devices/asrc, rewrite #9/10, combine common code
This commit is contained in:
parent
704e50b62a
commit
66a0da8ab9
|
|
@ -57,30 +57,12 @@ ASRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < here->ASRCtree->numVars; i++) {
|
for (i = 0; i < here->ASRCtree->numVars; i++) {
|
||||||
switch (here->ASRCtree->varTypes[i]) {
|
|
||||||
case IF_INSTANCE:
|
|
||||||
if (here->ASRCtype == ASRC_VOLTAGE) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
/* CCVS */
|
|
||||||
*(here->ASRCposptr[j++]) -= derivs[i] / factor;
|
*(here->ASRCposptr[j++]) -= derivs[i] / factor;
|
||||||
} else {
|
} else {
|
||||||
/* CCCS */
|
|
||||||
*(here->ASRCposptr[j++]) += derivs[i] / factor;
|
*(here->ASRCposptr[j++]) += derivs[i] / factor;
|
||||||
*(here->ASRCposptr[j++]) -= derivs[i] / factor;
|
*(here->ASRCposptr[j++]) -= derivs[i] / factor;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case IF_NODE:
|
|
||||||
if (here->ASRCtype == ASRC_VOLTAGE) {
|
|
||||||
/* VCVS */
|
|
||||||
*(here->ASRCposptr[j++]) -= derivs[i] / factor;
|
|
||||||
} else {
|
|
||||||
/* VCCS */
|
|
||||||
*(here->ASRCposptr[j++]) += derivs[i] / factor;
|
|
||||||
*(here->ASRCposptr[j++]) -= derivs[i] / factor;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return(E_BADPARM);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,30 +91,12 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
for (i = 0; i < here->ASRCtree->numVars; i++) {
|
for (i = 0; i < here->ASRCtree->numVars; i++) {
|
||||||
rhs -= (asrc_vals[i] * asrc_derivs[i]);
|
rhs -= (asrc_vals[i] * asrc_derivs[i]);
|
||||||
|
|
||||||
switch (here->ASRCtree->varTypes[i]) {
|
|
||||||
case IF_INSTANCE:
|
|
||||||
if (here->ASRCtype == ASRC_VOLTAGE) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
/* CCVS */
|
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
|
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
|
||||||
} else {
|
} else {
|
||||||
/* CCCS */
|
|
||||||
*(here->ASRCposptr[j++]) += asrc_derivs[i] * factor;
|
*(here->ASRCposptr[j++]) += asrc_derivs[i] * factor;
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
|
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case IF_NODE:
|
|
||||||
if (here->ASRCtype == ASRC_VOLTAGE) {
|
|
||||||
/* VCVS */
|
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
|
|
||||||
} else {
|
|
||||||
/* VCCS */
|
|
||||||
*(here->ASRCposptr[j++]) += asrc_derivs[i] * factor;
|
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return(E_BADPARM);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert the RHS */
|
/* Insert the RHS */
|
||||||
|
|
|
||||||
|
|
@ -73,30 +73,12 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < here->ASRCtree->numVars; i++) {
|
for (i = 0; i < here->ASRCtree->numVars; i++) {
|
||||||
switch (here->ASRCtree->varTypes[i]) {
|
|
||||||
case IF_INSTANCE:
|
|
||||||
if (here->ASRCtype == ASRC_VOLTAGE) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
/* CCVS */
|
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor;
|
*(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor;
|
||||||
} else {
|
} else {
|
||||||
/* CCCS */
|
|
||||||
*(here->ASRCposptr[j++]) += asrc_derivs[i] / factor;
|
*(here->ASRCposptr[j++]) += asrc_derivs[i] / factor;
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor;
|
*(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case IF_NODE:
|
|
||||||
if (here->ASRCtype == ASRC_VOLTAGE) {
|
|
||||||
/* VCVS */
|
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor;
|
|
||||||
} else {
|
|
||||||
/* VCCS */
|
|
||||||
*(here->ASRCposptr[j++]) += asrc_derivs[i] / factor;
|
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return(E_BADPARM);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue