Replace lengthy call to CKTcircuit by new TSTOP and TSTEP macros
This commit is contained in:
parent
28df521b11
commit
d7db4192a8
|
|
@ -81,85 +81,6 @@ typedef struct {
|
||||||
double start_val; /* signal time 0 value */
|
double start_val; /* signal time 0 value */
|
||||||
} mLocal_Data_t;
|
} mLocal_Data_t;
|
||||||
|
|
||||||
|
|
||||||
struct CKTcircuitmin {
|
|
||||||
|
|
||||||
/* This is a minimum re-definition of the circuit structure defined in
|
|
||||||
cktdefs.h. We are interested in TSTEP and TSTOP */
|
|
||||||
|
|
||||||
GENmodel **CKThead;
|
|
||||||
STATistics *CKTstat; /* The STATistics structure */
|
|
||||||
double *CKTstates[8]; /* Used as memory of past steps ??? */
|
|
||||||
double CKTtime; /* Current transient simulation time */
|
|
||||||
double CKTdelta; /* next time step in transient simulation */
|
|
||||||
double CKTdeltaOld[7]; /* Memory for the 7 most recent CKTdelta */
|
|
||||||
double CKTtemp; /* Actual temperature of CKT, initialzed to 300.15 K in cktinit.c*/
|
|
||||||
double CKTnomTemp; /* Reference temperature 300.15 K set in cktinit.c */
|
|
||||||
double CKTvt; /* Thernmal voltage at CKTtemp */
|
|
||||||
double CKTag[7]; /* the gear variable coefficient matrix */
|
|
||||||
#ifdef PREDICTOR
|
|
||||||
double CKTagp[7]; /* the gear predictor variable coefficient matrix */
|
|
||||||
#endif /*PREDICTOR*/
|
|
||||||
int CKTorder; /* the integration method order */
|
|
||||||
int CKTmaxOrder; /* maximum integration method order */
|
|
||||||
int CKTintegrateMethod; /* the integration method to be used */
|
|
||||||
double CKTxmu; /* for trapezoidal method */
|
|
||||||
int CKTindverbosity; /* control check of inductive couplings */
|
|
||||||
SMPmatrix *CKTmatrix; /* pointer to sparse matrix */
|
|
||||||
int CKTniState; /* internal state */
|
|
||||||
double *CKTrhs; /* current rhs value - being loaded */
|
|
||||||
double *CKTrhsOld; /* previous rhs value for convergence testing */
|
|
||||||
double *CKTrhsSpare; /* spare rhs value for reordering */
|
|
||||||
double *CKTirhs; /* current rhs value - being loaded imag) */
|
|
||||||
double *CKTirhsOld; /* previous rhs value (imaginary)*/
|
|
||||||
double *CKTirhsSpare; /* spare rhs value (imaginary)*/
|
|
||||||
#ifdef PREDICTOR
|
|
||||||
double *CKTpred; /* predicted solution vector */
|
|
||||||
double *CKTsols[8]; /* previous 8 solutions */
|
|
||||||
#endif /* PREDICTOR */
|
|
||||||
double *CKTrhsOp; /* opearating point values */
|
|
||||||
double *CKTsenRhs; /* current sensitivity rhs values */
|
|
||||||
double *CKTseniRhs; /* current sensitivity rhs values (imag)*/
|
|
||||||
int CKTmaxEqNum; /* And this ? */
|
|
||||||
int CKTcurrentAnalysis; /* the analysis in progress (if any) */
|
|
||||||
CKTnode *CKTnodes; /* ??? */
|
|
||||||
CKTnode *CKTlastNode; /* ??? */
|
|
||||||
CKTnode *prev_CKTlastNode; /* just before model setup */
|
|
||||||
int CKTnumStates; /* Number of sates effectively valid ??? */
|
|
||||||
long CKTmode; /* Mode of operation of the circuit ??? */
|
|
||||||
int CKTbypass; /* bypass option, how does it work ? */
|
|
||||||
int CKTdcMaxIter; /* iteration limit for dc op. (itl1) */
|
|
||||||
int CKTdcTrcvMaxIter; /* iteration limit for dc tran. curv (itl2) */
|
|
||||||
int CKTtranMaxIter; /* iteration limit for each timepoint for tran*/
|
|
||||||
int CKTbreakSize; /* ??? */
|
|
||||||
int CKTbreak; /* ??? */
|
|
||||||
double CKTsaveDelta; /* ??? */
|
|
||||||
double CKTminBreak; /* ??? */
|
|
||||||
double *CKTbreaks; /* List of breakpoints ??? */
|
|
||||||
double CKTabstol; /* --- */
|
|
||||||
double CKTpivotAbsTol; /* --- */
|
|
||||||
double CKTpivotRelTol; /* --- */
|
|
||||||
double CKTreltol; /* --- */
|
|
||||||
double CKTchgtol; /* --- */
|
|
||||||
double CKTvoltTol; /* --- */
|
|
||||||
double CKTlteReltol; /* relative error in voltage based truncation error estimation */
|
|
||||||
double CKTlteAbstol; /* absolute error in voltage based truncation error estimation */
|
|
||||||
double CKTlteTrtol; /* scaling time step in voltage based truncation error estimation */
|
|
||||||
int CKTnewtrunc; /* enable lte (local truncation error) based on voltages */
|
|
||||||
double CKTgmin; /* .options GMIN */
|
|
||||||
double CKTgshunt; /* .options RSHUNT */
|
|
||||||
double CKTcshunt; /* .options CSHUNT */
|
|
||||||
double CKTdelmin; /* minimum time step for tran analysis */
|
|
||||||
double CKTtrtol; /* .options TRTOL */
|
|
||||||
double CKTfinalTime; /* TSTOP */
|
|
||||||
double CKTstep; /* TSTEP */
|
|
||||||
double CKTmaxStep; /* TMAX */
|
|
||||||
double CKTinitTime; /* TSTART */
|
|
||||||
/* struct is truncated here */
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct CKTcircuitmin CKTcircuitmin;
|
|
||||||
|
|
||||||
/*=== FUNCTION PROTOTYPE DEFINITIONS ===*/
|
/*=== FUNCTION PROTOTYPE DEFINITIONS ===*/
|
||||||
|
|
||||||
static void cm_delay_callback(ARGS, Mif_Callback_Reason_t reason);
|
static void cm_delay_callback(ARGS, Mif_Callback_Reason_t reason);
|
||||||
|
|
@ -174,8 +95,6 @@ void cm_delay(ARGS)
|
||||||
|
|
||||||
mLocal_Data_t *loc; /* Pointer to local static data, not to be included
|
mLocal_Data_t *loc; /* Pointer to local static data, not to be included
|
||||||
in the state vector */
|
in the state vector */
|
||||||
CKTcircuitmin *ckt;
|
|
||||||
|
|
||||||
|
|
||||||
if (ANALYSIS != MIF_AC) { /**** only Transient Analysis and dc ****/
|
if (ANALYSIS != MIF_AC) { /**** only Transient Analysis and dc ****/
|
||||||
|
|
||||||
|
|
@ -185,11 +104,12 @@ void cm_delay(ARGS)
|
||||||
|
|
||||||
CALLBACK = cm_delay_callback;
|
CALLBACK = cm_delay_callback;
|
||||||
|
|
||||||
ckt = (CKTcircuitmin*)cm_get_circuit();
|
|
||||||
|
|
||||||
if (PARAM_NULL(buffer_size)) {
|
if (PARAM_NULL(buffer_size)) {
|
||||||
/* size depends on TSTOP/TSTEP, if no parameter given */
|
/* size depends on TSTOP/TSTEP, if no parameter given */
|
||||||
buffer_size = (int) (ckt->CKTfinalTime / ckt->CKTstep) + 1;
|
if (TSTEP > 0) /* called from tran analysis */
|
||||||
|
buffer_size = (int) (TSTOP/TSTEP) + 1;
|
||||||
|
else /* called from op or dc analysis */
|
||||||
|
buffer_size = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buffer_size = PARAM(buffer_size);
|
buffer_size = PARAM(buffer_size);
|
||||||
|
|
@ -232,22 +152,22 @@ void cm_delay(ARGS)
|
||||||
loc->tdelmin = 0.0;
|
loc->tdelmin = 0.0;
|
||||||
cm_message_send("Negative min delay not allowed, set to 0");
|
cm_message_send("Negative min delay not allowed, set to 0");
|
||||||
}
|
}
|
||||||
else if (loc->tdelmin > ckt->CKTfinalTime) {
|
else if (loc->tdelmin > TSTOP) {
|
||||||
loc->tdelmin = ckt->CKTfinalTime;
|
loc->tdelmin = TSTOP;
|
||||||
cm_message_send("min delay greater than final sim time not allowed, set to final time");
|
cm_message_send("min delay greater than final sim time not allowed, set to final time");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PARAM_NULL(delmax))
|
if (PARAM_NULL(delmax))
|
||||||
loc->tdelmax = ckt->CKTfinalTime;
|
loc->tdelmax = TSTOP;
|
||||||
else {
|
else {
|
||||||
loc->tdelmax = PARAM(delmax);
|
loc->tdelmax = PARAM(delmax);
|
||||||
if (loc->tdelmax < 0) {
|
if (loc->tdelmax < 0) {
|
||||||
loc->tdelmin = 0.0;
|
loc->tdelmin = 0.0;
|
||||||
cm_message_send("Negative max delay not allowed, set to 0");
|
cm_message_send("Negative max delay not allowed, set to 0");
|
||||||
}
|
}
|
||||||
else if (loc->tdelmax > ckt->CKTfinalTime) {
|
else if (loc->tdelmax > TSTOP) {
|
||||||
loc->tdelmax = ckt->CKTfinalTime;
|
loc->tdelmax = TSTOP;
|
||||||
cm_message_send("max delay greater than final sim time not allowed, set to final time");
|
cm_message_send("max delay greater than final sim time not allowed, set to final time");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -261,8 +181,8 @@ void cm_delay(ARGS)
|
||||||
loc->buff_del = 0;
|
loc->buff_del = 0;
|
||||||
loc->step_count = 0;
|
loc->step_count = 0;
|
||||||
loc->tdelay = delay;
|
loc->tdelay = delay;
|
||||||
loc->tstop = ckt->CKTfinalTime;
|
loc->tstop = TSTOP;
|
||||||
loc->tstep = ckt->CKTstep;
|
loc->tstep = TSTEP;
|
||||||
loc->tprev = 0.0;
|
loc->tprev = 0.0;
|
||||||
loc->prev_val = 0.0;
|
loc->prev_val = 0.0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue