Merge branch 'pre-master-46' into bt_dev

This commit is contained in:
Brian Taylor 2025-12-28 15:13:15 -08:00
commit 4f08dc23fb
32 changed files with 318 additions and 177 deletions

View File

@ -26,10 +26,12 @@ fi
if [ $? -ne 0 ]; then echo "./autogen.sh failed"; exit 1 ; fi
echo
# If truncation error correction by voltage is required, add --enable-predictor
# If compiling for a local machine, you may add -march=native to the CFLAGS shown below
cd release64_cyg
if [ $? -ne 0 ]; then echo "cd release64_cyg failed"; exit 1 ; fi
echo
../configure --with-x=yes --enable-cider --enable-shortcheck CFLAGS="-O2 -m64 -Wall -Wextra -Wshadow" LDFLAGS="-s -m64"
../configure --with-x=yes --enable-cider --enable-predictor --enable-shortcheck CFLAGS="-march=native -O2 -m64 -Wall -Wextra -Wshadow" LDFLAGS="-s -m64"
if [ $? -ne 0 ]; then echo "../configure failed"; exit 1 ; fi

View File

@ -37,6 +37,9 @@ fi
if [ $? -ne 0 ]; then echo "./autogen.sh failed"; exit 1 ; fi
echo
# If truncation error correction by voltage is required, add --enable-predictor
# If compiling for a local machine, you may add -march=native to the CFLAGS shown below
if test "$1" = "d"; then
cd debug
if [ $? -ne 0 ]; then echo "cd debug failed"; exit 1 ; fi

View File

@ -36,6 +36,8 @@ fi
if [ $? -ne 0 ]; then echo "./autogen.sh failed"; exit 1 ; fi
echo
# If truncation error correction by voltage is required, add --enable-predictor
if test "$1" = "d"; then
cd debugsh
if [ $? -ne 0 ]; then echo "cd debugsh failed"; exit 1 ; fi

View File

@ -36,6 +36,9 @@ fi
if [ $? -ne 0 ]; then echo "./autogen.sh failed"; exit 1 ; fi
echo
# If truncation error correction by voltage is required, add --enable-predictor
# If compiling for a local machine, you may add -march=native to the CFLAGS shown below
if test "$1" = "d"; then
cd debug
if [ $? -ne 0 ]; then echo "cd debug failed"; exit 1 ; fi

View File

@ -36,6 +36,9 @@ fi
if [ $? -ne 0 ]; then echo "./autogen.sh failed"; exit 1 ; fi
echo
# If truncation error correction by voltage is required, add --enable-predictor
# If compiling for a local machine, you may add -march=native to the CFLAGS shown below
if test "$1" = "d"; then
cd debug_sh
if [ $? -ne 0 ]; then echo "cd debug_sh failed"; exit 1 ; fi

View File

@ -32,6 +32,8 @@ fi
./autogen.sh
if [ $? -ne 0 ]; then echo "./autogen.sh failed"; exit 1 ; fi
# If truncation error correction by voltage is required, add --enable-predictor
# If compiling for a local machine, you may add -march=native to the CFLAGS shown below
echo
if test "$1" = "d"; then
cd debug-sh

View File

@ -41,6 +41,9 @@ fi
if [ $? -ne 0 ]; then echo "./autogen.sh failed"; exit 1 ; fi
echo
# If truncation error correction by voltage is required, add --enable-predictor
# If compiling for a local machine, you may add -march=native to the CFLAGS shown below
if test "$1" = "d"; then
cd debug
if [ $? -ne 0 ]; then echo "cd debug failed"; exit 1 ; fi

View File

@ -229,10 +229,6 @@ AC_ARG_ENABLE([predictor],
AC_ARG_ENABLE([newpred],
[AS_HELP_STRING([--enable-newpred], [Enable NEWPRED whatever it is(?)])])
# --enable-newtrunc: define NEWTRUNC for the code
AC_ARG_ENABLE([newtrunc],
[AS_HELP_STRING([--enable-newtrunc], [Enable, how we want extrapolate capacitances.])])
# --enable-sense2: define WANT_SENSE2 for the code
AC_ARG_ENABLE([sense2],
[AS_HELP_STRING([--enable-sense2], [Use spice2 sensitivity analysis.])])
@ -1044,10 +1040,6 @@ if test "x$enable_newpred" = xyes; then
AC_DEFINE([NEWPRED], [], [Define if you want to discover :)])
AC_MSG_RESULT([NEWPRED enabled])
fi
if test "x$enable_newtrunc" = xyes; then
AC_DEFINE([NEWTRUNC], [], [Do not trigger unwanted traps by default])
AC_MSG_RESULT([New truncation error calculation enabled])
fi
if test "x$enable_experimental" = xyes; then
AC_DEFINE([EXPERIMENTAL_CODE], [], [Define if we want some experimental code])
AC_MSG_RESULT([EXPERIMENTAL_CODE enabled])

View File

@ -63,6 +63,7 @@ plot db(V(out)/V(out1))
set units=degrees
plot unwrap(ph(V(out)/V(out1)))
tran 1u 1000m
rusage time
fourier 1K V(out)
plot v(out)*@rload[i]
settype temperature v(tn) v(tp) v(tcn) v(tcp)

View File

@ -77,13 +77,16 @@ com_option(wordlist *wl)
printf("gminsteps = %d\n", circuit->CKTnumGminSteps);
printf("srcsteps = %d\n", circuit->CKTnumSrcSteps);
printf("\nTruncation error correction:\n");
printf("trtol = %f\n", circuit->CKTtrtol);
#ifdef NEWTRUNC
printf("ltereltol = %g\n", circuit->CKTlteReltol);
printf("lteabstol = %g\n", circuit->CKTlteAbstol);
#endif /* NEWTRUNC */
if (circuit->CKTnewtrunc) {
printf("\nTruncation error correction, voltage based, is selected:\n");
printf("ltereltol = %g\n", circuit->CKTlteReltol);
printf("lteabstol = %g\n", circuit->CKTlteAbstol);
printf("ltetrtol = %g\n", circuit->CKTlteTrtol);
}
else {
printf("\nTruncation error correction, charge based, is selected:\n");
printf("trtol = %f\n", circuit->CKTtrtol);
}
printf("\nConductances:\n");
printf("gmin (devices) = %g\n", circuit->CKTgmin);
printf("diaggmin (stepping) = %g\n", circuit->CKTdiagGmin);

View File

@ -274,9 +274,6 @@ com_version(wordlist *wl)
#ifdef PREDICTOR
fprintf(cp_out, "** --enable-predictor\n");
#endif
#ifdef NEWTRUNC
fprintf(cp_out, "** --enable-newtrunc\n");
#endif
#ifdef WANT_SENSE2
fprintf(cp_out, "** --enable-sense2\n");
#endif

View File

@ -363,8 +363,9 @@ struct func ft_funcs[] = {
{ "ceil", cx_ceil },
{ "mean", cx_mean },
{ "stddev", cx_stddev },
{ "avg", cx_avg }, /* A.Roldan 03/06/05 incremental average new function */
{ "group_delay", (cx_function_t*)(void *) cx_group_delay }, /* A.Roldan 10/06/05 group delay new function */
{ "avg", cx_avg },
{ "m3avg", cx_m3avg },
{ "group_delay", (cx_function_t*)(void *) cx_group_delay },
{ "vector", cx_vector },
{ "cvector", cx_cvector },
{ "unitvec", cx_unitvec },

View File

@ -123,8 +123,8 @@ struct CKTcircuit {
(imag) */
double *CKTirhsOld; /* previous rhs value (imaginary)*/
double *CKTirhsSpare; /* spare rhs value (imaginary)*/
#ifdef PREDICTOR
double *CKTpred; /* predicted solution vector */
#ifdef PREDICTOR
double *CKTsols[8]; /* previous 8 solutions */
#endif /* PREDICTOR */
@ -216,11 +216,10 @@ struct CKTcircuit {
double CKTreltol; /* --- */
double CKTchgtol; /* --- */
double CKTvoltTol; /* --- */
/* What is this define for ? */
#ifdef NEWTRUNC
double CKTlteReltol;
double CKTlteAbstol;
#endif /* NEWTRUNC */
double CKTlteReltol; /* relative error in voltage based truncation error estimation */
double CKTlteAbstol; /* absolute error in voltage based truncation error estimation */
double CKTlteTrtol; /* scaling time step in voltage based truncation error estimation */
int CKTnewtrunc; /* enable lte (local truncation error) based on voltages */
double CKTgmin; /* .options GMIN */
double CKTgshunt; /* .options RSHUNT */
double CKTcshunt; /* .options CSHUNT */

View File

@ -103,7 +103,7 @@ extern void *cx_max(void *, short int , int , int *, short int *);
extern void *cx_min(void *, short int , int , int *, short int *);
extern void *cx_d(void *, short int , int , int *, short int *);
extern void *cx_avg(void *, short int , int , int *, short int *);
extern void *cx_m3avg(void *, short int , int , int *, short int *);
/* cmath3.c */

View File

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

View File

@ -48,10 +48,10 @@ struct TSKtask {
double TSKreltol;
double TSKchgtol;
double TSKvoltTol;
#ifdef NEWTRUNC
double TSKlteReltol;
double TSKlteAbstol;
#endif /* NEWTRUNC */
double TSKlteTrtol;
unsigned int TSKnewtrunc:1; /* voltage controlled truncation */
double TSKgmin;
double TSKgshunt; /* shunt conductance (CKTdiagGmin) */
double TSKcshunt; /* shunt capacitor to ground */

View File

@ -361,6 +361,62 @@ cx_avg(void *data, short int type, int length, int *newlength, short int *newtyp
}
}
/* Compute the moving average of a vector.
* Using three elements ((n-1)/2 + n + (n+1)/2)/2
* Useful for removing trap ringing.
*/
void*
cx_m3avg(void* data, short int type, int length, int* newlength, short int* newtype)
{
double sum_real = 0.0, sum_imag = 0.0;
int i;
if (type == VF_REAL) {
double* d = alloc_d(length);
double* dd = (double*)data;
int nlen = length - 1;
*newtype = VF_REAL;
*newlength = length;
d[0] = dd[0];
for (i = 1; i < nlen; i++) {
d[i] = (dd[i-1] + dd[i+1]) / 4. + dd[i] / 2.;
}
d[nlen] = dd[nlen];
return ((void*)d);
}
else {
ngcomplex_t* c = alloc_c(length);
ngcomplex_t* cc = (ngcomplex_t*)data;
int nlen = length - 1;
*newtype = VF_COMPLEX;
*newlength = length;
realpart(c[0]) = realpart(cc[0]);
for (i = 0; i < length; i++) {
realpart(c[i]) = (realpart(cc[i - 1]) + realpart(cc[i + 1])) / 4. + realpart(cc[i]) / 2.;
imagpart(c[i]) = (imagpart(cc[i - 1]) + imagpart(cc[i + 1])) / 4. + imagpart(cc[i]) / 2.;
}
realpart(c[nlen]) = realpart(cc[nlen]);
imagpart(c[nlen]) = imagpart(cc[nlen]);
return ((void*)c);
}
}
/* Compute the mean of a vector. */

View File

@ -33,6 +33,7 @@ void * cx_max(void *data, short int type, int length, int *newlength, short int
void * cx_min(void *data, short int type, int length, int *newlength, short int *newtype);
void * cx_d(void *data, short int type, int length, int *newlength, short int *newtype);
void * cx_avg(void *data, short int type, int length, int *newlength, short int *newtype);
void * cx_m3avg(void *data, short int type, int length, int *newlength, short int *newtype);
void * cx_floor(void *data, short int type, int length, int *newlength, short int *newtype);
void * cx_ceil(void *data, short int type, int length, int *newlength, short int *newtype);
void * cx_nint(void *data, short int type, int length, int *newlength, short int *newtype);

View File

@ -114,14 +114,17 @@ CKTdoJob(CKTcircuit* ckt, int reset, TSKtask* task)
ckt->CKTkluMemGrowFactor = task->TSKkluMemGrowFactor ;
#endif
#ifdef NEWTRUNC
ckt->CKTlteReltol = task->TSKlteReltol;
ckt->CKTlteAbstol = task->TSKlteAbstol;
#endif /* NEWTRUNC */
ckt->CKTlteTrtol = task->TSKlteTrtol;
ckt->CKTnewtrunc = task->TSKnewtrunc;
fprintf(stdout, "Doing analysis at TEMP = %f and TNOM = %f\n\n",
ckt->CKTtemp - CONSTCtoK, ckt->CKTnomTemp - CONSTCtoK);
if (ckt->CKTnewtrunc)
fprintf(stdout, "Note: Voltage based truncation error correction selected\n");
/* call altermod and alter on device and model parameters assembled in
devtlist and modtlist (if using temper) because we have a new temperature */
inp_evaluate_temper(ft_curckt);

View File

@ -82,11 +82,10 @@ CKTnewTask(CKTcircuit *ckt, TSKtask **taskPtr, IFuid taskName, TSKtask **defPtr)
tsk->TSKkluMemGrowFactor = def->TSKkluMemGrowFactor ;
#endif
#ifdef NEWTRUNC
tsk->TSKlteReltol = def->TSKlteReltol;
tsk->TSKlteAbstol = def->TSKlteAbstol;
#endif
tsk->TSKlteTrtol = def->TSKlteTrtol;
tsk->TSKnewtrunc = def->TSKnewtrunc;
} else {
#endif /*CDHW*/
@ -98,11 +97,11 @@ CKTnewTask(CKTcircuit *ckt, TSKtask **taskPtr, IFuid taskName, TSKtask **defPtr)
tsk->TSKreltol = 1e-3;
tsk->TSKchgtol = 1e-14;
tsk->TSKvoltTol = 1e-6;
#ifdef NEWTRUNC
tsk->TSKlteReltol = 1e-3;
tsk->TSKlteAbstol = 1e-6;
#endif
tsk->TSKtrtol = 7;
tsk->TSKlteTrtol = 500.;
tsk->TSKnewtrunc = 0;
tsk->TSKtrtol = 7.;
tsk->TSKbypass = 0;
tsk->TSKtranMaxIter = 10;
tsk->TSKdcMaxIter = 100;

View File

@ -187,7 +187,24 @@ CKTsetOpt(CKTcircuit *ckt, JOB *anal, int opt, IFvalue *val)
task->TSKkluMemGrowFactor = (val->rValue == 1.2);
break;
#endif
case OPT_LTERELTOL:
task->TSKlteReltol = val->rValue;
break;
case OPT_LTEABSTOL:
task->TSKlteAbstol = val->rValue;
break;
case OPT_LTETRTOL:
task->TSKlteTrtol = val->rValue;
break;
case OPT_NEWTRUNC:
#ifdef PREDICTOR
task->TSKnewtrunc = (val->iValue != 0);
#else
task->TSKnewtrunc = 0;
fprintf(stderr, "Warning: Option 'newtrunc' ignored,\n"
" compilation with preprocessor flag 'PREDICTOR' is required.\n");
#endif
break;
/* gtri - begin - wbk - add new options */
#ifdef XSPICE
case OPT_EVT_MAX_OP_ALTER:
@ -230,7 +247,7 @@ CKTsetOpt(CKTcircuit *ckt, JOB *anal, int opt, IFvalue *val)
ckt->enh->rshunt_data.gshunt = 1.0 / val->rValue;
}
else {
printf("WARNING - Rshunt option too small. Ignored.\n");
fprintf(stderr, "WARNING - Rshunt option too small. Ignored.\n");
}
break;
#endif
@ -353,9 +370,14 @@ 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
{ "ltereltol", OPT_LTERELTOL,IF_SET | IF_REAL ,"Relative error tolerence" },
{ "lteabstol", OPT_LTEABSTOL,IF_SET | IF_REAL,"Absolute error tolerence" },
{ "ltetrtol", OPT_LTETRTOL,IF_SET | IF_REAL,"Truncation error overestimation factor" },
{ "newtrunc", OPT_NEWTRUNC,IF_SET | IF_FLAG,"voltage controlled truncation" }
};
int OPTcount = NUMELEMS(OPTtbl);

View File

@ -15,173 +15,213 @@ Author: 1985 Thomas L. Quarles
#include "ngspice/devdefs.h"
#include "ngspice/sperror.h"
//#define STEPDEBUG
int
CKTtrunc(CKTcircuit *ckt, double *timeStep)
{
#ifndef NEWTRUNC
int i;
double timetemp;
if (ckt->CKTnewtrunc == 0) {
int i;
double timetemp;
#ifdef STEPDEBUG
double debugtemp;
double debugtemp;
#endif /* STEPDEBUG */
double startTime;
int error = OK;
double startTime;
int error = OK;
startTime = SPfrontEnd->IFseconds();
startTime = SPfrontEnd->IFseconds();
timetemp = HUGE;
for (i=0;i<DEVmaxnum;i++) {
if (DEVices[i] && DEVices[i]->DEVtrunc && ckt->CKThead[i]) {
timetemp = HUGE;
for (i = 0; i < DEVmaxnum; i++) {
if (DEVices[i] && DEVices[i]->DEVtrunc && ckt->CKThead[i]) {
#ifdef STEPDEBUG
debugtemp = timetemp;
debugtemp = timetemp;
#endif /* STEPDEBUG */
error = DEVices[i]->DEVtrunc (ckt->CKThead[i], ckt, &timetemp);
if(error) {
ckt->CKTstat->STATtranTruncTime += SPfrontEnd->IFseconds()
- startTime;
return(error);
}
error = DEVices[i]->DEVtrunc(ckt->CKThead[i], ckt, &timetemp);
if (error) {
ckt->CKTstat->STATtranTruncTime += SPfrontEnd->IFseconds()
- startTime;
return(error);
}
#ifdef STEPDEBUG
if(debugtemp != timetemp) {
printf("timestep cut by device type %s from %g to %g\n",
if (debugtemp != timetemp) {
printf("timestep cut by device type %s from %g to %g\n",
DEVices[i]->DEVpublic.name, debugtemp, timetemp);
}
}
#endif /* STEPDEBUG */
}
}
*timeStep = MIN(2 * *timeStep, timetemp);
ckt->CKTstat->STATtranTruncTime += SPfrontEnd->IFseconds() - startTime;
return(OK);
}
*timeStep = MIN(2 * *timeStep,timetemp);
else {
int i;
CKTnode* node;
double timetemp;
double tmp;
double diff;
double tol;
double startTime;
int size;
ckt->CKTstat->STATtranTruncTime += SPfrontEnd->IFseconds() - startTime;
return(OK);
#else /* NEWTRUNC */
int i;
CKTnode *node;
double timetemp;
double tmp;
double diff;
double tol;
double startTime;
int size;
startTime = SPfrontEnd->IFseconds();
startTime = SPfrontEnd->IFseconds();
timetemp = HUGE;
size = SMPmatSize(ckt->CKTmatrix);
#ifdef STEPDEBUG
printf("\nNEWTRUNC at time %g, delta %g\n", ckt->CKTtime, ckt->CKTdeltaOld[0]);
#endif
node = ckt->CKTnodes;
switch (ckt->CKTintegrateMethod) {
timetemp = HUGE;
size = SMPmatSize(ckt->CKTmatrix);
case TRAPEZOIDAL:
#ifdef STEPDEBUG
printf("at time %g, delta %g\n",ckt->CKTtime,ckt->CKTdeltaOld[0]);
printf("TRAP, Order is %d\n", ckt->CKTorder);
#endif
node = ckt->CKTnodes;
switch(ckt->CKTintegrateMethod) {
case TRAPEZOIDAL:
switch(ckt->CKTorder) {
case 1:
for(i=1;i<size;i++) {
tol = MAX( fabs(ckt->CKTrhs[i]),fabs(ckt->CKTpred[i]))*
ckt->CKTlteReltol+ckt->CKTlteAbstol;
node = node->next;
if(node->type!= SP_VOLTAGE) continue;
diff = ckt->CKTrhs[i]-ckt->CKTpred[i];
switch (ckt->CKTorder) {
case 1:
for (i = 1; i < size; i++) {
tol = MAX(fabs(ckt->CKTrhs[i]), fabs(ckt->CKTpred[i])) *
ckt->CKTlteReltol + ckt->CKTlteAbstol;
node = node->next;
if (node->type != SP_VOLTAGE) continue;
diff = ckt->CKTrhs[i] - ckt->CKTpred[i];
#ifdef STEPDEBUG
printf("%s: cor=%g, pred=%g ",node->name,
ckt->CKTrhs[i],ckt->CKTpred[i]);
printf("%s: cor=%g, pred=%g ", node->name,
ckt->CKTrhs[i], ckt->CKTpred[i]);
#endif
if(diff != 0) {
tmp = ckt->CKTtrtol * tol * 2 /diff;
tmp = ckt->CKTdeltaOld[0]*sqrt(fabs(tmp));
timetemp = MIN(timetemp,tmp);
if (diff != 0) {
// if (!AlmostEqualUlps(diff, 0, 10)) {
tmp = ckt->CKTlteTrtol * tol * 2 / diff;
tmp = ckt->CKTdeltaOld[0] * fabs(tmp);
timetemp = MIN(timetemp, tmp);
#ifdef STEPDEBUG
printf("tol = %g, diff = %g, h->%g\n",tol,diff,tmp);
printf("tol = %g, diff = %g, h->%g\n", tol, diff, tmp);
#endif
} else {
}
else {
#ifdef STEPDEBUG
printf("diff is 0\n");
printf("diff is 0\n");
#endif
}
}
break;
case 2:
for (i = 1; i < size; i++) {
tol = MAX(fabs(ckt->CKTrhs[i]), fabs(ckt->CKTpred[i])) *
ckt->CKTlteReltol + ckt->CKTlteAbstol;
node = node->next;
if (node->type != SP_VOLTAGE) continue;
diff = ckt->CKTrhs[i] - ckt->CKTpred[i];
#ifdef STEPDEBUG
printf("%s: cor=%g, pred=%g ", node->name,
ckt->CKTrhs[i], ckt->CKTpred[i]);
#endif
if (diff != 0) {
// if (!AlmostEqualUlps(diff, 0, 10)) {
tmp = ckt->CKTlteTrtol * tol * 2 / diff;
tmp = ckt->CKTdeltaOld[0] * sqrt(fabs(tmp));
timetemp = MIN(timetemp, tmp);
#ifdef STEPDEBUG
printf("tol = %g, diff = %g, h->%g\n", tol, diff, tmp);
#endif
}
else {
#ifdef STEPDEBUG
printf("diff is 0\n");
#endif
}
}
break;
/* case 2:
for(i=1;i<size;i++) {
tol = MAX( fabs(ckt->CKTrhs[i]),fabs(ckt->CKTpred[i]))*
ckt->CKTlteReltol+ckt->CKTlteAbstol;
node = node->next;
if(node->type!= SP_VOLTAGE) continue;
diff = ckt->CKTrhs[i]-ckt->CKTpred[i];
#ifdef STEPDEBUG
printf("%s: cor=%g, pred=%g ",node->name,ckt->CKTrhs[i],
ckt->CKTpred[i]);
#endif
if(diff != 0) {
// if(!AlmostEqualUlps(diff, 0, 10)) {
tmp = tol * ckt->CKTlteTrtol * (ckt->CKTdeltaOld[0] + ckt->CKTdeltaOld[1])
/ (diff * ckt->CKTdelta);
tmp = fabs(tmp);
tmp = exp(log(tmp) / 3);
tmp *= ckt->CKTdelta;
timetemp = MIN(timetemp,tmp);
#ifdef STEPDEBUG
printf("tol = %g, diff = %g, h->%g\n",tol,diff,tmp);
#endif
} else {
#ifdef STEPDEBUG
printf("diff is 0\n");
#endif
}
}
break; */
default:
return(E_ORDER);
break;
}
break;
case 2:
for(i=1;i<size;i++) {
tol = MAX( fabs(ckt->CKTrhs[i]),fabs(ckt->CKTpred[i]))*
ckt->CKTlteReltol+ckt->CKTlteAbstol;
node = node->next;
if(node->type!= SP_VOLTAGE) continue;
diff = ckt->CKTrhs[i]-ckt->CKTpred[i];
case GEAR: {
#ifdef STEPDEBUG
printf("%s: cor=%g, pred=%g ",node->name,ckt->CKTrhs[i],
ckt->CKTpred[i]);
printf("GEAR, Order is %d\n", ckt->CKTorder);
#endif
if(diff != 0) {
tmp = ckt->CKTdeltaOld[0]*ckt->CKTtrtol * tol * 3 *
(ckt->CKTdeltaOld[0]+ckt->CKTdeltaOld[1])/diff;
tmp = fabs(tmp);
timetemp = MIN(timetemp,tmp);
#ifdef STEPDEBUG
printf("tol = %g, diff = %g, h->%g\n",tol,diff,tmp);
#endif
} else {
#ifdef STEPDEBUG
printf("diff is 0\n");
#endif
}
double delsum = 0;
for (i = 0; i <= ckt->CKTorder; i++) {
delsum += ckt->CKTdeltaOld[i];
}
break;
default:
return(E_ORDER);
break;
}
break;
case GEAR: {
double delsum=0;
for(i=0;i<=ckt->CKTorder;i++) {
delsum += ckt->CKTdeltaOld[i];
}
for(i=1;i<size;i++) {
node = node->next;
if(node->type!= SP_VOLTAGE) continue;
tol = MAX( fabs(ckt->CKTrhs[i]),fabs(ckt->CKTpred[i]))*
ckt->CKTlteReltol+ckt->CKTlteAbstol;
diff = (ckt->CKTrhs[i]-ckt->CKTpred[i]);
for (i = 1; i < size; i++) {
node = node->next;
if (node->type != SP_VOLTAGE) continue;
tol = MAX(fabs(ckt->CKTrhs[i]), fabs(ckt->CKTpred[i])) *
ckt->CKTlteReltol + ckt->CKTlteAbstol;
diff = (ckt->CKTrhs[i] - ckt->CKTpred[i]);
#ifdef STEPDEBUG
printf("%s: cor=%g, pred=%g ",node->name,ckt->CKTrhs[i],
printf("%s: cor=%g, pred=%g ", node->name, ckt->CKTrhs[i],
ckt->CKTpred[i]);
#endif
if(diff != 0) {
tmp = tol*ckt->CKTtrtol*delsum/(diff*ckt->CKTdelta);
tmp = fabs(tmp);
switch(ckt->CKTorder) {
if (diff != 0) {
tmp = tol * ckt->CKTlteTrtol * delsum / (diff * ckt->CKTdelta);
tmp = fabs(tmp);
switch (ckt->CKTorder) {
case 0:
break;
case 1:
tmp = sqrt(tmp);
break;
default:
tmp = exp(log(tmp)/(ckt->CKTorder+1));
tmp = exp(log(tmp) / (ckt->CKTorder + 1));
break;
}
tmp *= ckt->CKTdelta;
timetemp = MIN(timetemp, tmp);
#ifdef STEPDEBUG
printf("tol = %g, diff = %g, h->%g\n", tol, diff, tmp);
#endif
}
tmp *= ckt->CKTdelta;
timetemp = MIN(timetemp,tmp);
else {
#ifdef STEPDEBUG
printf("tol = %g, diff = %g, h->%g\n",tol,diff,tmp);
#endif
} else {
#ifdef STEPDEBUG
printf("diff is 0\n");
printf("diff is 0\n");
#endif
}
}
}
}
break;
break;
default:
return(E_METHOD);
default:
return(E_METHOD);
}
*timeStep = MIN(2 * *timeStep, timetemp);
ckt->CKTstat->STATtranTruncTime += SPfrontEnd->IFseconds() - startTime;
return(OK);
}
*timeStep = MIN(2 * *timeStep,timetemp);
ckt->CKTstat->STATtranTruncTime += SPfrontEnd->IFseconds() - startTime;
return(OK);
#endif /* NEWTRUNC */
}

View File

@ -181,7 +181,7 @@ void com_optran(wordlist* wl) {
/* optran deselected by setting opstepsize to 0 */
if (opstepsize == 0) {
nooptran = TRUE;
fprintf(stdout, "Note: Optran is deselected");
fprintf(stdout, "Note: Optran is deselected.\n");
}
dataset = TRUE;

View File

@ -814,13 +814,16 @@ DEVcap(CKTcircuit *ckt, double vgd, double vgs, double vgb, double covlgd,
double
DEVpred(CKTcircuit *ckt, int loct)
{
#ifndef NEWTRUNC
double xfact;
if (!ckt->CKTnewtrunc) {
double xfact;
xfact = ckt->CKTdelta/ckt->CKTdeltaOld[1];
return( ( (1+xfact) * *(ckt->CKTstate1+loct) ) -
( xfact * *(ckt->CKTstate2+loct) ) );
#endif /* NEWTRUNC */
xfact = ckt->CKTdelta / ckt->CKTdeltaOld[1];
return(((1 + xfact) * *(ckt->CKTstate1 + loct)) -
(xfact * *(ckt->CKTstate2 + loct)));
}
else {
return 1.;
}
}

View File

@ -38,6 +38,7 @@ if $?osdi_enabled
osdi @pkglibdir@/BSIMCMG.osdi
osdi @pkglibdir@/HICUMl0-2.0.osdi
osdi @pkglibdir@/psp103_nqs.osdi
osdi @pkglibdir@/psp103.osdi
osdi @pkglibdir@/r2_cmc.osdi
osdi @pkglibdir@/vbic_4T_et_cf.osdi

View File

@ -142,11 +142,10 @@ struct CKTcircuitmin {
double CKTreltol; /* --- */
double CKTchgtol; /* --- */
double CKTvoltTol; /* --- */
/* What is this define for ? */
#ifdef NEWTRUNC
double CKTlteReltol;
double CKTlteAbstol;
#endif /* NEWTRUNC */
double CKTlteReltol; /* relative error in voltage based truncation error estimation */
double CKTlteAbstol; /* absolute error in voltage based truncation error estimation */
double CKTlteTrtol; /* scaling time step in voltage based truncation error estimation */
int CKTnewtrunc; /* enable lte (local truncation error) based on voltages */
double CKTgmin; /* .options GMIN */
double CKTgshunt; /* .options RSHUNT */
double CKTcshunt; /* .options CSHUNT */

View File

@ -40,6 +40,7 @@ if $?osdi_enabled
osdi ../lib/ngspice/BSIMCMG.osdi
osdi ../lib/ngspice/HICUMl0-2.0.osdi
osdi ../lib/ngspice/psp103_nqs.osdi
osdi ../lib/ngspice/psp103.osdi
osdi ../lib/ngspice/r2_cmc.osdi
osdi ../lib/ngspice/vbic_4T_et_cf.osdi

View File

@ -41,6 +41,7 @@ if $?osdi_enabled
osdi C:/Spiced/lib/ngspice/BSIMCMG.osdi
osdi C:/Spiced/lib/ngspice/HICUMl0-2.0.osdi
osdi C:/Spiced/lib/ngspice/psp103_nqs.osdi
osdi C:/Spiced/lib/ngspice/psp103.osdi
osdi C:/Spiced/lib/ngspice/r2_cmc.osdi
osdi C:/Spiced/lib/ngspice/vbic_4T_et_cf.osdi

View File

@ -39,6 +39,7 @@ if $?osdi_enabled
osdi C:/Spice64d/lib/ngspice/BSIMBULK107.osdi
osdi C:/Spice64d/lib/ngspice/BSIMCMG.osdi
osdi C:/Spice64d/lib/ngspice/HICUMl0-2.0.osdi
osdi C:/Spice64d/lib/ngspice/psp103_nqs.osdi
osdi C:/Spice64d/lib/ngspice/psp103.osdi
osdi C:/Spice64d/lib/ngspice/r2_cmc.osdi
osdi C:/Spice64d/lib/ngspice/vbic_4T_et_cf.osdi

View File

@ -40,6 +40,7 @@ if $?osdi_enabled
osdi C:/Spice/lib/ngspice/BSIMCMG.osdi
osdi C:/Spice/lib/ngspice/HICUMl0-2.0.osdi
osdi C:/Spice/lib/ngspice/psp103_nqs.osdi
osdi C:/Spice/lib/ngspice/psp103.osdi
osdi C:/Spice/lib/ngspice/r2_cmc.osdi
osdi C:/Spice/lib/ngspice/vbic_4T_et_cf.osdi

View File

@ -40,6 +40,7 @@ if $?osdi_enabled
osdi C:/Spice64/lib/ngspice/BSIMCMG.osdi
osdi C:/Spice64/lib/ngspice/HICUMl0-2.0.osdi
osdi C:/Spice64/lib/ngspice/psp103_nqs.osdi
osdi C:/Spice64/lib/ngspice/psp103.osdi
osdi C:/Spice64/lib/ngspice/r2_cmc.osdi
osdi C:/Spice64/lib/ngspice/vbic_4T_et_cf.osdi

View File

@ -464,9 +464,6 @@
/* Define if you want to discover :) */
/* #undef NEWPRED */
/* Do not trigger unwanted traps by default */
/* #undef NEWTRUNC */
/* Define if we want NOBYPASS */
/* #undef NOBYPASS */
@ -490,7 +487,7 @@
#define PACKAGE_VERSION VERSION
/* Define if we want predictor algorithm */
/* #undef PREDICTOR */
#define PREDICTOR
/* Define to 1 if the C compiler supports function prototypes. */
/* #undef PROTOTYPES */