devices/asrc, rewrite #10/10, emphasise matrix for the two cases VSRC vs ISRC

This commit is contained in:
rlar 2015-04-12 18:18:29 +02:00
parent 66a0da8ab9
commit ad869c6d2d
3 changed files with 44 additions and 36 deletions

View File

@ -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;
}
*(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++)
*(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;
}
}
}
}

View File

@ -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;
}

View File

@ -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;
}
*(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++)
*(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;
}
}
}
}