From 6ea1e1932dfaafd4d9719823934034cea9db4dd8 Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 12 Apr 2015 18:11:41 +0200 Subject: [PATCH] devices/asrc, rewrite #4/10, drop `ASRCcont_br' --- src/spicelib/devices/asrc/asrcdefs.h | 1 - src/spicelib/devices/asrc/asrcset.c | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/spicelib/devices/asrc/asrcdefs.h b/src/spicelib/devices/asrc/asrcdefs.h index c4c617935..d402fded4 100644 --- a/src/spicelib/devices/asrc/asrcdefs.h +++ b/src/spicelib/devices/asrc/asrcdefs.h @@ -39,7 +39,6 @@ typedef struct sASRCinstance { * in the sparce matrix */ double ASRCprev_value; /* Previous value for the convergence test */ double *ASRCacValues; /* Store rhs and derivatives for ac anal */ - int ASRCcont_br; /* Temporary store for controlling current branch */ unsigned ASRCtempGiven : 1; /* indicates temperature specified */ unsigned ASRCdtempGiven : 1; /* indicates delta-temp specified */ diff --git a/src/spicelib/devices/asrc/asrcset.c b/src/spicelib/devices/asrc/asrcset.c index db091074a..951ea011c 100644 --- a/src/spicelib/devices/asrc/asrcset.c +++ b/src/spicelib/devices/asrc/asrcset.c @@ -77,10 +77,12 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) } for (i = 0; i < here->ASRCtree->numVars; i++) { + int column; + switch (here->ASRCtree->varTypes[i]) { case IF_INSTANCE: - here->ASRCcont_br = CKTfndBranch(ckt, here->ASRCtree->vars[i].uValue); - if (here->ASRCcont_br == 0) { + column = CKTfndBranch(ckt, here->ASRCtree->vars[i].uValue); + if (column == 0) { SPfrontEnd->IFerrorf(ERR_FATAL, "%s: unknown controlling source %s", here->ASRCname, here->ASRCtree->vars[i].uValue); return(E_BADPARM); @@ -88,26 +90,27 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) if (here->ASRCtype == ASRC_VOLTAGE) { /* CCVS */ here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1); - TSTALLOC(ASRCposptr[j++], here->ASRCbranch, here->ASRCcont_br); + TSTALLOC(ASRCposptr[j++], here->ASRCbranch, column); } else if (here->ASRCtype == ASRC_CURRENT) { /* CCCS */ here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 2); - TSTALLOC(ASRCposptr[j++], here->ASRCposNode, here->ASRCcont_br); - TSTALLOC(ASRCposptr[j++], here->ASRCnegNode, here->ASRCcont_br); + TSTALLOC(ASRCposptr[j++], here->ASRCposNode, column); + TSTALLOC(ASRCposptr[j++], here->ASRCnegNode, column); } else { return (E_BADPARM); } break; case IF_NODE: + column = here->ASRCtree->vars[i].nValue->number; if (here->ASRCtype == ASRC_VOLTAGE) { /* VCVS */ here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1); - TSTALLOC(ASRCposptr[j++], here->ASRCbranch, here->ASRCtree->vars[i].nValue->number); + TSTALLOC(ASRCposptr[j++], here->ASRCbranch, column); } else if (here->ASRCtype == ASRC_CURRENT) { /* VCCS */ here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 2); - TSTALLOC(ASRCposptr[j++], here->ASRCposNode, here->ASRCtree->vars[i].nValue->number); - TSTALLOC(ASRCposptr[j++], here->ASRCnegNode, here->ASRCtree->vars[i].nValue->number); + TSTALLOC(ASRCposptr[j++], here->ASRCposNode, column); + TSTALLOC(ASRCposptr[j++], here->ASRCnegNode, column); } else { return (E_BADPARM); }