diff --git a/src/spicelib/devices/csw/cswtrunc.c b/src/spicelib/devices/csw/cswtrunc.c index 97418246a..7662b12a3 100644 --- a/src/spicelib/devices/csw/cswtrunc.c +++ b/src/spicelib/devices/csw/cswtrunc.c @@ -27,9 +27,10 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) ref = model->CSWiThreshold + fabs(model->CSWiHysteresis); if (ckt->CKTstate0[here->CSWctrlvalue] < ref && lastChange > 0) { maxChange = - (ref - ckt->CKTstate0[here->CSWctrlvalue]) * 0.75 - + 0.00005; + (ref - ckt->CKTstate0[here->CSWctrlvalue]) * 0.75; maxStep = maxChange / lastChange * ckt->CKTdeltaOld[0]; + if (maxStep < ckt->CKTdelmin) + maxStep = ckt->CKTdelmin; if (*timeStep > maxStep) *timeStep = maxStep; } @@ -37,9 +38,10 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) ref = model->CSWiThreshold - fabs(model->CSWiHysteresis); if (ckt->CKTstate0[here->CSWctrlvalue] > ref && lastChange < 0) { maxChange = - (ref - ckt->CKTstate0[here->CSWctrlvalue]) * 0.75 - - 0.00005; + (ref - ckt->CKTstate0[here->CSWctrlvalue]) * 0.75; maxStep = maxChange / lastChange * ckt->CKTdeltaOld[0]; + if (maxStep < ckt->CKTdelmin) + maxStep = ckt->CKTdelmin; if (*timeStep > maxStep) *timeStep = maxStep; } diff --git a/src/spicelib/devices/sw/swtrunc.c b/src/spicelib/devices/sw/swtrunc.c index 9be098f5c..ef3165322 100644 --- a/src/spicelib/devices/sw/swtrunc.c +++ b/src/spicelib/devices/sw/swtrunc.c @@ -27,9 +27,10 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) ref = model->SWvThreshold + fabs(model->SWvHysteresis); if (ckt->CKTstate0[here->SWctrlvalue] < ref && lastChange > 0) { maxChange = - (ref - ckt->CKTstate0[here->SWctrlvalue]) * 0.75 - + 0.05; + (ref - ckt->CKTstate0[here->SWctrlvalue]) * 0.75; maxStep = maxChange / lastChange * ckt->CKTdeltaOld[0]; + if (maxStep < ckt->CKTdelmin) + maxStep = ckt->CKTdelmin; if (*timeStep > maxStep) *timeStep = maxStep; } @@ -37,9 +38,10 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) ref = model->SWvThreshold - fabs(model->SWvHysteresis); if (ckt->CKTstate0[here->SWctrlvalue] > ref && lastChange < 0) { maxChange = - (ref - ckt->CKTstate0[here->SWctrlvalue]) * 0.75 - - 0.05; + (ref - ckt->CKTstate0[here->SWctrlvalue]) * 0.75; maxStep = maxChange / lastChange * ckt->CKTdeltaOld[0]; + if (maxStep < ckt->CKTdelmin) + maxStep = ckt->CKTdelmin; if (*timeStep > maxStep) *timeStep = maxStep; }