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:
rlar 2018-02-25 12:02:07 +01:00
parent d870c02ff6
commit 1e602edfb6
1 changed files with 4 additions and 6 deletions

View File

@ -25,11 +25,10 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
ckt->CKTstate1[here->SWctrlvalue];
if (ckt->CKTstate0[here->SWswitchstate] < 0) {
ref = (model->SWvThreshold + model->SWvHysteresis);
if (ckt->CKTstate0[here->SWctrlvalue] < ref && lastChange > 1e-3)
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;
@ -38,11 +37,10 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
}
} else {
ref = model->SWvThreshold - model->SWvHysteresis;
if (ckt->CKTstate0[here->SWctrlvalue] > ref && lastChange < -1e-3)
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;