diff --git a/src/spicelib/devices/asrc/asrcacld.c b/src/spicelib/devices/asrc/asrcacld.c index ae42614e4..9b15598b4 100644 --- a/src/spicelib/devices/asrc/asrcacld.c +++ b/src/spicelib/devices/asrc/asrcacld.c @@ -33,12 +33,11 @@ ASRCacLoad(GENmodel *inModel, CKTcircuit *ckt) difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15; factor = 1.0 - + (here->ASRCtc1) * difference - + (here->ASRCtc2) * difference * difference; + + here->ASRCtc1 * difference + + here->ASRCtc2 * difference * difference; - if (here->ASRCreciproctc == 1) { + if (here->ASRCreciproctc == 1) factor = 1 / factor; - } /* * Get the function and its derivatives from the diff --git a/src/spicelib/devices/asrc/asrcconv.c b/src/spicelib/devices/asrc/asrcconv.c index c6513b642..798705f52 100644 --- a/src/spicelib/devices/asrc/asrcconv.c +++ b/src/spicelib/devices/asrc/asrcconv.c @@ -35,7 +35,7 @@ ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt) asrc_derivs = NEWN(double, i); } - for (i = 0; i < here->ASRCtree->numVars; i++) { + for (i = 0; i < here->ASRCtree->numVars; i++) if (here->ASRCtree->varTypes[i] == IF_INSTANCE) { branch = CKTfndBranch(ckt, here->ASRCtree->vars[i].uValue); asrc_vals[i] = ckt->CKTrhsOld[branch]; @@ -43,7 +43,6 @@ ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt) node_num = here->ASRCtree->vars[i].nValue->number; asrc_vals[i] = ckt->CKTrhsOld[node_num]; } - } if (here->ASRCtree->IFeval(here->ASRCtree, ckt->CKTgmin, &rhs, asrc_vals, asrc_derivs) != OK) @@ -52,13 +51,12 @@ ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt) prev = here->ASRCprev_value; diff = fabs(prev - rhs); - if (here->ASRCtype == ASRC_VOLTAGE) { + if (here->ASRCtype == ASRC_VOLTAGE) tol = ckt->CKTreltol * MAX(fabs(rhs), fabs(prev)) + ckt->CKTvoltTol; - } else { + else tol = ckt->CKTreltol * MAX(fabs(rhs), fabs(prev)) + ckt->CKTabstol; - } if (diff > tol) { ckt->CKTnoncon++; diff --git a/src/spicelib/devices/asrc/asrcfbr.c b/src/spicelib/devices/asrc/asrcfbr.c index ba3085840..3c430add1 100644 --- a/src/spicelib/devices/asrc/asrcfbr.c +++ b/src/spicelib/devices/asrc/asrcfbr.c @@ -19,8 +19,8 @@ ASRCfindBr(CKTcircuit *ckt, GENmodel *inputModel, IFuid name) int error; CKTnode *tmp; - for (; model; model = model->ASRCnextModel) { - for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) { + for (; model; model = model->ASRCnextModel) + for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) if (here->ASRCname == name) { if (here->ASRCbranch == 0) { error = CKTmkCur(ckt, &tmp, here->ASRCname, "branch"); @@ -30,8 +30,6 @@ ASRCfindBr(CKTcircuit *ckt, GENmodel *inputModel, IFuid name) } return(here->ASRCbranch); } - } - } return(0); } diff --git a/src/spicelib/devices/asrc/asrcload.c b/src/spicelib/devices/asrc/asrcload.c index 49c4ed210..a73be10f2 100644 --- a/src/spicelib/devices/asrc/asrcload.c +++ b/src/spicelib/devices/asrc/asrcload.c @@ -33,12 +33,11 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt) difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15; factor = 1.0 - + (here->ASRCtc1) * difference - + (here->ASRCtc2) * difference * difference; + + here->ASRCtc1 * difference + + here->ASRCtc2 * difference * difference; - if (here->ASRCreciproctc == 1) { + if (here->ASRCreciproctc == 1) factor = 1 / factor; - } /* * Get the function and its derivatives evaluated @@ -76,7 +75,7 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt) /* The ac load precomputation and storage */ if (ckt->CKTmode & MODEINITSMSIG) { - int size = (here->ASRCtree->numVars) + 1; + int size = here->ASRCtree->numVars + 1; here->ASRCacValues = NEWN(double, size); for (i = 0; i < here->ASRCtree->numVars; i++) here->ASRCacValues[i] = asrc_derivs[i]; @@ -127,9 +126,8 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt) } /* Store the rhs for small signal analysis */ - if (ckt->CKTmode & MODEINITSMSIG) { + if (ckt->CKTmode & MODEINITSMSIG) here->ASRCacValues[here->ASRCtree->numVars] = factor * rhs; - } } } diff --git a/src/spicelib/devices/asrc/asrcpzld.c b/src/spicelib/devices/asrc/asrcpzld.c index 3c4c31c39..17fadc76d 100644 --- a/src/spicelib/devices/asrc/asrcpzld.c +++ b/src/spicelib/devices/asrc/asrcpzld.c @@ -32,12 +32,11 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15; factor = 1.0 - + (here->ASRCtc1) * difference - + (here->ASRCtc2) * difference * difference; + + here->ASRCtc1 * difference + + here->ASRCtc2 * difference * difference; - if (here->ASRCreciproctc == 1) { + if (here->ASRCreciproctc == 1) factor = 1 / factor; - } j = 0; @@ -54,7 +53,7 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) } /* Fill the vector of values from the previous solution */ - for (i = 0; i < here->ASRCtree->numVars; i++) { + for (i = 0; i < here->ASRCtree->numVars; i++) if (here->ASRCtree->varTypes[i] == IF_INSTANCE) { int branch = CKTfndBranch(ckt, here->ASRCtree->vars[i].uValue); asrc_vals[i] = *(ckt->CKTrhsOld + branch); @@ -62,7 +61,6 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) int node_num = (here->ASRCtree->vars[i].nValue) -> number; asrc_vals[i] = *(ckt->CKTrhsOld + node_num); } - } if (here->ASRCtree->IFeval(here->ASRCtree, ckt->CKTgmin, &value, asrc_vals, asrc_derivs) != OK) return(E_BADPARM); diff --git a/src/spicelib/devices/asrc/asrcset.c b/src/spicelib/devices/asrc/asrcset.c index 6ab8a9233..3dddbc9dc 100644 --- a/src/spicelib/devices/asrc/asrcset.c +++ b/src/spicelib/devices/asrc/asrcset.c @@ -39,14 +39,13 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) j = 0; /* strchr of the array holding ptrs to SMP */ v_first = 1; - if (here->ASRCtype == ASRC_VOLTAGE) { + if (here->ASRCtype == ASRC_VOLTAGE) if (here->ASRCbranch == 0) { error = CKTmkCur(ckt, &tmp, here->ASRCname, "branch"); if (error) return(error); here->ASRCbranch = tmp->number; } - } /* macro to make elements with built in test for out of memory */ #define TSTALLOC(ptr, first, second) \ @@ -142,14 +141,12 @@ ASRCunsetup(GENmodel *inModel, CKTcircuit *ckt) ASRCmodel *model = (ASRCmodel *) inModel; ASRCinstance *here; - for (; model; model = model->ASRCnextModel) { - for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) { + for (; model; model = model->ASRCnextModel) + for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) if (here->ASRCbranch) { CKTdltNNum(ckt, here->ASRCbranch); here->ASRCbranch = 0; } - } - } return OK; }