Add NEWTRUNC-specific ltetrtol option

This commit is contained in:
Vogt 2025-11-06 11:31:41 +01:00
parent 8a5cacda6f
commit 5951c695c9
8 changed files with 22 additions and 4 deletions

View File

@ -82,6 +82,7 @@ com_option(wordlist *wl)
#ifdef NEWTRUNC
printf("ltereltol = %g\n", circuit->CKTlteReltol);
printf("lteabstol = %g\n", circuit->CKTlteAbstol);
printf("ltetrtol = %g\n", circuit->CKTlteTrtol);
#endif /* NEWTRUNC */
printf("\nConductances:\n");

View File

@ -221,6 +221,7 @@ struct CKTcircuit {
#ifdef NEWTRUNC
double CKTlteReltol;
double CKTlteAbstol;
double CKTlteTrtol;
#endif /* NEWTRUNC */
double CKTgmin; /* .options GMIN */
double CKTgshunt; /* .options RSHUNT */

View File

@ -132,6 +132,12 @@ enum {
OPT_KLU_MEMGROW_FACTOR,
#endif
#ifdef NEWTRUNC
OPT_LTERELTOL,
OPT_LTEABSTOL,
OPT_LTETRTOL,
#endif
};
#ifdef XSPICE

View File

@ -51,6 +51,7 @@ struct TSKtask {
#ifdef NEWTRUNC
double TSKlteReltol;
double TSKlteAbstol;
double TSKlteTrtol;
#endif /* NEWTRUNC */
double TSKgmin;
double TSKgshunt; /* shunt conductance (CKTdiagGmin) */

View File

@ -117,6 +117,7 @@ CKTdoJob(CKTcircuit* ckt, int reset, TSKtask* task)
#ifdef NEWTRUNC
ckt->CKTlteReltol = task->TSKlteReltol;
ckt->CKTlteAbstol = task->TSKlteAbstol;
ckt->CKTlteTrtol = task->TSKlteTrtol;
#endif /* NEWTRUNC */
fprintf(stdout, "Doing analysis at TEMP = %f and TNOM = %f\n\n",

View File

@ -85,6 +85,7 @@ CKTnewTask(CKTcircuit *ckt, TSKtask **taskPtr, IFuid taskName, TSKtask **defPtr)
#ifdef NEWTRUNC
tsk->TSKlteReltol = def->TSKlteReltol;
tsk->TSKlteAbstol = def->TSKlteAbstol;
tsk->TSKlteTrtol = def->TSKlteTrtol;
#endif
} else {
@ -101,6 +102,7 @@ CKTnewTask(CKTcircuit *ckt, TSKtask **taskPtr, IFuid taskName, TSKtask **defPtr)
#ifdef NEWTRUNC
tsk->TSKlteReltol = 1e-3;
tsk->TSKlteAbstol = 1e-6;
tsk->TSKlteTrtol = 7;
#endif
tsk->TSKtrtol = 7;
tsk->TSKbypass = 0;

View File

@ -353,7 +353,13 @@ static IFparm OPTtbl[] = {
{ "klu", OPT_KLU, IF_SET|IF_FLAG,
"Set KLU as Direct Linear Solver" },
{ "klu_memgrow_factor", OPT_KLU_MEMGROW_FACTOR, IF_SET|IF_REAL,
"KLU Memory Grow Factor (default is 1.2)" }
"KLU Memory Grow Factor (default is 1.2)" },
#endif
#ifdef NEWTRUNC
{ "ltereltol", OPT_RELTOL,IF_SET | IF_REAL ,"Relative error tolerence" },
{ "lteabstol", OPT_ABSTOL,IF_SET | IF_REAL,"Absolute error tolerence" },
{ "ltetrtol", OPT_TRTOL,IF_SET | IF_REAL,"Truncation error overestimation factor" }
#endif
};

View File

@ -92,7 +92,7 @@ CKTtrunc(CKTcircuit *ckt, double *timeStep)
#endif
if(diff != 0) {
// if (!AlmostEqualUlps(diff, 0, 10)) {
tmp = ckt->CKTtrtol * tol * 2 /diff;
tmp = ckt->CKTlteTrtol * tol * 2 /diff;
tmp = ckt->CKTdeltaOld[0]*sqrt(fabs(tmp));
timetemp = MIN(timetemp,tmp);
#ifdef STEPDEBUG
@ -118,7 +118,7 @@ CKTtrunc(CKTcircuit *ckt, double *timeStep)
#endif
if(diff != 0) {
// if(!AlmostEqualUlps(diff, 0, 10)) {
tmp = tol * ckt->CKTtrtol * (ckt->CKTdeltaOld[0] + ckt->CKTdeltaOld[1])
tmp = tol * ckt->CKTlteTrtol * (ckt->CKTdeltaOld[0] + ckt->CKTdeltaOld[1])
/ (diff * ckt->CKTdelta);
tmp = fabs(tmp);
tmp = exp(log(tmp) / 3);
@ -160,7 +160,7 @@ CKTtrunc(CKTcircuit *ckt, double *timeStep)
ckt->CKTpred[i]);
#endif
if(diff != 0) {
tmp = tol*ckt->CKTtrtol*delsum/(diff*ckt->CKTdelta);
tmp = tol*ckt->CKTlteTrtol*delsum/(diff*ckt->CKTdelta);
tmp = fabs(tmp);
switch(ckt->CKTorder) {
case 0: