62 #define STEPDEBUG 0 // set to zero for release
63 #define BREAKPOINTS 0 // exact breakpoint calculation
66 #define dState 0 // delta T state
70 #define sState 1 // solution state
75 #define SOL(state) (solution[(int) getState (sState, (state))])
80 using namespace transient;
134 for (
int i = 0;
i < 8;
i++)
169 if (
c->getSubcircuit ()) {
170 printf (
"subcircuit Name %s\n",
c->getSubcircuit ());
183 this->
getEnv()->runSolver();
204 if (!strcmp (solver,
"CroutLU"))
206 else if (!strcmp (solver,
"DoolittleLU"))
208 else if (!strcmp (solver,
"HouseholderQR"))
210 else if (!strcmp (solver,
"HouseholderLQ"))
212 else if (!strcmp (solver,
"GolubSVD"))
225 initETR (start, firstdelta, mode);
244 if (mode == ETR_MODE_ASYNC)
249 else if (mode == ETR_MODE_SYNC)
256 e->
setText (
"Unknown ETR mode.");
278 if (
c->hasHistory ())
307 if (mode == ETR_MODE_ASYNC){
320 else if (mode == ETR_MODE_SYNC)
342 for (
int i = 0;
i < 8;
i++)
374 for (
int r = 0;
r <
x->getSize();
r++) {
383 sprintf (buf,
"%f\t%18.17f\t%6.5f %6.5f %6.5f %6.5f %6.5f %6.5f %6.5f %6.5f",
385 (
double)
real (
x->get (
r)),
492 if (error)
return -1;
614 "DEBUG: delta accepted at t = %.3e, h = %.3e\n",
624 "DEBUG: delta rejected at t = %.3e, h = %.3e\n",
627 if (current > 0) current -=
deltaOld;
666 "WARNING: %s: minimum delta h = %.3e at t = %.3e\n",
727 if (error)
return -1;
810 for (
int i = 0;
i < 8;
i++)
828 for (
int i = 0;
i < 8;
i++)
831 assert (src[
i]->getSize () == dest[
i]->getSize ());
833 for (
int j = 0; j < src[
i]->
getSize (); j++)
835 dest[
i]->
set (j, src[
i]->
get (j));
848 if (
c->hasHistory ())
879 for (
int r = 0;
r < N +
M;
r++)
906 std::string fullname;
921 if (
c->getSubcircuit ())
923 fullname.append (
c->getSubcircuit ());
924 fullname.append (
".");
928 fullname.append (probename);
931 if (strcmp (fullname.c_str(),
c->getName ()) == 0)
935 c->saveOperatingPoints ();
938 probeV =
c->getOperatingPoint (
"Vr");
952 std::string fullname;
967 if (
c->getSubcircuit ())
969 fullname.append (
c->getSubcircuit ());
970 fullname.append (
".");
974 fullname.append (probename);
977 if (strcmp (fullname.c_str(),
c->getName ()) == 0)
980 probeI =
real (
x->get (
c->getVoltageSource () +
getN ()));
993 std::string fullname;
1009 if (
c->getSubcircuit ())
1011 fullname.append (
c->getSubcircuit ());
1012 fullname.append (
".");
1016 fullname.append (ecvsname);
1019 if (strcmp (fullname.c_str(),
c->getName ()) == 0)
1022 c->setProperty(
"U", V);
1040 c->setProperty (
"Tnext", t);
1057 if (
c->hasHistory ())
c->truncateHistory (t);
1063 return A->getRows();
1068 return A->getCols();
1085 PROP_RNG_STR4 (
"Euler",
"Trapezoidal",
"Gear",
"AdamsMoulton")
void getsolution(double *)
The externally controlled voltage source component implementation file.
matrix real(matrix a)
Real part matrix.
void fillLastSolution(tvector< nr_double_t > *)
tvector< nr_double_t > * lastsolution[8]
int setECVSVoltage(char *ecvsname, nr_double_t V)
Sets the voltage of an exterally controlled voltage source.
static void calcTR(trsolver *)
void updateExternalInterpTime(nr_double_t)
void fillState(int, state_type_t)
int correctorType(char *, int &)
void recallSolution(void)
int getN()
Returns the number of node voltages in the circuit.
nr_double_t getPropertyDouble(const char *)
void applyNodeset(bool nokeep=true)
void storeHistoryAges(void)
void(* messagefcn)(int level, const char *format,...)
Pointer to function used to print messages during a sim.
void calcCorrectorCoeff(int, int, nr_double_t *, nr_double_t *)
void logprogressclear(int points)
void updateHistoryAges(nr_double_t)
#define K
Absolute 0 in centigrade.
int getPropertyInteger(const char *)
void truncateHistory(nr_double_t)
#define catch_exception()
tvector< nr_double_t > * solution[8]
int getJacCols()
Returns the number of columns in the Jacobian matrix for the circuit.
void setDescription(const char *n)
#define throw_exception(e)
nr_double_t lastdeltas[8]
void adjustDelta_sync(nr_double_t)
void adjustDelta(nr_double_t)
void copySolution(tvector< nr_double_t > *[8], tvector< nr_double_t > *[8])
void calcPredictorCoeff(int, int, nr_double_t *, nr_double_t *)
int getNodeV(char *label, nr_double_t &nodeV)
Obtains the voltage of a node by name.
std::vector< nr_double_t > initialhistages
void initHistory(nr_double_t)
base class for qucs circuit elements.
void fillSolution(tvector< nr_double_t > *)
int getVProbeV(char *probename, nr_double_t &probeV)
Obtains the voltage reported by a voltage probe.
void setCalculation(calculate_func_t f)
environment * getEnv(void)
void initETR(nr_double_t start, nr_double_t, int)
void adjustOrder(int reduce=0)
The analysis class header file.
void updateCoefficients(nr_double_t)
void print(const char *prefix=NULL)
void rejectstep_async(void)
int stepsolve_async(nr_double_t steptime)
#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)
int getJacRows()
Returns the number of rows in the Jacobian matrix for the circuit.
The externally controlled trsolver external class header file.
int countVoltageSources(void)
int stepsolve_sync(nr_double_t synctime)
void getJacData(int r, int c, nr_double_t &data)
Obtains the data from the Jacobian matrix for the circuit.
int getIProbeI(char *probename, nr_double_t &probeI)
Obtains the current reported by a current probe.
External interface class for transient simulation.
void saveState(int, state_type_t *)
const char * getDescription(void)
void initCircuitTR(circuit *)
The environment class definition.
void inputState(int, state_type_t *)
void setText(const char *,...)
nr_double_t lastasynctime
int init(nr_double_t, nr_double_t, int)
#define CONV_SteepestDescent
char * getPropertyString(const char *)
void setState(int, state_type_t, int n=0)
void logprint(int level, const char *format,...)
void acceptstep_async(void)
void(* calculate_func_t)(nasolver< nr_type_t > *)
void updateHistory(nr_double_t)
void acceptstep_sync(void)