diff --git a/src/spicelib/devices/asrc/asrcacld.c b/src/spicelib/devices/asrc/asrcacld.c index 91bc05748..910f10064 100644 --- a/src/spicelib/devices/asrc/asrcacld.c +++ b/src/spicelib/devices/asrc/asrcacld.c @@ -50,19 +50,22 @@ ASRCacLoad(GENmodel *inModel, CKTcircuit *ckt) derivs = here->ASRCacValues; if (here->ASRCtype == ASRC_VOLTAGE) { + *(here->ASRCposptr[j++]) += 1.0; *(here->ASRCposptr[j++]) -= 1.0; *(here->ASRCposptr[j++]) -= 1.0; *(here->ASRCposptr[j++]) += 1.0; - } - for (i = 0; i < here->ASRCtree->numVars; i++) { - if (here->ASRCtype == ASRC_VOLTAGE) { - *(here->ASRCposptr[j++]) -= derivs[i] / factor; - } else { - *(here->ASRCposptr[j++]) += derivs[i] / factor; - *(here->ASRCposptr[j++]) -= derivs[i] / factor; - } + for (i = 0; i < here->ASRCtree->numVars; i++) + *(here->ASRCposptr[j++]) -= derivs[i] / factor; + + } else { + + 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/asrcload.c b/src/spicelib/devices/asrc/asrcload.c index 7ddba8c35..5a59dc1c0 100644 --- a/src/spicelib/devices/asrc/asrcload.c +++ b/src/spicelib/devices/asrc/asrcload.c @@ -82,27 +82,29 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt) } if (here->ASRCtype == ASRC_VOLTAGE) { + *(here->ASRCposptr[j++]) += 1.0; *(here->ASRCposptr[j++]) -= 1.0; *(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]); + for (i = 0; i < here->ASRCtree->numVars; i++) { + rhs -= (asrc_vals[i] * asrc_derivs[i]); - if (here->ASRCtype == ASRC_VOLTAGE) { - *(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor; - } else { - *(here->ASRCposptr[j++]) += asrc_derivs[i] * factor; - *(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor; - } - } + *(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor; + } - /* Insert the RHS */ - if (here->ASRCtype == ASRC_VOLTAGE) { ckt->CKTrhs[here->ASRCbranch] += factor * rhs; + } else { + + for (i = 0; i < here->ASRCtree->numVars; i++) { + rhs -= (asrc_vals[i] * asrc_derivs[i]); + + *(here->ASRCposptr[j++]) += asrc_derivs[i] * factor; + *(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor; + } + ckt->CKTrhs[here->ASRCposNode] -= 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 5284c5b7b..0649aad3f 100644 --- a/src/spicelib/devices/asrc/asrcpzld.c +++ b/src/spicelib/devices/asrc/asrcpzld.c @@ -66,19 +66,22 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) return(E_BADPARM); if (here->ASRCtype == ASRC_VOLTAGE) { + *(here->ASRCposptr[j++]) += 1.0; *(here->ASRCposptr[j++]) -= 1.0; *(here->ASRCposptr[j++]) -= 1.0; *(here->ASRCposptr[j++]) += 1.0; - } - for (i = 0; i < here->ASRCtree->numVars; i++) { - if (here->ASRCtype == ASRC_VOLTAGE) { - *(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor; - } else { - *(here->ASRCposptr[j++]) += asrc_derivs[i] / factor; - *(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor; - } + for (i = 0; i < here->ASRCtree->numVars; i++) + *(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor; + + } else { + + for (i = 0; i < here->ASRCtree->numVars; i++) { + *(here->ASRCposptr[j++]) += asrc_derivs[i] / factor; + *(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor; + } + } } }