asrc, i=, add branch current node, this is an untested experiment !

This commit is contained in:
rlar 2015-04-24 21:53:41 +02:00
parent 764416c57c
commit 6e2673d243
5 changed files with 31 additions and 2 deletions

View File

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

View File

@ -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 */

View File

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

View File

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

View File

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