fix truncation to work successfully with trunc-1.cir testcase
testcase trunc-1.cir working now pretty much perfectly testcase davis-130420.cir works very precise as well number of timesteps going up from 374 to 1296 voltage error 20mV going down to 2 uV currently ckt->CKTdelmin = 1e-11*ckt->CKTmaxStep; is hardwired in traninit.c might make sense making it possible to steer that
This commit is contained in:
parent
d870c02ff6
commit
1e602edfb6
|
|
@ -25,11 +25,10 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
||||||
ckt->CKTstate1[here->SWctrlvalue];
|
ckt->CKTstate1[here->SWctrlvalue];
|
||||||
if (ckt->CKTstate0[here->SWswitchstate] < 0) {
|
if (ckt->CKTstate0[here->SWswitchstate] < 0) {
|
||||||
ref = (model->SWvThreshold + model->SWvHysteresis);
|
ref = (model->SWvThreshold + model->SWvHysteresis);
|
||||||
if (ckt->CKTstate0[here->SWctrlvalue] < ref && lastChange > 1e-3)
|
if (ckt->CKTstate0[here->SWctrlvalue] < ref && lastChange > 0)
|
||||||
{
|
{
|
||||||
maxChange =
|
maxChange =
|
||||||
(ref - ckt->CKTstate0[here->SWctrlvalue]) * 0.75
|
(ref - ckt->CKTstate0[here->SWctrlvalue]) * 0.75;
|
||||||
+ 0.05;
|
|
||||||
maxStep = maxChange / lastChange * ckt->CKTdeltaOld[0];
|
maxStep = maxChange / lastChange * ckt->CKTdeltaOld[0];
|
||||||
if (maxStep < ckt->CKTdelmin)
|
if (maxStep < ckt->CKTdelmin)
|
||||||
maxStep = ckt->CKTdelmin;
|
maxStep = ckt->CKTdelmin;
|
||||||
|
|
@ -38,11 +37,10 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ref = model->SWvThreshold - model->SWvHysteresis;
|
ref = model->SWvThreshold - model->SWvHysteresis;
|
||||||
if (ckt->CKTstate0[here->SWctrlvalue] > ref && lastChange < -1e-3)
|
if (ckt->CKTstate0[here->SWctrlvalue] > ref && lastChange < 0)
|
||||||
{
|
{
|
||||||
maxChange =
|
maxChange =
|
||||||
(ref - ckt->CKTstate0[here->SWctrlvalue]) * 0.75
|
(ref - ckt->CKTstate0[here->SWctrlvalue]) * 0.75;
|
||||||
- 0.05;
|
|
||||||
maxStep = maxChange / lastChange * ckt->CKTdeltaOld[0];
|
maxStep = maxChange / lastChange * ckt->CKTdeltaOld[0];
|
||||||
if (maxStep < ckt->CKTdelmin)
|
if (maxStep < ckt->CKTdelmin)
|
||||||
maxStep = ckt->CKTdelmin;
|
maxStep = ckt->CKTdelmin;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue