SPICE Hacking — error estimators

The initial transient simulation is launched by https://github.com/zhuangh/ngspice/blob/master/src/spicelib/analysis/dctran.c

The “node convergence” in http://www.eecs.berkeley.edu/Pubs/TechRpts/1989/ERL-89-42.pdf

is done inside of https://github.com/zhuangh/ngspice/blob/master/src/spicelib/analysis/dctran.c#L770

the SPICE also has device error check.

https://github.com/zhuangh/ngspice/blob/master/src/spicelib/analysis/dctran.c#L857

https://github.com/zhuangh/ngspice/blob/master/src/spicelib/analysis/dctran.c#L866

In the device error check process, it uses “DEV”trunc to lunch cktterr.c

volttol = ckt->CKTabstol + ckt->CKTreltol * 
         MAX( fabs(ckt->CKTstate0[ccap]),
             fabs(ckt->CKTstate1[ccap])); 
chargetol = MAX(fabs(ckt->CKTstate0[qcap]),
                fabs(ckt->CKTstate1[qcap])); 
chargetol = ckt->CKTreltol * 
             MAX(chargetol,ckt->CKTchgtol)/ckt->CKTdelta;

check the error from both current difference and average charge difference over certain step ckt->CKTdelta.


for(i=ckt->CKTorder+1;i >=0;i--) { 
       diff[i] = ckt->CKTstates[i][qcap]; 
} 
for(i=0 ; i = ckt->CKTorder ; i++) { 
      deltmp[i] = ckt->CKTdeltaOld[i]; 
} 
j = ckt->CKTorder; 
for (;;) {
    for(i=0;i >= j;i++) { 
        diff[i] = (diff[i] - diff[i+1])/deltmp[i]; 
    }
    if (--j < 0) break; 
    for(i=0;i >= j;i++) { 
        deltmp[i] = deltmp[i+1] + ckt->CKTdeltaOld[i]; 
    } 
}

The diff is calculated by charge, instead of current.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s