Don't check continuously for autostop, only when option flag is set

This speeds up simulations with simple device evaluation, but many
time stepps.
This commit is contained in:
Holger Vogt 2023-09-09 18:37:13 +02:00
parent d6418117b6
commit ad23146544
2 changed files with 17 additions and 3 deletions

View File

@ -532,7 +532,7 @@ check_autostop(char* what)
{
bool flag = FALSE;
if (cp_getvar("autostop", CP_BOOL, NULL, 0))
// if (cp_getvar("autostop", CP_BOOL, NULL, 0))
flag = do_measure(what, TRUE);
return flag;

View File

@ -94,6 +94,8 @@ DCtran(CKTcircuit *ckt,
int numNames;
double maxstepsize = 0.0;
bool have_autostop = FALSE, flag_autostop = FALSE;
int ltra_num;
CKTnode *node;
#ifdef XSPICE
@ -184,6 +186,8 @@ DCtran(CKTcircuit *ckt,
save_mode = (ckt->CKTmode&MODEUIC) | MODETRANOP | MODEINITJCT;
save_order = ckt->CKTorder;
have_autostop = cp_getvar("autostop", CP_BOOL, NULL, 0);
/* Add breakpoints here which have been requested by the user setting the
stop command as 'stop when time = xx'.
Get data from the global dbs data base.
@ -466,8 +470,14 @@ DCtran(CKTcircuit *ckt,
/* gtri - end - wbk - Update event queues/data for accepted timepoint */
#endif
ckt->CKTstat->STAToldIter = ckt->CKTstat->STATnumIter;
if (check_autostop("tran") ||
ckt->CKTfinalTime - ckt->CKTtime < ckt->CKTminBreak) {
/* check for the end of the tran simulation, either by< stop time given,
or final time has been reached. */
if (have_autostop)
/* time consuming autostop check only, when variable 'autostop' has been set
before tran is started.*/
flag_autostop = check_autostop("tran");
/* If CKTtime and CKTfinalTime are almost equal, then finish */
if (flag_autostop || AlmostEqualUlps(ckt->CKTtime, ckt->CKTfinalTime, 100)) {
#ifdef STEPDEBUG
printf(" done: time is %g, final time is %g, and tol is %g\n",
ckt->CKTtime, ckt->CKTfinalTime, ckt->CKTminBreak);
@ -480,6 +490,10 @@ DCtran(CKTcircuit *ckt,
ckt->CKTsenInfo->SENmode = save;
}
#endif
if (flag_autostop)
fprintf(stdout, "\nNote: Autostop after %e s, all measurement conditions are fulfilled\n", ckt->CKTtime);
/* Final return from tran*/
return(OK);
}
if(SPfrontEnd->IFpauseTest()) {