rewrite-rw, braces

This commit is contained in:
rlar 2018-03-06 21:22:01 +01:00
parent 98cd4cb408
commit fd4a8bf51b
14 changed files with 60 additions and 90 deletions

View File

@ -26,7 +26,7 @@ CSWacLoad(GENmodel *inModel, CKTcircuit *ckt)
int current_state; int current_state;
/* loop through all the switch models */ /* loop through all the switch models */
for( ; model; model = CSWnextModel(model)) { for( ; model; model = CSWnextModel(model))
/* loop through all the instances of the model */ /* loop through all the instances of the model */
for (here = CSWinstances(model); here; for (here = CSWinstances(model); here;
@ -41,6 +41,5 @@ CSWacLoad(GENmodel *inModel, CKTcircuit *ckt)
*(here->CSWnegPosPtr) -= g_now; *(here->CSWnegPosPtr) -= g_now;
*(here->CSWnegNegPtr) += g_now; *(here->CSWnegNegPtr) += g_now;
} }
}
return OK; return OK;
} }

View File

@ -31,7 +31,7 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt)
/* switch is on or off while control value is in hysteresis region. */ /* switch is on or off while control value is in hysteresis region. */
/* loop through all the switch models */ /* loop through all the switch models */
for( ; model; model = CSWnextModel(model)) { for( ; model; model = CSWnextModel(model))
/* loop through all the instances of the model */ /* loop through all the instances of the model */
for (here = CSWinstances(model); here; for (here = CSWinstances(model); here;
@ -70,30 +70,29 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt)
/* use state0 since INITTRAN or INITPRED already called */ /* use state0 since INITTRAN or INITPRED already called */
if (model->CSWiHysteresis > 0) { if (model->CSWiHysteresis > 0) {
if (i_ctrl > (model->CSWiThreshold + model->CSWiHysteresis)) { if (i_ctrl > (model->CSWiThreshold + model->CSWiHysteresis))
current_state = REALLY_ON; current_state = REALLY_ON;
} else if (i_ctrl < (model->CSWiThreshold - model->CSWiHysteresis)) { else if (i_ctrl < (model->CSWiThreshold - model->CSWiHysteresis))
current_state = REALLY_OFF; current_state = REALLY_OFF;
} else { else
current_state = previous_state; current_state = previous_state;
}
} else { } else {
if (i_ctrl > (model->CSWiThreshold - model->CSWiHysteresis)) { if (i_ctrl > (model->CSWiThreshold - model->CSWiHysteresis))
current_state = REALLY_ON; current_state = REALLY_ON;
} else if (i_ctrl < (model->CSWiThreshold + model->CSWiHysteresis)) { else if (i_ctrl < (model->CSWiThreshold + model->CSWiHysteresis))
current_state = REALLY_OFF; current_state = REALLY_OFF;
} else { else {
/* in hysteresis... change value if going from low to hysteresis, /* in hysteresis... change value if going from low to hysteresis,
* or from hi to hysteresis. */ * or from hi to hysteresis. */
/* if previous state was in hysteresis, then don't change the state.. */ /* if previous state was in hysteresis, then don't change the state.. */
if ((previous_state == HYST_OFF) || (previous_state == HYST_ON)) { if ((previous_state == HYST_OFF) || (previous_state == HYST_ON))
current_state = previous_state; current_state = previous_state;
} else if (previous_state == REALLY_ON) { else if (previous_state == REALLY_ON)
current_state = HYST_OFF; current_state = HYST_OFF;
} else if (previous_state == REALLY_OFF) { else if (previous_state == REALLY_OFF)
current_state = HYST_ON; current_state = HYST_ON;
} else else
internalerror("bad value for previous region in swload"); internalerror("bad value for previous region in swload");
} }
} }
@ -106,30 +105,29 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt)
} else if (ckt->CKTmode & (MODEINITTRAN|MODEINITPRED)) { } else if (ckt->CKTmode & (MODEINITTRAN|MODEINITPRED)) {
if (model->CSWiHysteresis > 0) { if (model->CSWiHysteresis > 0) {
if (i_ctrl > (model->CSWiThreshold + model->CSWiHysteresis)) { if (i_ctrl > (model->CSWiThreshold + model->CSWiHysteresis))
current_state = REALLY_ON; current_state = REALLY_ON;
} else if (i_ctrl < (model->CSWiThreshold - model->CSWiHysteresis)) { else if (i_ctrl < (model->CSWiThreshold - model->CSWiHysteresis))
current_state = REALLY_OFF; current_state = REALLY_OFF;
} else { else
current_state = previous_state; current_state = previous_state;
}
} else { } else {
if (i_ctrl > (model->CSWiThreshold - model->CSWiHysteresis)) { if (i_ctrl > (model->CSWiThreshold - model->CSWiHysteresis))
current_state = REALLY_ON; current_state = REALLY_ON;
} else if (i_ctrl < (model->CSWiThreshold + model->CSWiHysteresis)) { else if (i_ctrl < (model->CSWiThreshold + model->CSWiHysteresis))
current_state = REALLY_OFF; current_state = REALLY_OFF;
} else { else {
/* in hysteresis... change value if going from low to hysteresis, /* in hysteresis... change value if going from low to hysteresis,
* or from hi to hysteresis. */ * or from hi to hysteresis. */
/* if previous state was in hysteresis, then don't change the state.. */ /* if previous state was in hysteresis, then don't change the state.. */
if ((previous_state == HYST_OFF) || (previous_state == HYST_ON)) { if ((previous_state == HYST_OFF) || (previous_state == HYST_ON))
current_state = previous_state; current_state = previous_state;
} else if (previous_state == REALLY_ON) { else if (previous_state == REALLY_ON)
current_state = HYST_OFF; current_state = HYST_OFF;
} else if (previous_state == REALLY_OFF) { else if (previous_state == REALLY_OFF)
current_state = HYST_ON; current_state = HYST_ON;
} else else
internalerror("bad value for previous region in cswload"); internalerror("bad value for previous region in cswload");
} }
} }
@ -148,6 +146,5 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt)
*(here->CSWnegPosPtr) -= g_now; *(here->CSWnegPosPtr) -= g_now;
*(here->CSWnegNegPtr) += g_now; *(here->CSWnegNegPtr) += g_now;
} }
}
return OK; return OK;
} }

View File

@ -36,7 +36,7 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d
int current_state; int current_state;
for (model=firstModel; model; model=CSWnextModel(model)) { for (model=firstModel; model; model=CSWnextModel(model))
for (inst=CSWinstances(model); inst; inst=CSWnextInstance(inst)) { for (inst=CSWinstances(model); inst; inst=CSWnextInstance(inst)) {
switch (operation) { switch (operation) {
@ -46,7 +46,7 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d
/* see if we have to to produce a summary report */ /* see if we have to to produce a summary report */
/* if so, name the noise generator */ /* if so, name the noise generator */
if (job->NStpsSm != 0) { if (job->NStpsSm != 0)
switch (mode) { switch (mode) {
case N_DENS: case N_DENS:
@ -58,7 +58,6 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d
NOISE_ADD_OUTVAR(ckt, data, "inoise_total_%s%s", inst->CSWname, ""); NOISE_ADD_OUTVAR(ckt, data, "inoise_total_%s%s", inst->CSWname, "");
break; break;
} }
}
break; break;
case N_CALC: case N_CALC:
@ -81,9 +80,8 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d
/* clear out our integration variable if it's the first pass */ /* clear out our integration variable if it's the first pass */
if (data->freq == job->NstartFreq) { if (data->freq == job->NstartFreq)
inst->CSWnVar[OUTNOIZ] = 0.0; inst->CSWnVar[OUTNOIZ] = 0.0;
}
} else { /* data->delFreq != 0.0 (we have to integrate) */ } else { /* data->delFreq != 0.0 (we have to integrate) */
tempOutNoise = Nintegrate(noizDens, lnNdens, tempOutNoise = Nintegrate(noizDens, lnNdens,
inst->CSWnVar[LNLSTDENS], data); inst->CSWnVar[LNLSTDENS], data);
@ -97,9 +95,8 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d
data->inNoise += tempInNoise; data->inNoise += tempInNoise;
inst->CSWnVar[LNLSTDENS] = lnNdens; inst->CSWnVar[LNLSTDENS] = lnNdens;
} }
if (data->prtSummary) { if (data->prtSummary)
data->outpVector[data->outNumber++] = noizDens; data->outpVector[data->outNumber++] = noizDens;
}
break; break;
case INT_NOIZ: /* already calculated, just output */ case INT_NOIZ: /* already calculated, just output */
@ -116,7 +113,6 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d
break; /* the plots */ break; /* the plots */
} /* switch (operation) */ } /* switch (operation) */
} /* for inst */ } /* for inst */
} /* for model */
return OK; return OK;
} }

View File

@ -25,14 +25,12 @@ CSWparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
here->CSWcontName = value->uValue; here->CSWcontName = value->uValue;
break; break;
case CSW_IC_ON: case CSW_IC_ON:
if(value->iValue) { if(value->iValue)
here->CSWzero_stateGiven = TRUE; here->CSWzero_stateGiven = TRUE;
}
break; break;
case CSW_IC_OFF: case CSW_IC_OFF:
if(value->iValue) { if(value->iValue)
here->CSWzero_stateGiven = FALSE; here->CSWzero_stateGiven = FALSE;
}
break; break;
default: default:
return E_BADPARM; return E_BADPARM;

View File

@ -30,7 +30,7 @@ CSWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
NG_IGNORE(s); NG_IGNORE(s);
/* loop through all the switch models */ /* loop through all the switch models */
for( ; model; model = CSWnextModel(model)) { for( ; model; model = CSWnextModel(model))
/* loop through all the instances of the model */ /* loop through all the instances of the model */
for (here = CSWinstances(model); here; for (here = CSWinstances(model); here;
@ -45,6 +45,5 @@ CSWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
*(here->CSWnegPosPtr) -= g_now; *(here->CSWnegPosPtr) -= g_now;
*(here->CSWnegNegPtr) += g_now; *(here->CSWnegNegPtr) += g_now;
} }
}
return OK; return OK;
} }

View File

@ -25,12 +25,10 @@ CSWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
/* loop through all the current source models */ /* loop through all the current source models */
for( ; model; model = CSWnextModel(model)) { for( ; model; model = CSWnextModel(model)) {
/* Default Value Processing for Switch Model */ /* Default Value Processing for Switch Model */
if (!model->CSWthreshGiven) { if (!model->CSWthreshGiven)
model->CSWiThreshold = 0; model->CSWiThreshold = 0;
} if (!model->CSWhystGiven)
if (!model->CSWhystGiven) {
model->CSWiHysteresis = 0; model->CSWiHysteresis = 0;
}
if (!model->CSWonGiven) { if (!model->CSWonGiven) {
model->CSWonConduct = CSW_ON_CONDUCTANCE; model->CSWonConduct = CSW_ON_CONDUCTANCE;
model->CSWonResistance = 1.0/model->CSWonConduct; model->CSWonResistance = 1.0/model->CSWonConduct;

View File

@ -21,7 +21,7 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
double lastChange, maxChange, maxStep, ref; double lastChange, maxChange, maxStep, ref;
for( ; model; model = CSWnextModel(model)) { for( ; model; model = CSWnextModel(model))
for(here = CSWinstances(model); here; for(here = CSWinstances(model); here;
here = CSWnextInstance(here)) { here = CSWnextInstance(here)) {
lastChange = ckt->CKTstates[0][here->CSWstate + 1] - lastChange = ckt->CKTstates[0][here->CSWstate + 1] -
@ -32,7 +32,7 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
maxChange = (ref - ckt->CKTstates[0][here->CSWstate + 1]) * maxChange = (ref - ckt->CKTstates[0][here->CSWstate + 1]) *
0.75 + 0.00005; 0.75 + 0.00005;
maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0]; maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0];
if (*timeStep > maxStep) { *timeStep = maxStep; } if (*timeStep > maxStep) *timeStep = maxStep;
} }
} else { } else {
ref = (model->CSWiThreshold - model->CSWiHysteresis); ref = (model->CSWiThreshold - model->CSWiHysteresis);
@ -40,10 +40,9 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
maxChange = (ref - ckt->CKTstates[0][here->CSWstate + 1]) * maxChange = (ref - ckt->CKTstates[0][here->CSWstate + 1]) *
0.75 - 0.00005; 0.75 - 0.00005;
maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0]; maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0];
if (*timeStep > maxStep) { *timeStep = maxStep; } if (*timeStep > maxStep) *timeStep = maxStep;
} }
} }
} }
}
return OK; return OK;
} }

View File

@ -25,7 +25,7 @@ SWacLoad(GENmodel *inModel, CKTcircuit *ckt)
int current_state; int current_state;
/* loop through all the switch models */ /* loop through all the switch models */
for( ; model; model = SWnextModel(model)) { for( ; model; model = SWnextModel(model))
/* loop through all the instances of the model */ /* loop through all the instances of the model */
for (here = SWinstances(model); here; for (here = SWinstances(model); here;
@ -42,6 +42,5 @@ SWacLoad(GENmodel *inModel, CKTcircuit *ckt)
*(here->SWnegPosPtr) -= g_now; *(here->SWnegPosPtr) -= g_now;
*(here->SWnegNegPtr) += g_now; *(here->SWnegNegPtr) += g_now;
} }
}
return OK; return OK;
} }

View File

@ -31,7 +31,7 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
// double current_region = -1; // double current_region = -1;
/* loop through all the switch models */ /* loop through all the switch models */
for( ; model; model = SWnextModel(model)) { for( ; model; model = SWnextModel(model))
/* loop through all the instances of the model */ /* loop through all the instances of the model */
for (here = SWinstances(model); here; for (here = SWinstances(model); here;
@ -72,29 +72,26 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
/* use state0 since INITTRAN or INITPRED already called */ /* use state0 since INITTRAN or INITPRED already called */
if (model->SWvHysteresis > 0) { if (model->SWvHysteresis > 0) {
if (v_ctrl > (model->SWvThreshold + model->SWvHysteresis)) { if (v_ctrl > (model->SWvThreshold + model->SWvHysteresis))
current_state = REALLY_ON; current_state = REALLY_ON;
} else if (v_ctrl < (model->SWvThreshold - model->SWvHysteresis)) { else if (v_ctrl < (model->SWvThreshold - model->SWvHysteresis))
current_state = REALLY_OFF; current_state = REALLY_OFF;
} else { else
current_state = old_current_state; current_state = old_current_state;
}
} else { // negative hysteresis case. } else { // negative hysteresis case.
if (v_ctrl > (model->SWvThreshold - model->SWvHysteresis)) if (v_ctrl > (model->SWvThreshold - model->SWvHysteresis))
{
current_state = REALLY_ON; current_state = REALLY_ON;
} else if (v_ctrl < (model->SWvThreshold + model->SWvHysteresis)) else if (v_ctrl < (model->SWvThreshold + model->SWvHysteresis))
{
current_state = REALLY_OFF; current_state = REALLY_OFF;
} else { // in hysteresis... change value if going from low to hysteresis, or from hi to hysteresis. else { // in hysteresis... change value if going from low to hysteresis, or from hi to hysteresis.
// if previous state was in hysteresis, then don't change the state.. // if previous state was in hysteresis, then don't change the state..
if ((previous_state == HYST_OFF) || (previous_state == HYST_ON)) { if ((previous_state == HYST_OFF) || (previous_state == HYST_ON))
current_state = previous_state; current_state = previous_state;
} else if (previous_state == REALLY_ON) { else if (previous_state == REALLY_ON)
current_state = HYST_OFF; current_state = HYST_OFF;
} else if (previous_state == REALLY_OFF) { else if (previous_state == REALLY_OFF)
current_state = HYST_ON; current_state = HYST_ON;
} else else
internalerror("bad value for previous state in swload"); internalerror("bad value for previous state in swload");
} }
} }
@ -121,13 +118,12 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
current_state = REALLY_OFF; current_state = REALLY_OFF;
else { else {
current_state = 0.0; current_state = 0.0;
if ((previous_state == HYST_ON) || (previous_state == HYST_OFF)) { if ((previous_state == HYST_ON) || (previous_state == HYST_OFF))
current_state = previous_state; current_state = previous_state;
} else if (previous_state == REALLY_ON) { else if (previous_state == REALLY_ON)
current_state = REALLY_OFF; current_state = REALLY_OFF;
} else if (previous_state == REALLY_OFF) { else if (previous_state == REALLY_OFF)
current_state = REALLY_ON; current_state = REALLY_ON;
}
} }
} }
} }
@ -151,6 +147,5 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
*(here->SWnegPosPtr) -= g_now; *(here->SWnegPosPtr) -= g_now;
*(here->SWnegNegPtr) += g_now; *(here->SWnegNegPtr) += g_now;
} }
}
return OK; return OK;
} }

View File

@ -36,7 +36,7 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da
int current_state; int current_state;
for (model=firstModel; model; model=SWnextModel(model)) { for (model=firstModel; model; model=SWnextModel(model))
for (inst=SWinstances(model); inst; inst=SWnextInstance(inst)) { for (inst=SWinstances(model); inst; inst=SWnextInstance(inst)) {
switch (operation) { switch (operation) {
@ -46,7 +46,7 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da
/* see if we have to to produce a summary report */ /* see if we have to to produce a summary report */
/* if so, name the noise generator */ /* if so, name the noise generator */
if (job->NStpsSm != 0) { if (job->NStpsSm != 0)
switch (mode) { switch (mode) {
case N_DENS: case N_DENS:
@ -58,7 +58,6 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da
NOISE_ADD_OUTVAR(ckt, data, "inoise_total_%s%s", inst->SWname, ""); NOISE_ADD_OUTVAR(ckt, data, "inoise_total_%s%s", inst->SWname, "");
break; break;
} }
}
break; break;
case N_CALC: case N_CALC:
@ -81,9 +80,8 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da
/* clear out our integration variable if it's the first pass */ /* clear out our integration variable if it's the first pass */
if (data->freq == job->NstartFreq) { if (data->freq == job->NstartFreq)
inst->SWnVar[OUTNOIZ] = 0.0; inst->SWnVar[OUTNOIZ] = 0.0;
}
} else { /* data->delFreq != 0.0 (we have to integrate) */ } else { /* data->delFreq != 0.0 (we have to integrate) */
tempOutNoise = Nintegrate(noizDens, lnNdens, tempOutNoise = Nintegrate(noizDens, lnNdens,
inst->SWnVar[LNLSTDENS], data); inst->SWnVar[LNLSTDENS], data);
@ -97,9 +95,8 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da
data->inNoise += tempInNoise; data->inNoise += tempInNoise;
inst->SWnVar[LNLSTDENS] = lnNdens; inst->SWnVar[LNLSTDENS] = lnNdens;
} }
if (data->prtSummary) { if (data->prtSummary)
data->outpVector[data->outNumber++] = noizDens; data->outpVector[data->outNumber++] = noizDens;
}
break; break;
case INT_NOIZ: /* already calculated, just output */ case INT_NOIZ: /* already calculated, just output */
@ -116,7 +113,6 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da
break; /* the plots */ break; /* the plots */
} /* switch (operation) */ } /* switch (operation) */
} /* for inst */ } /* for inst */
} /* for model */
return OK; return OK;
} }

View File

@ -22,14 +22,12 @@ SWparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
switch(param) { switch(param) {
case SW_IC_ON: case SW_IC_ON:
if(value->iValue) { if(value->iValue)
here->SWzero_stateGiven = TRUE; here->SWzero_stateGiven = TRUE;
}
break; break;
case SW_IC_OFF: case SW_IC_OFF:
if(value->iValue) { if(value->iValue)
here->SWzero_stateGiven = FALSE; here->SWzero_stateGiven = FALSE;
}
break; break;
default: default:
return E_BADPARM; return E_BADPARM;

View File

@ -29,7 +29,7 @@ SWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
NG_IGNORE(s); NG_IGNORE(s);
/* loop through all the switch models */ /* loop through all the switch models */
for( ; model; model = SWnextModel(model)) { for( ; model; model = SWnextModel(model))
/* loop through all the instances of the model */ /* loop through all the instances of the model */
for (here = SWinstances(model); here; for (here = SWinstances(model); here;
@ -46,6 +46,5 @@ SWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
*(here->SWnegPosPtr) -= g_now; *(here->SWnegPosPtr) -= g_now;
*(here->SWnegNegPtr) += g_now; *(here->SWnegNegPtr) += g_now;
} }
}
return OK; return OK;
} }

View File

@ -25,12 +25,10 @@ SWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
/* loop through all the current source models */ /* loop through all the current source models */
for( ; model; model = SWnextModel(model)) { for( ; model; model = SWnextModel(model)) {
/* Default Value Processing for Switch Model */ /* Default Value Processing for Switch Model */
if (!model->SWthreshGiven) { if (!model->SWthreshGiven)
model->SWvThreshold = 0; model->SWvThreshold = 0;
} if (!model->SWhystGiven)
if (!model->SWhystGiven) {
model->SWvHysteresis = 0; model->SWvHysteresis = 0;
}
if (!model->SWonGiven) { if (!model->SWonGiven) {
model->SWonConduct = SW_ON_CONDUCTANCE; model->SWonConduct = SW_ON_CONDUCTANCE;
model->SWonResistance = 1.0/model->SWonConduct; model->SWonResistance = 1.0/model->SWonConduct;

View File

@ -19,7 +19,7 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
SWinstance *here; SWinstance *here;
double lastChange, maxChange, maxStep, ref; double lastChange, maxChange, maxStep, ref;
for( ; model; model = SWnextModel(model)) { for( ; model; model = SWnextModel(model))
for(here = SWinstances(model); here; for(here = SWinstances(model); here;
here = SWnextInstance(here)) { here = SWnextInstance(here)) {
lastChange = ckt->CKTstates[0][here->SWstate + 1] - lastChange = ckt->CKTstates[0][here->SWstate + 1] -
@ -30,7 +30,7 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
maxChange = (ref - ckt->CKTstates[0][here->SWstate + 1]) * maxChange = (ref - ckt->CKTstates[0][here->SWstate + 1]) *
0.75 + 0.05; 0.75 + 0.05;
maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0]; maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0];
if (*timeStep > maxStep) { *timeStep = maxStep; } if (*timeStep > maxStep) *timeStep = maxStep;
} }
} else { } else {
ref = (model->SWvThreshold - model->SWvHysteresis); ref = (model->SWvThreshold - model->SWvHysteresis);
@ -38,10 +38,9 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
maxChange = (ref - ckt->CKTstates[0][here->SWstate + 1]) * maxChange = (ref - ckt->CKTstates[0][here->SWstate + 1]) *
0.75 - 0.05; 0.75 - 0.05;
maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0]; maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0];
if (*timeStep > maxStep) { *timeStep = maxStep; } if (*timeStep > maxStep) *timeStep = maxStep;
} }
} }
} }
}
return OK; return OK;
} }