rewrite-rw, line wraps
This commit is contained in:
parent
97d61c495f
commit
b0a8cd33d2
|
|
@ -29,8 +29,7 @@ CSWacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
|||
for( ; model; model = CSWnextModel(model))
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = CSWinstances(model); here;
|
||||
here=CSWnextInstance(here)) {
|
||||
for (here = CSWinstances(model); here; here=CSWnextInstance(here)) {
|
||||
|
||||
current_state = (int) ckt->CKTstates[0][here->CSWstate + 0];
|
||||
|
||||
|
|
|
|||
|
|
@ -45,8 +45,9 @@ CSWask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *s
|
|||
strcpy(errMsg,msg);
|
||||
return E_ASKCURRENT;
|
||||
} else {
|
||||
value->rValue = (ckt->CKTrhsOld[here->CSWposNode]
|
||||
- ckt->CKTrhsOld[here->CSWnegNode]) *
|
||||
value->rValue =
|
||||
(ckt->CKTrhsOld[here->CSWposNode] -
|
||||
ckt->CKTrhsOld[here->CSWnegNode]) *
|
||||
here->CSWcond;
|
||||
}
|
||||
return OK;
|
||||
|
|
@ -57,10 +58,11 @@ CSWask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *s
|
|||
strcpy(errMsg,msg);
|
||||
return E_ASKPOWER;
|
||||
} else {
|
||||
value->rValue = (ckt->CKTrhsOld[here->CSWposNode]
|
||||
- ckt->CKTrhsOld[here->CSWnegNode]) *
|
||||
(ckt->CKTrhsOld[here->CSWposNode]
|
||||
- ckt->CKTrhsOld[here->CSWnegNode]) *
|
||||
value->rValue =
|
||||
(ckt->CKTrhsOld[here->CSWposNode] -
|
||||
ckt->CKTrhsOld[here->CSWnegNode]) *
|
||||
(ckt->CKTrhsOld[here->CSWposNode] -
|
||||
ckt->CKTrhsOld[here->CSWnegNode]) *
|
||||
here->CSWcond;
|
||||
}
|
||||
return OK;
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt)
|
|||
for( ; model; model = CSWnextModel(model))
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = CSWinstances(model); here;
|
||||
here=CSWnextInstance(here)) {
|
||||
for (here = CSWinstances(model); here; here=CSWnextInstance(here)) {
|
||||
|
||||
old_current_state = ckt->CKTstates[0][here->CSWstate + 0];
|
||||
previous_state = ckt->CKTstates[1][here->CSWstate + 0];
|
||||
|
|
|
|||
|
|
@ -33,8 +33,7 @@ CSWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
|||
for( ; model; model = CSWnextModel(model))
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = CSWinstances(model); here;
|
||||
here=CSWnextInstance(here)) {
|
||||
for (here = CSWinstances(model); here; here=CSWnextInstance(here)) {
|
||||
|
||||
current_state = (int) ckt->CKTstates[0][here->CSWstate + 0];
|
||||
|
||||
|
|
|
|||
|
|
@ -45,8 +45,7 @@ CSWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
|||
}
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = CSWinstances(model); here;
|
||||
here=CSWnextInstance(here)) {
|
||||
for (here = CSWinstances(model); here; here=CSWnextInstance(here)) {
|
||||
|
||||
/* Default Value Processing for Switch Instance */
|
||||
here->CSWstate = *states;
|
||||
|
|
|
|||
|
|
@ -22,25 +22,29 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
|||
double lastChange, maxChange, maxStep, ref;
|
||||
|
||||
for( ; model; model = CSWnextModel(model))
|
||||
for(here = CSWinstances(model); here;
|
||||
here = CSWnextInstance(here)) {
|
||||
lastChange = ckt->CKTstates[0][here->CSWstate + 1] -
|
||||
for(here = CSWinstances(model); here; here = CSWnextInstance(here)) {
|
||||
lastChange =
|
||||
ckt->CKTstates[0][here->CSWstate + 1] -
|
||||
ckt->CKTstates[1][here->CSWstate + 1];
|
||||
if (ckt->CKTstates[0][here->CSWstate + 0]==0) {
|
||||
ref = model->CSWiThreshold + model->CSWiHysteresis;
|
||||
if (ckt->CKTstates[0][here->CSWstate + 1]<ref && lastChange>0) {
|
||||
maxChange = (ref - ckt->CKTstates[0][here->CSWstate + 1]) *
|
||||
0.75 + 0.00005;
|
||||
maxChange =
|
||||
(ref - ckt->CKTstates[0][here->CSWstate + 1]) * 0.75
|
||||
+ 0.00005;
|
||||
maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0];
|
||||
if (*timeStep > maxStep) *timeStep = maxStep;
|
||||
if (*timeStep > maxStep)
|
||||
*timeStep = maxStep;
|
||||
}
|
||||
} else {
|
||||
ref = model->CSWiThreshold - model->CSWiHysteresis;
|
||||
if (ckt->CKTstates[0][here->CSWstate + 1]>ref && lastChange<0) {
|
||||
maxChange = (ref - ckt->CKTstates[0][here->CSWstate + 1]) *
|
||||
0.75 - 0.00005;
|
||||
maxChange =
|
||||
(ref - ckt->CKTstates[0][here->CSWstate + 1]) * 0.75
|
||||
- 0.00005;
|
||||
maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0];
|
||||
if (*timeStep > maxStep) *timeStep = maxStep;
|
||||
if (*timeStep > maxStep)
|
||||
*timeStep = maxStep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ SWacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
|||
for( ; model; model = SWnextModel(model))
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = SWinstances(model); here;
|
||||
here=SWnextInstance(here)) {
|
||||
for (here = SWinstances(model); here; here=SWnextInstance(here)) {
|
||||
|
||||
/* In AC analysis, just propogate the state... */
|
||||
|
||||
|
|
|
|||
|
|
@ -48,8 +48,9 @@ SWask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *se
|
|||
strcpy(errMsg,msg);
|
||||
return E_ASKCURRENT;
|
||||
} else {
|
||||
value->rValue = (ckt->CKTrhsOld[here->SWposNode]
|
||||
- ckt->CKTrhsOld[here->SWnegNode]) *
|
||||
value->rValue =
|
||||
(ckt->CKTrhsOld[here->SWposNode] -
|
||||
ckt->CKTrhsOld[here->SWnegNode]) *
|
||||
here->SWcond;
|
||||
}
|
||||
return OK;
|
||||
|
|
@ -60,10 +61,11 @@ SWask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *se
|
|||
strcpy(errMsg,msg);
|
||||
return E_ASKPOWER;
|
||||
} else {
|
||||
value->rValue = (ckt->CKTrhsOld[here->SWposNode]
|
||||
- ckt->CKTrhsOld[here->SWnegNode]) *
|
||||
(ckt->CKTrhsOld[here->SWposNode]
|
||||
- ckt->CKTrhsOld[here->SWnegNode]) *
|
||||
value->rValue =
|
||||
(ckt->CKTrhsOld[here->SWposNode] -
|
||||
ckt->CKTrhsOld[here->SWnegNode]) *
|
||||
(ckt->CKTrhsOld[here->SWposNode] -
|
||||
ckt->CKTrhsOld[here->SWnegNode]) *
|
||||
here->SWcond;
|
||||
}
|
||||
return OK;
|
||||
|
|
|
|||
|
|
@ -34,14 +34,14 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
|
|||
for( ; model; model = SWnextModel(model))
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = SWinstances(model); here;
|
||||
here=SWnextInstance(here)) {
|
||||
for (here = SWinstances(model); here; here=SWnextInstance(here)) {
|
||||
|
||||
old_current_state = ckt->CKTstates[0][here->SWstate + 0];
|
||||
previous_state = ckt->CKTstates[1][here->SWstate + 0];
|
||||
|
||||
v_ctrl = ckt->CKTrhsOld[here->SWposCntrlNode]
|
||||
- ckt->CKTrhsOld[here->SWnegCntrlNode];
|
||||
v_ctrl =
|
||||
ckt->CKTrhsOld[here->SWposCntrlNode] -
|
||||
ckt->CKTrhsOld[here->SWnegCntrlNode];
|
||||
|
||||
/* decide the state of the switch */
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,7 @@ SWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
|||
for( ; model; model = SWnextModel(model))
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = SWinstances(model); here;
|
||||
here=SWnextInstance(here)) {
|
||||
for (here = SWinstances(model); here; here=SWnextInstance(here)) {
|
||||
|
||||
/* In AC analysis, just propogate the state... */
|
||||
|
||||
|
|
|
|||
|
|
@ -45,8 +45,7 @@ SWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
|||
}
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = SWinstances(model); here;
|
||||
here=SWnextInstance(here)) {
|
||||
for (here = SWinstances(model); here; here=SWnextInstance(here)) {
|
||||
|
||||
here->SWstate = *states;
|
||||
*states += SW_NUM_STATES;
|
||||
|
|
|
|||
|
|
@ -20,25 +20,29 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
|||
double lastChange, maxChange, maxStep, ref;
|
||||
|
||||
for( ; model; model = SWnextModel(model))
|
||||
for(here = SWinstances(model); here;
|
||||
here = SWnextInstance(here)) {
|
||||
lastChange = ckt->CKTstates[0][here->SWstate + 1] -
|
||||
for(here = SWinstances(model); here; here = SWnextInstance(here)) {
|
||||
lastChange =
|
||||
ckt->CKTstates[0][here->SWstate + 1] -
|
||||
ckt->CKTstates[1][here->SWstate + 1];
|
||||
if (ckt->CKTstates[0][here->SWstate + 0]==0) {
|
||||
ref = model->SWvThreshold + model->SWvHysteresis;
|
||||
if (ckt->CKTstates[0][here->SWstate + 1]<ref && lastChange>0) {
|
||||
maxChange = (ref - ckt->CKTstates[0][here->SWstate + 1]) *
|
||||
0.75 + 0.05;
|
||||
maxChange =
|
||||
(ref - ckt->CKTstates[0][here->SWstate + 1]) * 0.75
|
||||
+ 0.05;
|
||||
maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0];
|
||||
if (*timeStep > maxStep) *timeStep = maxStep;
|
||||
if (*timeStep > maxStep)
|
||||
*timeStep = maxStep;
|
||||
}
|
||||
} else {
|
||||
ref = model->SWvThreshold - model->SWvHysteresis;
|
||||
if (ckt->CKTstates[0][here->SWstate + 1]>ref && lastChange<0) {
|
||||
maxChange = (ref - ckt->CKTstates[0][here->SWstate + 1]) *
|
||||
0.75 - 0.05;
|
||||
maxChange =
|
||||
(ref - ckt->CKTstates[0][here->SWstate + 1]) * 0.75
|
||||
- 0.05;
|
||||
maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0];
|
||||
if (*timeStep > maxStep) *timeStep = maxStep;
|
||||
if (*timeStep > maxStep)
|
||||
*timeStep = maxStep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue