From 036a45f348b5098bcd2c07914900ff461dd4d394 Mon Sep 17 00:00:00 2001 From: rlar Date: Sat, 11 Apr 2015 21:27:01 +0200 Subject: [PATCH] devices/asrc, cleanup #6/9, cleanup --- src/spicelib/devices/asrc/asrc.c | 3 +-- src/spicelib/devices/asrc/asrcacld.c | 8 +++--- src/spicelib/devices/asrc/asrcask.c | 11 +++++---- src/spicelib/devices/asrc/asrcconv.c | 11 ++++----- src/spicelib/devices/asrc/asrcfbr.c | 6 ++--- src/spicelib/devices/asrc/asrcload.c | 8 +++--- src/spicelib/devices/asrc/asrcmdel.c | 10 +++++--- src/spicelib/devices/asrc/asrcpzld.c | 9 +++---- src/spicelib/devices/asrc/asrcset.c | 37 ++++++++++++---------------- src/spicelib/devices/asrc/asrctemp.c | 6 ++--- 10 files changed, 52 insertions(+), 57 deletions(-) diff --git a/src/spicelib/devices/asrc/asrc.c b/src/spicelib/devices/asrc/asrc.c index 1ccaeadb5..bb4ac8620 100644 --- a/src/spicelib/devices/asrc/asrc.c +++ b/src/spicelib/devices/asrc/asrc.c @@ -15,8 +15,7 @@ IFparm ASRCpTable[] = { /* parameters */ IP("i", ASRC_CURRENT, IF_PARSETREE, "Current source"), IP("v", ASRC_VOLTAGE, IF_PARSETREE, "Voltage source"), IOPZU("temp", ASRC_TEMP, IF_REAL, "Instance operating temperature"), - IOPZ("dtemp", ASRC_DTEMP, IF_REAL, - "Instance temperature difference with the rest of the circuit"), + IOPZ("dtemp", ASRC_DTEMP, IF_REAL, "Instance temperature difference with the rest of the circuit"), IOPU("tc1", ASRC_TC1, IF_REAL, "First order temp. coefficient"), IOPU("tc2", ASRC_TC2, IF_REAL, "Second order temp. coefficient"), IOPU("reciproctc", ASRC_RTC, IF_INTEGER, "Flag to calculate reciprocal temperature behaviour"), diff --git a/src/spicelib/devices/asrc/asrcacld.c b/src/spicelib/devices/asrc/asrcacld.c index ce8fc9eb9..ae42614e4 100644 --- a/src/spicelib/devices/asrc/asrcacld.c +++ b/src/spicelib/devices/asrc/asrcacld.c @@ -29,12 +29,12 @@ ASRCacLoad(GENmodel *inModel, CKTcircuit *ckt) NG_IGNORE(ckt); for (; model; model = model->ASRCnextModel) { - for (here = model->ASRCinstances; here; - here = here->ASRCnextInstance) { + for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) { difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15; - factor = 1.0 + (here->ASRCtc1) * difference + - (here->ASRCtc2) * difference * difference; + factor = 1.0 + + (here->ASRCtc1) * difference + + (here->ASRCtc2) * difference * difference; if (here->ASRCreciproctc == 1) { factor = 1 / factor; diff --git a/src/spicelib/devices/asrc/asrcask.c b/src/spicelib/devices/asrc/asrcask.c index 45ae2f529..6554b77c7 100644 --- a/src/spicelib/devices/asrc/asrcask.c +++ b/src/spicelib/devices/asrc/asrcask.c @@ -38,12 +38,12 @@ ASRCask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, IFvalu value->rValue = here->ASRCtc2; return(OK); case ASRC_CURRENT: - value->tValue = here->ASRCtype == ASRC_CURRENT ? - here->ASRCtree : NULL; + value->tValue = + (here->ASRCtype == ASRC_CURRENT) ? here->ASRCtree : NULL; return(OK); case ASRC_VOLTAGE: - value->tValue = here->ASRCtype == ASRC_VOLTAGE ? - here->ASRCtree : NULL; + value->tValue = + (here->ASRCtype == ASRC_VOLTAGE) ? here->ASRCtree : NULL; return(OK); case ASRC_POS_NODE: value->iValue = here->ASRCposNode; @@ -58,7 +58,8 @@ ASRCask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, IFvalu value->rValue = here->ASRCprev_value; return(OK); case ASRC_OUTPUTVOLTAGE: - value->rValue = ckt->CKTrhsOld[here->ASRCposNode] - + value->rValue = + ckt->CKTrhsOld[here->ASRCposNode] - ckt->CKTrhsOld[here->ASRCnegNode]; return(OK); default: diff --git a/src/spicelib/devices/asrc/asrcconv.c b/src/spicelib/devices/asrc/asrcconv.c index fe967d0c2..6defad7b0 100644 --- a/src/spicelib/devices/asrc/asrcconv.c +++ b/src/spicelib/devices/asrc/asrcconv.c @@ -22,8 +22,7 @@ ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt) double rhs; for (; model; model = model->ASRCnextModel) { - for (here = model->ASRCinstances; here; - here = here->ASRCnextInstance) { + for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) { i = here->ASRCtree->numVars; if (asrc_nvals < i) { @@ -54,11 +53,11 @@ ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt) diff = fabs(prev - rhs); if (here->ASRCtype == ASRC_VOLTAGE) { - tol = ckt->CKTreltol * - MAX(fabs(rhs), fabs(prev)) + ckt->CKTvoltTol; + tol = ckt->CKTreltol * MAX(fabs(rhs), fabs(prev)) + + ckt->CKTvoltTol; } else { - tol = ckt->CKTreltol * - MAX(fabs(rhs), fabs(prev)) + ckt->CKTabstol; + tol = ckt->CKTreltol * MAX(fabs(rhs), fabs(prev)) + + ckt->CKTabstol; } if (diff > tol) { diff --git a/src/spicelib/devices/asrc/asrcfbr.c b/src/spicelib/devices/asrc/asrcfbr.c index a95f1f00e..ba3085840 100644 --- a/src/spicelib/devices/asrc/asrcfbr.c +++ b/src/spicelib/devices/asrc/asrcfbr.c @@ -20,12 +20,12 @@ ASRCfindBr(CKTcircuit *ckt, GENmodel *inputModel, IFuid name) CKTnode *tmp; for (; model; model = model->ASRCnextModel) { - for (here = model->ASRCinstances; here; - here = here->ASRCnextInstance) { + for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) { if (here->ASRCname == name) { if (here->ASRCbranch == 0) { error = CKTmkCur(ckt, &tmp, here->ASRCname, "branch"); - if (error) return(error); + if (error) + return(error); here->ASRCbranch = tmp->number; } return(here->ASRCbranch); diff --git a/src/spicelib/devices/asrc/asrcload.c b/src/spicelib/devices/asrc/asrcload.c index 54933a3f3..123474177 100644 --- a/src/spicelib/devices/asrc/asrcload.c +++ b/src/spicelib/devices/asrc/asrcload.c @@ -29,12 +29,12 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt) double factor; for (; model; model = model->ASRCnextModel) { - for (here = model->ASRCinstances; here; - here=here->ASRCnextInstance) - { + for (here = model->ASRCinstances; here; here=here->ASRCnextInstance) { difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15; - factor = 1.0 + (here->ASRCtc1) * difference + (here->ASRCtc2) * difference * difference; + factor = 1.0 + + (here->ASRCtc1) * difference + + (here->ASRCtc2) * difference * difference; if (here->ASRCreciproctc == 1) { factor = 1 / factor; diff --git a/src/spicelib/devices/asrc/asrcmdel.c b/src/spicelib/devices/asrc/asrcmdel.c index db470a899..e23443f0a 100644 --- a/src/spicelib/devices/asrc/asrcmdel.c +++ b/src/spicelib/devices/asrc/asrcmdel.c @@ -20,8 +20,8 @@ ASRCmDelete(GENmodel **modList, IFuid modname, GENmodel *killModel) oldmod = model; for (; *model; model = &((*model)->ASRCnextModel)) { - if ((*model)->ASRCmodName == modname || - (modfast && *model == modfast)) goto delgot; + if ((*model)->ASRCmodName == modname || (modfast && *model == modfast)) + goto delgot; oldmod = model; } @@ -33,11 +33,13 @@ ASRCmDelete(GENmodel **modList, IFuid modname, GENmodel *killModel) for (here = (*model)->ASRCinstances; here; here = here->ASRCnextInstance) { FREE(here->ASRCacValues); - if (prev) FREE(prev); + if (prev) + FREE(prev); prev = here; } - if (prev) FREE(prev); + if (prev) + FREE(prev); FREE(*model); return(OK); } diff --git a/src/spicelib/devices/asrc/asrcpzld.c b/src/spicelib/devices/asrc/asrcpzld.c index 161ba4f29..3c4c31c39 100644 --- a/src/spicelib/devices/asrc/asrcpzld.c +++ b/src/spicelib/devices/asrc/asrcpzld.c @@ -28,13 +28,12 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) NG_IGNORE(s); for (; model; model = model->ASRCnextModel) { - for (here = model->ASRCinstances; here; - here = here->ASRCnextInstance) - { + for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) { difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15; - factor = 1.0 + (here->ASRCtc1) * difference + - (here->ASRCtc2) * difference * difference; + factor = 1.0 + + (here->ASRCtc1) * difference + + (here->ASRCtc2) * difference * difference; if (here->ASRCreciproctc == 1) { factor = 1 / factor; diff --git a/src/spicelib/devices/asrc/asrcset.c b/src/spicelib/devices/asrc/asrcset.c index 1234a0f32..6ab8a9233 100644 --- a/src/spicelib/devices/asrc/asrcset.c +++ b/src/spicelib/devices/asrc/asrcset.c @@ -26,12 +26,14 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) NG_IGNORE(states); for (; model; model = model->ASRCnextModel) { - for (here = model->ASRCinstances; here; - here=here->ASRCnextInstance) { + for (here = model->ASRCinstances; here; here=here->ASRCnextInstance) { - if (!here->ASRCtc1Given) here->ASRCtc1 = 0.0; - if (!here->ASRCtc2Given) here->ASRCtc2 = 0.0; - if (!here->ASRCreciproctcGiven) here->ASRCreciproctc = 0; + if (!here->ASRCtc1Given) + here->ASRCtc1 = 0.0; + if (!here->ASRCtc2Given) + here->ASRCtc2 = 0.0; + if (!here->ASRCreciproctcGiven) + here->ASRCreciproctc = 0; here->ASRCposptr = NULL; j = 0; /* strchr of the array holding ptrs to SMP */ @@ -40,7 +42,8 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) if (here->ASRCtype == ASRC_VOLTAGE) { if (here->ASRCbranch == 0) { error = CKTmkCur(ckt, &tmp, here->ASRCname, "branch"); - if (error) return(error); + if (error) + return(error); here->ASRCbranch = tmp->number; } } @@ -64,8 +67,7 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) if (here->ASRCtype == ASRC_VOLTAGE) { if (here->ASRCposNode == here->ASRCnegNode) { - SPfrontEnd->IFerrorf(ERR_FATAL, - "instance %s is a shorted ASRC", here->ASRCname); + SPfrontEnd->IFerrorf(ERR_FATAL, "instance %s is a shorted ASRC", here->ASRCname); return(E_UNSUPP); } @@ -80,11 +82,10 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) for (i = 0; i < here->ASRCtree->numVars; i++) { switch (here->ASRCtree->varTypes[i]) { case IF_INSTANCE: - here->ASRCcont_br = CKTfndBranch(ckt, - here->ASRCtree->vars[i].uValue); + here->ASRCcont_br = CKTfndBranch(ckt, here->ASRCtree->vars[i].uValue); if (here->ASRCcont_br == 0) { - SPfrontEnd->IFerrorf (ERR_FATAL, - "%s: unknown controlling source %s", here->ASRCname, here->ASRCtree->vars[i].uValue); + SPfrontEnd->IFerrorf(ERR_FATAL, "%s: unknown controlling source %s", + here->ASRCname, here->ASRCtree->vars[i].uValue); return(E_BADPARM); } if (here->ASRCtype == ASRC_VOLTAGE) { @@ -136,19 +137,13 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) int -ASRCunsetup( - GENmodel *inModel, - CKTcircuit *ckt) +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; diff --git a/src/spicelib/devices/asrc/asrctemp.c b/src/spicelib/devices/asrc/asrctemp.c index 77364a4b4..469018eaa 100644 --- a/src/spicelib/devices/asrc/asrctemp.c +++ b/src/spicelib/devices/asrc/asrctemp.c @@ -16,14 +16,14 @@ ASRCtemp(GENmodel *inModel, CKTcircuit *ckt) ASRCinstance *here; for (; model; model = model->ASRCnextModel) { - for (here = model->ASRCinstances; here; - here = here->ASRCnextInstance) { + for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) { /* Default Value Processing for Source Instance */ if (!here->ASRCtempGiven) { here->ASRCtemp = ckt->CKTtemp; - if (!here->ASRCdtempGiven) here->ASRCdtemp = 0.0; + if (!here->ASRCdtempGiven) + here->ASRCdtemp = 0.0; } else { here->ASRCdtemp = 0.0; if (here->ASRCdtempGiven)