From 5bb08ea5c8dc3190110b13059ce1ca7c9dc808cb Mon Sep 17 00:00:00 2001 From: rlar Date: Sat, 10 Mar 2018 10:56:34 +0100 Subject: [PATCH] spicelib/devices/{sw,csw}, #2/, bug fix, negative hysteresis fix an aspect of commit: > commit 0dae4607a01e2bbf93a925f5c37385ad9ce232f2 > Date: Wed Apr 25 18:28:20 2001 +0000 > > Added a patch to csw and sw from Jon Engelbert dealing with negative histeresys which allowed negative hysteresis, but didn't fix the usage of hysteresis in the trunc.c files accordingly. --- src/spicelib/devices/csw/cswtrunc.c | 4 ++-- src/spicelib/devices/sw/swtrunc.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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