diff --git a/src/spicelib/devices/asrc/asrcacld.c b/src/spicelib/devices/asrc/asrcacld.c index 910f10064..2b7f64cf6 100644 --- a/src/spicelib/devices/asrc/asrcacld.c +++ b/src/spicelib/devices/asrc/asrcacld.c @@ -61,6 +61,11 @@ ASRCacLoad(GENmodel *inModel, CKTcircuit *ckt) } else { + if (here->ASRCbranch) { + *(here->ASRCposptr[j++]) += 1.0; + *(here->ASRCposptr[j++]) -= 1.0; + } + for (i = 0; i < here->ASRCtree->numVars; i++) { *(here->ASRCposptr[j++]) += derivs[i] / factor; *(here->ASRCposptr[j++]) -= derivs[i] / factor; diff --git a/src/spicelib/devices/asrc/asrcdefs.h b/src/spicelib/devices/asrc/asrcdefs.h index 93bdef553..b7c6c9c9f 100644 --- a/src/spicelib/devices/asrc/asrcdefs.h +++ b/src/spicelib/devices/asrc/asrcdefs.h @@ -28,6 +28,8 @@ typedef struct sASRCinstance { int ASRCtype; /* Whether source is voltage or current */ int ASRCbranch; /* number of branch equation added for v source */ + int ASRCposPrimeNode; /* number of positive prime node of capacitor */ + IFparseTree *ASRCtree; /* The parse tree */ int *ASRCvars; /* indices of the controlling nodes/branches */ diff --git a/src/spicelib/devices/asrc/asrcload.c b/src/spicelib/devices/asrc/asrcload.c index e67f57cc4..75ceaf159 100644 --- a/src/spicelib/devices/asrc/asrcload.c +++ b/src/spicelib/devices/asrc/asrcload.c @@ -89,6 +89,11 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt) } else { + if (here->ASRCbranch) { + *(here->ASRCposptr[j++]) += 1.0; + *(here->ASRCposptr[j++]) -= 1.0; + } + for (i = 0; i < here->ASRCtree->numVars; i++) { rhs -= (asrc_vals[i] * asrc_derivs[i]); @@ -96,7 +101,7 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt) *(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor; } - ckt->CKTrhs[here->ASRCposNode] -= factor * rhs; + ckt->CKTrhs[here->ASRCposPrimeNode] -= factor * rhs; ckt->CKTrhs[here->ASRCnegNode] += factor * rhs; } diff --git a/src/spicelib/devices/asrc/asrcpzld.c b/src/spicelib/devices/asrc/asrcpzld.c index 1093863da..4296be7eb 100644 --- a/src/spicelib/devices/asrc/asrcpzld.c +++ b/src/spicelib/devices/asrc/asrcpzld.c @@ -77,6 +77,11 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) } else { + if (here->ASRCbranch) { + *(here->ASRCposptr[j++]) += 1.0; + *(here->ASRCposptr[j++]) -= 1.0; + } + for (i = 0; i < here->ASRCtree->numVars; i++) { *(here->ASRCposptr[j++]) += asrc_derivs[i] / factor; *(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor; diff --git a/src/spicelib/devices/asrc/asrcset.c b/src/spicelib/devices/asrc/asrcset.c index 8ff3b122b..e5e291a27 100644 --- a/src/spicelib/devices/asrc/asrcset.c +++ b/src/spicelib/devices/asrc/asrcset.c @@ -56,6 +56,8 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) break; case ASRC_CURRENT: j = 2 * here->ASRCtree->numVars; + if (here->ASRCbranch) + j += 2; break; default: return (E_BADPARM); @@ -83,6 +85,15 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) TSTALLOC(ASRCposptr[j++], here->ASRCnegNode, here->ASRCbranch); TSTALLOC(ASRCposptr[j++], here->ASRCbranch, here->ASRCnegNode); TSTALLOC(ASRCposptr[j++], here->ASRCbranch, here->ASRCposNode); + } else { + + if (here->ASRCbranch == 0) { + here->ASRCposPrimeNode = here->ASRCposNode; + } else { + here->ASRCposPrimeNode = here->ASRCbranch; + TSTALLOC(ASRCposptr[j++], here->ASRCposNode, here->ASRCbranch); + TSTALLOC(ASRCposptr[j++], here->ASRCposPrimeNode, here->ASRCbranch); + } } for (i = 0; i < here->ASRCtree->numVars; i++) { @@ -109,7 +120,7 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) if (here->ASRCtype == ASRC_VOLTAGE) { TSTALLOC(ASRCposptr[j++], here->ASRCbranch, column); } else { - TSTALLOC(ASRCposptr[j++], here->ASRCposNode, column); + TSTALLOC(ASRCposptr[j++], here->ASRCposPrimeNode, column); TSTALLOC(ASRCposptr[j++], here->ASRCnegNode, column); } } @@ -131,6 +142,7 @@ ASRCunsetup(GENmodel *inModel, CKTcircuit *ckt) if (here->ASRCbranch) { CKTdltNNum(ckt, here->ASRCbranch); here->ASRCbranch = 0; + here->ASRCposPrimeNode = 0; } return OK;