50 #define STEPDEBUG 0 // set to zero for release
51 #define BREAKPOINTS 0 // exact breakpoint calculation
53 #define dState 0 // delta T state
54 #define sState 1 // solution state
57 #define SOL(state) (solution[(int) getState (sState, (state))])
61 using namespace transient;
65 : nasolver<nr_double_t> (), states<nr_double_t> ()
69 setDescription (
"transient");
70 for (
int i = 0;
i < 8;
i++) solution[
i] = NULL;
93 for (
int i = 0;
i < 8;
i++)
118 if (
swp != NULL)
delete swp;
177 nr_double_t time, saveCurrent;
178 int error = 0, convError = 0;
191 if (!strcmp (solver,
"CroutLU"))
193 else if (!strcmp (solver,
"DoolittleLU"))
195 else if (!strcmp (solver,
"HouseholderQR"))
197 else if (!strcmp (solver,
"HouseholderLQ"))
199 else if (!strcmp (solver,
"GolubSVD"))
256 "WARNING: %s: minimum delta h = %.3e at t = %.3e\n",
313 "(no convergence)\n", (
double) saveCurrent, (
double)
delta);
323 if (error)
return -1;
372 while (saveCurrent < time);
377 (
double) saveCurrent, (
double)
delta);
392 "%d non-convergences\n",
getName (),
408 nr_double_t age = 0.0;
412 if (
c->hasHistory ())
416 if (
c->getHistoryAge () > age)
418 age =
c->getHistoryAge ();
451 for (i = 0; i <
s; i++)
502 for (
int i = 0;
i < 8;
i++) *
SOL (
i) = *
s;
511 nr_double_t xn, dd, hn;
514 for (
int r = 0;
r < N +
M;
r++)
521 dd = (
SOL(o)->get (
r) -
SOL(o + 1)->get (
r)) / hn;
535 nr_double_t xn, dd, hn;
537 for (
int r = 0;
r < N +
M;
r++)
541 dd = (
SOL(1)->get (
r) -
SOL(2)->get (
r)) / hn;
556 for (
int r = 0;
r < N +
M;
r++)
601 for (
int s = 0;
s <
c->getStates ();
s++)
602 c->fillState (
s,
c->getState (
s));
670 "DEBUG: delta accepted at t = %.3e, h = %.3e\n",
680 "DEBUG: delta rejected at t = %.3e, h = %.3e\n",
683 if (current > 0) current -=
deltaOld;
739 c->calcTR (self->current);
750 if (
c->isNonLinear ())
c->restartDC ();
786 deltaMax =
MIN ((stop - start) / (points - 1), stop / 200);
790 delta =
MIN (stop / 200, deltaMax) / 10;
809 for (
int i = 0;
i < 8;
i++)
833 for (
int i = 0;
i < 8;
i++)
862 if ((t =
data->findDependency (
"time")) == NULL)
865 data->addDependency (t);
879 nr_double_t dif, rel,
tol, lte, q,
n = NR_MAX;
889 for (
int r = 0;
r < N +
M;
r++)
899 dif =
x->get (
r) -
SOL(0)->get (
r);
900 if (std::isfinite (dif) && dif != 0)
903 rel =
MAX (fabs (
x->get (
r)), fabs (
SOL(0)->get (
r)));
904 tol = LTEreltol * rel + LTEabstol;
905 lte = LTEfactor * (cec / (pec - cec)) * dif;
912 "error h = %.3e\n", (
double) n);
943 PROP_RNG_STR4 (
"Euler",
"Trapezoidal",
"Gear",
"AdamsMoulton")
nr_double_t getCorrectorError(int, int)
static void calcTR(trsolver *)
#define PROP_RNG_STR2(s1, s2)
void fillState(int, state_type_t)
int correctorType(char *, int &)
void recallSolution(void)
nr_double_t getPropertyDouble(const char *)
void applyNodeset(bool nokeep=true)
void appendHistory(int, nr_double_t)
void calcCorrectorCoeff(int, int, nr_double_t *, nr_double_t *)
void logprogressclear(int points)
#define K
Absolute 0 in centigrade.
int getPropertyInteger(const char *)
int getVoltageSource(void)
#define catch_exception()
tvector< nr_double_t > * solution[8]
void setIntegrationMethod(circuit *, int)
int solve(void)
placehoder for solution function
void setDescription(const char *n)
int getSize(void)
Get the number of ports the circuit element has.
nr_double_t getPredictorError(int, int)
void adjustDelta(nr_double_t)
template class for storing state variables.
int getVoltageSources(void)
void calcPredictorCoeff(int, int, nr_double_t *, nr_double_t *)
void predictBashford(void)
void saveAllResults(nr_double_t)
void initHistory(nr_double_t)
base class for qucs circuit elements.
void fillSolution(tvector< nr_double_t > *)
void saveResults(const char *, const char *, int, qucs::vector *f=NULL)
void setCalculation(calculate_func_t f)
void adjustOrder(int reduce=0)
nr_double_t checkDelta(void)
The analysis class header file.
circuit * findVoltageSource(int)
void updateCoefficients(nr_double_t)
void print(const char *prefix=NULL)
void setAge(nr_double_t a)
#define PROP_RNG_STR4(s1, s2, s3, s4)
int predictorType(int, int, int &)
state_type_t getState(int, int n=0)
The circuit class header file.
int solve_nonlinear(void)
virtual void initTR(void)
void saveHistory(circuit *)
int countVoltageSources(void)
#define MIN(x, y)
Minimum of x and y.
void logprogressbar(nr_double_t current, nr_double_t final, int points)
void setCoefficients(nr_double_t *c)
void saveState(int, state_type_t *)
const char * getDescription(void)
sweep * createSweep(const char *)
create a named sweep object
void initCircuitTR(circuit *)
nr_complex_t exp(const nr_complex_t z)
Compute complex exponential.
#define CONV_SteepestDescent
char * getPropertyString(const char *)
void setState(int, state_type_t, int n=0)
void logprint(int level, const char *format,...)
nr_complex_t log(const nr_complex_t z)
Compute principal value of natural logarithm of z.
int findAssignedNode(circuit *, int)
void(* calculate_func_t)(nasolver< nr_type_t > *)
static void calcDC(trsolver *)
#define PROP_NO_SUBSTRATE
void updateHistory(nr_double_t)
#define MAX(x, y)
Maximum of x and y.