diff --git a/src/spicelib/devices/csw/cswtrunc.c b/src/spicelib/devices/csw/cswtrunc.c index e7be9559f..972dd9c81 100644 --- a/src/spicelib/devices/csw/cswtrunc.c +++ b/src/spicelib/devices/csw/cswtrunc.c @@ -26,7 +26,7 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) ckt->CKTstate0[here->CSWctrlvalue] - ckt->CKTstate1[here->CSWctrlvalue]; if (ckt->CKTstate0[here->CSWswitchstate] == 0) { - ref = model->CSWiThreshold + model->CSWiHysteresis; + ref = model->CSWiThreshold + fabs(model->CSWiHysteresis); if (ckt->CKTstate0[here->CSWctrlvalue] < ref && lastChange > 0) { maxChange = (ref - ckt->CKTstate0[here->CSWctrlvalue]) * 0.75 @@ -36,7 +36,7 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) *timeStep = maxStep; } } else { - ref = model->CSWiThreshold - model->CSWiHysteresis; + ref = model->CSWiThreshold - fabs(model->CSWiHysteresis); if (ckt->CKTstate0[here->CSWctrlvalue] > ref && lastChange < 0) { maxChange = (ref - ckt->CKTstate0[here->CSWctrlvalue]) * 0.75 diff --git a/src/spicelib/devices/sw/swtrunc.c b/src/spicelib/devices/sw/swtrunc.c index 81866e285..d179f0e4c 100644 --- a/src/spicelib/devices/sw/swtrunc.c +++ b/src/spicelib/devices/sw/swtrunc.c @@ -24,7 +24,7 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) ckt->CKTstate0[here->SWctrlvalue] - ckt->CKTstate1[here->SWctrlvalue]; if (ckt->CKTstate0[here->SWswitchstate] == 0) { - ref = model->SWvThreshold + model->SWvHysteresis; + ref = model->SWvThreshold + fabs(model->SWvHysteresis); if (ckt->CKTstate0[here->SWctrlvalue] < ref && lastChange > 0) { maxChange = (ref - ckt->CKTstate0[here->SWctrlvalue]) * 0.75 @@ -34,7 +34,7 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) *timeStep = maxStep; } } else { - ref = model->SWvThreshold - model->SWvHysteresis; + ref = model->SWvThreshold - fabs(model->SWvHysteresis); if (ckt->CKTstate0[here->SWctrlvalue] > ref && lastChange < 0) { maxChange = (ref - ckt->CKTstate0[here->SWctrlvalue]) * 0.75