|
|
|
@ -10,6 +10,13 @@ Author: 1987 Kanwar Jit Singh |
|
|
|
#include "ngspice/suffix.h" |
|
|
|
|
|
|
|
|
|
|
|
#define TSTALLOC(ptr, first, second) \ |
|
|
|
do { \ |
|
|
|
if ((here->ptr = SMPmakeElt(matrix, first, second)) == NULL) \ |
|
|
|
return(E_NOMEM); \ |
|
|
|
} while(0) |
|
|
|
|
|
|
|
|
|
|
|
/* load the voltage source structure with those |
|
|
|
* pointers needed later for fast matrix loading |
|
|
|
*/ |
|
|
|
@ -43,25 +50,6 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) |
|
|
|
if (!here->ASRCreciproctcGiven) |
|
|
|
here->ASRCreciproctc = 0; |
|
|
|
|
|
|
|
if (here->ASRCtype == ASRC_VOLTAGE) |
|
|
|
if (here->ASRCbranch == 0) { |
|
|
|
error = CKTmkCur(ckt, &tmp, here->ASRCname, "branch"); |
|
|
|
if (error) |
|
|
|
return(error); |
|
|
|
here->ASRCbranch = tmp->number; |
|
|
|
} |
|
|
|
|
|
|
|
/* macro to make elements with built in test for out of memory */ |
|
|
|
#define TSTALLOC(ptr, first, second) \ |
|
|
|
do { if ((here->ptr = SMPmakeElt(matrix, first, second)) == NULL) { \ |
|
|
|
return(E_NOMEM); \ |
|
|
|
} } while(0) |
|
|
|
|
|
|
|
#define MY_TSTALLOC(ptr, first, second) \ |
|
|
|
do { if ((here->ptr = SMPmakeElt(matrix, here->first, (second)->number)) == NULL) { \ |
|
|
|
return(E_NOMEM); \ |
|
|
|
} } while(0) |
|
|
|
|
|
|
|
switch (here->ASRCtype) { |
|
|
|
case ASRC_VOLTAGE: |
|
|
|
j = 4 + here->ASRCtree->numVars; |
|
|
|
@ -77,9 +65,18 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) |
|
|
|
|
|
|
|
/* For each controlling variable set the entries |
|
|
|
in the vector of the positions of the SMP */ |
|
|
|
|
|
|
|
j = 0; |
|
|
|
|
|
|
|
if (here->ASRCtype == ASRC_VOLTAGE) { |
|
|
|
|
|
|
|
if (here->ASRCbranch == 0) { |
|
|
|
error = CKTmkCur(ckt, &tmp, here->ASRCname, "branch"); |
|
|
|
if (error) |
|
|
|
return(error); |
|
|
|
here->ASRCbranch = tmp->number; |
|
|
|
} |
|
|
|
|
|
|
|
TSTALLOC(ASRCposptr[j++], here->ASRCposNode, here->ASRCbranch); |
|
|
|
TSTALLOC(ASRCposptr[j++], here->ASRCnegNode, here->ASRCbranch); |
|
|
|
TSTALLOC(ASRCposptr[j++], here->ASRCbranch, here->ASRCnegNode); |
|
|
|
|