devices/asrc, cleanup #2/9, whitespace
This commit is contained in:
parent
df147cd8b8
commit
2cb727476f
|
|
@ -9,29 +9,32 @@ Author: 1987 Kanwar Jit Singh
|
||||||
#include "asrcdefs.h"
|
#include "asrcdefs.h"
|
||||||
#include "ngspice/suffix.h"
|
#include "ngspice/suffix.h"
|
||||||
|
|
||||||
|
|
||||||
/* Arbitrary source */
|
/* Arbitrary source */
|
||||||
IFparm ASRCpTable[] = { /* parameters */
|
IFparm ASRCpTable[] = { /* parameters */
|
||||||
IP( "i", ASRC_CURRENT, IF_PARSETREE, "Current source"),
|
IP("i", ASRC_CURRENT, IF_PARSETREE, "Current source"),
|
||||||
IP( "v", ASRC_VOLTAGE, IF_PARSETREE, "Voltage source"),
|
IP("v", ASRC_VOLTAGE, IF_PARSETREE, "Voltage source"),
|
||||||
IOPZU( "temp", ASRC_TEMP, IF_REAL, "Instance operating temperature"),
|
IOPZU("temp", ASRC_TEMP, IF_REAL, "Instance operating temperature"),
|
||||||
IOPZ( "dtemp", ASRC_DTEMP, IF_REAL,
|
IOPZ("dtemp", ASRC_DTEMP, IF_REAL,
|
||||||
"Instance temperature difference with the rest of the circuit"),
|
"Instance temperature difference with the rest of the circuit"),
|
||||||
IOPU( "tc1", ASRC_TC1, IF_REAL, "First order temp. coefficient"),
|
IOPU("tc1", ASRC_TC1, IF_REAL, "First order temp. coefficient"),
|
||||||
IOPU( "tc2", ASRC_TC2, IF_REAL, "Second order temp. coefficient"),
|
IOPU("tc2", ASRC_TC2, IF_REAL, "Second order temp. coefficient"),
|
||||||
IOPU( "reciproctc", ASRC_RTC, IF_INTEGER, "Flag to calculate reciprocal temperature behaviour"),
|
IOPU("reciproctc", ASRC_RTC, IF_INTEGER, "Flag to calculate reciprocal temperature behaviour"),
|
||||||
OP( "i", ASRC_OUTPUTCURRENT, IF_REAL, "Current through source"),
|
OP("i", ASRC_OUTPUTCURRENT, IF_REAL, "Current through source"),
|
||||||
OP( "v", ASRC_OUTPUTVOLTAGE, IF_REAL, "Voltage across source"),
|
OP("v", ASRC_OUTPUTVOLTAGE, IF_REAL, "Voltage across source"),
|
||||||
OP( "pos_node", ASRC_POS_NODE, IF_INTEGER, "Positive Node"),
|
OP("pos_node", ASRC_POS_NODE, IF_INTEGER, "Positive Node"),
|
||||||
OP( "neg_node", ASRC_NEG_NODE, IF_INTEGER, "Negative Node")
|
OP("neg_node", ASRC_NEG_NODE, IF_INTEGER, "Negative Node")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
char *ASRCnames[] = {
|
char *ASRCnames[] = {
|
||||||
"src+",
|
"src+",
|
||||||
"src-"
|
"src-"
|
||||||
};
|
};
|
||||||
|
|
||||||
int ASRCnSize = NUMELEMS(ASRCnames);
|
|
||||||
int ASRCpTSize = NUMELEMS(ASRCpTable);
|
int ASRCnSize = NUMELEMS(ASRCnames);
|
||||||
int ASRCmPTSize = 0;
|
int ASRCpTSize = NUMELEMS(ASRCpTable);
|
||||||
int ASRCiSize = sizeof(ASRCinstance);
|
int ASRCmPTSize = 0;
|
||||||
int ASRCmSize = sizeof(ASRCmodel);
|
int ASRCiSize = sizeof(ASRCinstance);
|
||||||
|
int ASRCmSize = sizeof(ASRCmodel);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ Author: 1988 Kanwar Jit Singh
|
||||||
int
|
int
|
||||||
ASRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
ASRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actually load the current voltage value into the
|
* Actually load the current voltage value into the
|
||||||
* sparse matrix previously provided. The values have
|
* sparse matrix previously provided. The values have
|
||||||
|
|
@ -34,63 +33,63 @@ ASRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
NG_IGNORE(ckt);
|
NG_IGNORE(ckt);
|
||||||
|
|
||||||
/* loop through all the Arbitrary source models */
|
/* loop through all the Arbitrary source models */
|
||||||
for( ; model != NULL; model = model->ASRCnextModel ) {
|
for (; model != NULL; model = model->ASRCnextModel) {
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = model->ASRCinstances; here != NULL ;
|
for (here = model->ASRCinstances; here != NULL;
|
||||||
here = here->ASRCnextInstance) {
|
here = here->ASRCnextInstance) {
|
||||||
|
|
||||||
difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15;
|
difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15;
|
||||||
factor = 1.0 + (here->ASRCtc1)*difference +
|
factor = 1.0 + (here->ASRCtc1) * difference +
|
||||||
(here->ASRCtc2)*difference*difference;
|
(here->ASRCtc2) * difference * difference;
|
||||||
if(here->ASRCreciproctc == 1) {
|
|
||||||
factor = 1/factor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
if (here->ASRCreciproctc == 1) {
|
||||||
* Get the function and its derivatives from the
|
factor = 1 / factor;
|
||||||
* field in the instance structure. The field is
|
}
|
||||||
* an array of doubles holding the rhs, and the
|
|
||||||
* entries of the jacobian.
|
|
||||||
*/
|
|
||||||
|
|
||||||
j=0;
|
/*
|
||||||
derivs = here->ASRCacValues;
|
* Get the function and its derivatives from the
|
||||||
|
* field in the instance structure. The field is
|
||||||
|
* an array of doubles holding the rhs, and the
|
||||||
|
* entries of the jacobian.
|
||||||
|
*/
|
||||||
|
|
||||||
if( here->ASRCtype == ASRC_VOLTAGE) {
|
j = 0;
|
||||||
|
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;
|
||||||
*(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++) {
|
for (i = 0; i < here->ASRCtree->numVars; i++) {
|
||||||
switch(here->ASRCtree->varTypes[i]) {
|
switch (here->ASRCtree->varTypes[i]) {
|
||||||
case IF_INSTANCE:
|
case IF_INSTANCE:
|
||||||
if( here->ASRCtype == ASRC_VOLTAGE) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
/* CCVS */
|
/* CCVS */
|
||||||
*(here->ASRCposptr[j++]) -= derivs[i] / factor;
|
*(here->ASRCposptr[j++]) -= derivs[i] / factor;
|
||||||
} else{
|
} else {
|
||||||
/* CCCS */
|
/* 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;
|
break;
|
||||||
case IF_NODE:
|
case IF_NODE:
|
||||||
if(here->ASRCtype == ASRC_VOLTAGE) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
/* VCVS */
|
/* VCVS */
|
||||||
*(here->ASRCposptr[j++]) -= derivs[i] / factor;
|
*(here->ASRCposptr[j++]) -= derivs[i] / factor;
|
||||||
} else {
|
} else {
|
||||||
/* VCCS */
|
/* VCCS */
|
||||||
*(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;
|
break;
|
||||||
default:
|
default:
|
||||||
return(E_BADPARM);
|
return(E_BADPARM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(OK);
|
return(OK);
|
||||||
|
|
|
||||||
|
|
@ -24,49 +24,49 @@ Author: 1987 Kanwar Jit Singh
|
||||||
int
|
int
|
||||||
ASRCask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, IFvalue *select)
|
ASRCask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, IFvalue *select)
|
||||||
{
|
{
|
||||||
ASRCinstance *here = (ASRCinstance*)instPtr;
|
ASRCinstance *here = (ASRCinstance*) instPtr;
|
||||||
|
|
||||||
NG_IGNORE(select);
|
NG_IGNORE(select);
|
||||||
|
|
||||||
switch(which) {
|
switch(which) {
|
||||||
case ASRC_TEMP:
|
case ASRC_TEMP:
|
||||||
value->rValue = here->ASRCtemp - CONSTCtoK;
|
value->rValue = here->ASRCtemp - CONSTCtoK;
|
||||||
return(OK);
|
return(OK);
|
||||||
case ASRC_DTEMP:
|
case ASRC_DTEMP:
|
||||||
value->rValue = here->ASRCdtemp;
|
value->rValue = here->ASRCdtemp;
|
||||||
return(OK);
|
return(OK);
|
||||||
case ASRC_TC1:
|
case ASRC_TC1:
|
||||||
value->rValue = here->ASRCtc1;
|
value->rValue = here->ASRCtc1;
|
||||||
return(OK);
|
return(OK);
|
||||||
case ASRC_TC2:
|
case ASRC_TC2:
|
||||||
value->rValue = here->ASRCtc2;
|
value->rValue = here->ASRCtc2;
|
||||||
return(OK);
|
return(OK);
|
||||||
case ASRC_CURRENT:
|
case ASRC_CURRENT:
|
||||||
value->tValue = here->ASRCtype == ASRC_CURRENT ?
|
value->tValue = here->ASRCtype == ASRC_CURRENT ?
|
||||||
here->ASRCtree : NULL;
|
here->ASRCtree : NULL;
|
||||||
return (OK);
|
return(OK);
|
||||||
case ASRC_VOLTAGE:
|
case ASRC_VOLTAGE:
|
||||||
value->tValue = here->ASRCtype == ASRC_VOLTAGE ?
|
value->tValue = here->ASRCtype == ASRC_VOLTAGE ?
|
||||||
here->ASRCtree : NULL;
|
here->ASRCtree : NULL;
|
||||||
return (OK);
|
return(OK);
|
||||||
case ASRC_POS_NODE:
|
case ASRC_POS_NODE:
|
||||||
value->iValue = here->ASRCposNode;
|
value->iValue = here->ASRCposNode;
|
||||||
return (OK);
|
return(OK);
|
||||||
case ASRC_NEG_NODE:
|
case ASRC_NEG_NODE:
|
||||||
value->iValue = here->ASRCnegNode;
|
value->iValue = here->ASRCnegNode;
|
||||||
return (OK);
|
return(OK);
|
||||||
case ASRC_OUTPUTCURRENT:
|
case ASRC_OUTPUTCURRENT:
|
||||||
if( here->ASRCtype == ASRC_VOLTAGE)
|
if (here->ASRCtype == ASRC_VOLTAGE)
|
||||||
value->rValue = ckt->CKTrhsOld[here->ASRCbranch];
|
value->rValue = ckt->CKTrhsOld[here->ASRCbranch];
|
||||||
else
|
else
|
||||||
value->rValue = here->ASRCprev_value;
|
value->rValue = here->ASRCprev_value;
|
||||||
return (OK);
|
return(OK);
|
||||||
case ASRC_OUTPUTVOLTAGE:
|
case ASRC_OUTPUTVOLTAGE:
|
||||||
value->rValue = ckt->CKTrhsOld[here->ASRCposNode] -
|
value->rValue = ckt->CKTrhsOld[here->ASRCposNode] -
|
||||||
ckt->CKTrhsOld[here->ASRCnegNode];
|
ckt->CKTrhsOld[here->ASRCnegNode];
|
||||||
return(OK);
|
return(OK);
|
||||||
default:
|
default:
|
||||||
return (E_BADPARM);
|
return(E_BADPARM);
|
||||||
}
|
}
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,11 @@ Author: 1988 Kanwar Jit Singh
|
||||||
#include "ngspice/sperror.h"
|
#include "ngspice/sperror.h"
|
||||||
#include "ngspice/suffix.h"
|
#include "ngspice/suffix.h"
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt)
|
ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
{
|
{
|
||||||
ASRCmodel *model = (ASRCmodel *)inModel;
|
ASRCmodel *model = (ASRCmodel *) inModel;
|
||||||
ASRCinstance *here;
|
ASRCinstance *here;
|
||||||
int i, node_num, branch;
|
int i, node_num, branch;
|
||||||
double diff;
|
double diff;
|
||||||
|
|
@ -20,51 +21,53 @@ ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
double tol;
|
double tol;
|
||||||
double rhs;
|
double rhs;
|
||||||
|
|
||||||
for( ; model != NULL; model = model->ASRCnextModel) {
|
for (; model != NULL; model = model->ASRCnextModel) {
|
||||||
for( here = model->ASRCinstances; here != NULL;
|
for (here = model->ASRCinstances; here != NULL;
|
||||||
here = here->ASRCnextInstance) {
|
here = here->ASRCnextInstance) {
|
||||||
|
|
||||||
i = here->ASRCtree->numVars;
|
i = here->ASRCtree->numVars;
|
||||||
if (asrc_nvals < i) {
|
if (asrc_nvals < i) {
|
||||||
if (asrc_nvals) {
|
if (asrc_nvals) {
|
||||||
FREE(asrc_vals);
|
FREE(asrc_vals);
|
||||||
FREE(asrc_derivs);
|
FREE(asrc_derivs);
|
||||||
}
|
}
|
||||||
asrc_nvals = i;
|
asrc_nvals = i;
|
||||||
asrc_vals = NEWN(double, i);
|
asrc_vals = NEWN(double, i);
|
||||||
asrc_derivs = NEWN(double, i);
|
asrc_derivs = NEWN(double, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for( i=0; i < here->ASRCtree->numVars; i++){
|
for (i = 0; i < here->ASRCtree->numVars; i++) {
|
||||||
if( here->ASRCtree->varTypes[i] == IF_INSTANCE){
|
if (here->ASRCtree->varTypes[i] == IF_INSTANCE) {
|
||||||
branch = CKTfndBranch(ckt,here->ASRCtree->vars[i].uValue);
|
branch = CKTfndBranch(ckt, here->ASRCtree->vars[i].uValue);
|
||||||
asrc_vals[i] = *(ckt->CKTrhsOld+branch);
|
asrc_vals[i] = *(ckt->CKTrhsOld + branch);
|
||||||
} else {
|
} else {
|
||||||
node_num = here->ASRCtree->vars[i].nValue->number;
|
node_num = here->ASRCtree->vars[i].nValue->number;
|
||||||
asrc_vals[i] = *(ckt->CKTrhsOld+node_num);
|
asrc_vals[i] = *(ckt->CKTrhsOld + node_num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( here->ASRCtree->IFeval (here->ASRCtree, ckt->CKTgmin, &rhs,
|
if (here->ASRCtree->IFeval(here->ASRCtree, ckt->CKTgmin, &rhs,
|
||||||
asrc_vals,asrc_derivs) != OK)
|
asrc_vals, asrc_derivs) != OK)
|
||||||
return(E_BADPARM);
|
return(E_BADPARM);
|
||||||
|
|
||||||
prev = here->ASRCprev_value;
|
prev = here->ASRCprev_value;
|
||||||
diff = fabs( prev - rhs);
|
diff = fabs(prev - rhs);
|
||||||
if ( here->ASRCtype == ASRC_VOLTAGE){
|
|
||||||
tol = ckt->CKTreltol *
|
|
||||||
MAX(fabs(rhs),fabs(prev)) + ckt->CKTvoltTol;
|
|
||||||
} else {
|
|
||||||
tol = ckt->CKTreltol *
|
|
||||||
MAX(fabs(rhs),fabs(prev)) + ckt->CKTabstol;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( diff > tol) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
ckt->CKTnoncon++;
|
tol = ckt->CKTreltol *
|
||||||
ckt->CKTtroubleElt = (GENinstance *) here;
|
MAX(fabs(rhs), fabs(prev)) + ckt->CKTvoltTol;
|
||||||
return(OK);
|
} else {
|
||||||
}
|
tol = ckt->CKTreltol *
|
||||||
|
MAX(fabs(rhs), fabs(prev)) + ckt->CKTabstol;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diff > tol) {
|
||||||
|
ckt->CKTnoncon++;
|
||||||
|
ckt->CKTtroubleElt = (GENinstance *) here;
|
||||||
|
return(OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(OK);
|
return(OK);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,70 +10,77 @@ Author: 1985 Thomas L. Quarles
|
||||||
#include "ngspice/ifsim.h"
|
#include "ngspice/ifsim.h"
|
||||||
#include "ngspice/complex.h"
|
#include "ngspice/complex.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* structures to describe Arbitrary sources
|
* structures to describe Arbitrary sources
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* information to describe a single instance */
|
/* information to describe a single instance */
|
||||||
|
|
||||||
typedef struct sASRCinstance {
|
typedef struct sASRCinstance {
|
||||||
struct sASRCmodel *ARRCmodPtr; /* backpointer to model */
|
struct sASRCmodel *ARRCmodPtr; /* backpointer to model */
|
||||||
struct sASRCinstance *ASRCnextInstance; /* pointer to next instance of
|
struct sASRCinstance *ASRCnextInstance; /* pointer to next instance of
|
||||||
* current model */
|
* current model */
|
||||||
IFuid ASRCname; /* pointer to character string naming this instance */
|
IFuid ASRCname; /* pointer to character string naming this instance */
|
||||||
int ASRCstates; /* state info */
|
int ASRCstates; /* state info */
|
||||||
int ASRCposNode; /* number of positive node of source */
|
int ASRCposNode; /* number of positive node of source */
|
||||||
int ASRCnegNode; /* number of negative node of source */
|
int ASRCnegNode; /* number of negative node of source */
|
||||||
int ASRCtype; /* Whether source is voltage or current */
|
|
||||||
int ASRCbranch; /* number of branch equation added for v source */
|
|
||||||
IFparseTree *ASRCtree; /* The parse tree */
|
|
||||||
double ASRCtemp; /* temperature at which this resistor operates */
|
|
||||||
double ASRCdtemp; /* delta-temperature of a particular instance */
|
|
||||||
double ASRCtc1; /* first temperature coefficient of resistors */
|
|
||||||
double ASRCtc2; /* second temperature coefficient of resistors */
|
|
||||||
int ASRCreciproctc; /* Flag to calculate reciprocal temperature behaviour */
|
|
||||||
double **ASRCposptr; /* pointer to pointers of the elements
|
|
||||||
* in the sparce matrix */
|
|
||||||
double ASRCprev_value; /* Previous value for the convergence test */
|
|
||||||
double *ASRCacValues; /* Store rhs and derivatives for ac anal */
|
|
||||||
int ASRCcont_br; /* Temporary store for controlling current branch */
|
|
||||||
unsigned ASRCtempGiven : 1; /* indicates temperature specified */
|
|
||||||
unsigned ASRCdtempGiven : 1; /* indicates delta-temp specified */
|
|
||||||
unsigned ASRCtc1Given : 1; /* indicates tc1 parameter specified */
|
|
||||||
unsigned ASRCtc2Given : 1; /* indicates tc2 parameter specified */
|
|
||||||
unsigned ASRCreciproctcGiven : 1; /* indicates reciproctc flag parameter specified */
|
|
||||||
} ASRCinstance ;
|
|
||||||
|
|
||||||
#define ASRCvOld ASRCstates
|
int ASRCtype; /* Whether source is voltage or current */
|
||||||
#define ASRCcontVOld ASRCstates + 1
|
int ASRCbranch; /* number of branch equation added for v source */
|
||||||
|
IFparseTree *ASRCtree; /* The parse tree */
|
||||||
|
|
||||||
|
double ASRCtemp; /* temperature at which this resistor operates */
|
||||||
|
double ASRCdtemp; /* delta-temperature of a particular instance */
|
||||||
|
double ASRCtc1; /* first temperature coefficient of resistors */
|
||||||
|
double ASRCtc2; /* second temperature coefficient of resistors */
|
||||||
|
int ASRCreciproctc; /* Flag to calculate reciprocal temperature behaviour */
|
||||||
|
double **ASRCposptr; /* pointer to pointers of the elements
|
||||||
|
* in the sparce matrix */
|
||||||
|
double ASRCprev_value; /* Previous value for the convergence test */
|
||||||
|
double *ASRCacValues; /* Store rhs and derivatives for ac anal */
|
||||||
|
int ASRCcont_br; /* Temporary store for controlling current branch */
|
||||||
|
|
||||||
|
unsigned ASRCtempGiven : 1; /* indicates temperature specified */
|
||||||
|
unsigned ASRCdtempGiven : 1; /* indicates delta-temp specified */
|
||||||
|
unsigned ASRCtc1Given : 1; /* indicates tc1 parameter specified */
|
||||||
|
unsigned ASRCtc2Given : 1; /* indicates tc2 parameter specified */
|
||||||
|
unsigned ASRCreciproctcGiven : 1; /* indicates reciproctc flag parameter specified */
|
||||||
|
|
||||||
|
} ASRCinstance;
|
||||||
|
|
||||||
|
|
||||||
|
#define ASRCvOld ASRCstates
|
||||||
|
#define ASRCcontVOld ASRCstates + 1
|
||||||
|
|
||||||
/* per model data */
|
/* per model data */
|
||||||
|
|
||||||
typedef struct sASRCmodel { /* model structure for a source */
|
typedef struct sASRCmodel { /* model structure for a source */
|
||||||
int ASRCmodType; /* type index of this device */
|
int ASRCmodType; /* type index of this device */
|
||||||
struct sASRCmodel *ASRCnextModel; /* pointer to next possible model
|
struct sASRCmodel *ASRCnextModel; /* pointer to next possible model
|
||||||
*in linked list */
|
* in linked list */
|
||||||
ASRCinstance * ASRCinstances; /* pointer to list of instances
|
ASRCinstance *ASRCinstances; /* pointer to list of instances
|
||||||
* that have this model */
|
* that have this model */
|
||||||
IFuid ASRCmodName; /* pointer to character string naming this model */
|
IFuid ASRCmodName; /* pointer to character string naming this model */
|
||||||
|
|
||||||
/* --- end of generic struct GENmodel --- */
|
/* --- end of generic struct GENmodel --- */
|
||||||
|
|
||||||
} ASRCmodel;
|
} ASRCmodel;
|
||||||
|
|
||||||
|
|
||||||
/* device parameters */
|
/* device parameters */
|
||||||
#define ASRC_VOLTAGE 1
|
#define ASRC_VOLTAGE 1
|
||||||
#define ASRC_CURRENT 2
|
#define ASRC_CURRENT 2
|
||||||
#define ASRC_POS_NODE 3
|
#define ASRC_POS_NODE 3
|
||||||
#define ASRC_NEG_NODE 4
|
#define ASRC_NEG_NODE 4
|
||||||
#define ASRC_PARSE_TREE 5
|
#define ASRC_PARSE_TREE 5
|
||||||
#define ASRC_OUTPUTVOLTAGE 6
|
#define ASRC_OUTPUTVOLTAGE 6
|
||||||
#define ASRC_OUTPUTCURRENT 7
|
#define ASRC_OUTPUTCURRENT 7
|
||||||
#define ASRC_TEMP 8
|
#define ASRC_TEMP 8
|
||||||
#define ASRC_DTEMP 9
|
#define ASRC_DTEMP 9
|
||||||
#define ASRC_TC1 10
|
#define ASRC_TC1 10
|
||||||
#define ASRC_TC2 11
|
#define ASRC_TC2 11
|
||||||
#define ASRC_RTC 12
|
#define ASRC_RTC 12
|
||||||
|
|
||||||
/* module-wide variables */
|
/* module-wide variables */
|
||||||
|
|
||||||
|
|
@ -87,4 +94,5 @@ extern int asrc_nvals;
|
||||||
/* model questions */
|
/* model questions */
|
||||||
|
|
||||||
#include "asrcext.h"
|
#include "asrcext.h"
|
||||||
|
|
||||||
#endif /*ASRC*/
|
#endif /*ASRC*/
|
||||||
|
|
|
||||||
|
|
@ -14,24 +14,24 @@ Author: 1987 Kanwar Jit Singh
|
||||||
|
|
||||||
int
|
int
|
||||||
ASRCdelete(GENmodel *model, IFuid name, GENinstance **fast)
|
ASRCdelete(GENmodel *model, IFuid name, GENinstance **fast)
|
||||||
|
|
||||||
{
|
{
|
||||||
ASRCinstance **instPtr = (ASRCinstance**)fast;
|
ASRCinstance **instPtr = (ASRCinstance**) fast;
|
||||||
ASRCmodel *modPtr = (ASRCmodel*)model;
|
ASRCmodel *modPtr = (ASRCmodel*) model;
|
||||||
|
|
||||||
ASRCinstance **prev = NULL;
|
ASRCinstance **prev = NULL;
|
||||||
ASRCinstance *here;
|
ASRCinstance *here;
|
||||||
|
|
||||||
for( ; modPtr ; modPtr = modPtr->ASRCnextModel) {
|
for (; modPtr ; modPtr = modPtr->ASRCnextModel) {
|
||||||
prev = &(modPtr->ASRCinstances);
|
prev = &(modPtr->ASRCinstances);
|
||||||
for(here = *prev; here ; here = *prev) {
|
for (here = *prev; here ; here = *prev) {
|
||||||
if(here->ASRCname == name || (instPtr && here==*instPtr) ) {
|
if (here->ASRCname == name || (instPtr && here == *instPtr)) {
|
||||||
*prev= here->ASRCnextInstance;
|
*prev = here->ASRCnextInstance;
|
||||||
FREE(here);
|
FREE(here);
|
||||||
return(OK);
|
return(OK);
|
||||||
}
|
}
|
||||||
prev = &(here->ASRCnextInstance);
|
prev = &(here->ASRCnextInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(E_NODEV);
|
return(E_NODEV);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,27 +8,28 @@ Author: 1987 Kanwar Jit Singh
|
||||||
#include "ngspice/suffix.h"
|
#include "ngspice/suffix.h"
|
||||||
#include "ngspice/inpdefs.h"
|
#include "ngspice/inpdefs.h"
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ASRCdestroy(GENmodel **model)
|
ASRCdestroy(GENmodel **model)
|
||||||
|
|
||||||
{
|
{
|
||||||
ASRCmodel **start = (ASRCmodel**)model; /* starting model */
|
ASRCmodel **start = (ASRCmodel**) model; /* starting model */
|
||||||
ASRCinstance *here; /* current instance */
|
ASRCinstance *here; /* current instance */
|
||||||
ASRCinstance *next;
|
ASRCinstance *next;
|
||||||
ASRCmodel *mod = *start; /* current model */
|
ASRCmodel *mod = *start; /* current model */
|
||||||
ASRCmodel *nextmod;
|
ASRCmodel *nextmod;
|
||||||
|
|
||||||
for( ; mod ; mod = nextmod) {
|
for (; mod ; mod = nextmod) {
|
||||||
for(here = mod->ASRCinstances ; here ; here = next) {
|
for (here = mod->ASRCinstances; here; here = next) {
|
||||||
next = here->ASRCnextInstance;
|
next = here->ASRCnextInstance;
|
||||||
FREE(here->ASRCacValues);
|
FREE(here->ASRCacValues);
|
||||||
INPfreeTree(here->ASRCtree);
|
INPfreeTree(here->ASRCtree);
|
||||||
if(here->ASRCposptr)
|
if (here->ASRCposptr)
|
||||||
free(here->ASRCposptr);
|
free(here->ASRCposptr);
|
||||||
FREE(here);
|
FREE(here);
|
||||||
}
|
}
|
||||||
nextmod = mod->ASRCnextModel;
|
nextmod = mod->ASRCnextModel;
|
||||||
FREE(mod);
|
FREE(mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
*model = NULL;
|
*model = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,16 @@ Copyright 1990 Regents of the University of California. All rights reserved.
|
||||||
Author: 1985 Thomas L. Quarles
|
Author: 1985 Thomas L. Quarles
|
||||||
**********/
|
**********/
|
||||||
|
|
||||||
extern int ASRCask(CKTcircuit*,GENinstance *,int,IFvalue *,IFvalue*);
|
extern int ASRCask(CKTcircuit *, GENinstance *, int, IFvalue *, IFvalue*);
|
||||||
extern int ASRCconvTest(GENmodel *,CKTcircuit*);
|
extern int ASRCconvTest(GENmodel *, CKTcircuit *);
|
||||||
extern int ASRCdelete(GENmodel *,IFuid,GENinstance **);
|
extern int ASRCdelete(GENmodel *, IFuid, GENinstance **);
|
||||||
extern void ASRCdestroy(GENmodel**);
|
extern void ASRCdestroy(GENmodel **);
|
||||||
extern int ASRCfindBr(CKTcircuit *,GENmodel *,IFuid);
|
extern int ASRCfindBr(CKTcircuit *, GENmodel *, IFuid);
|
||||||
extern int ASRCload(GENmodel *,CKTcircuit*);
|
extern int ASRCload(GENmodel *, CKTcircuit *);
|
||||||
extern int ASRCmDelete(GENmodel**,IFuid,GENmodel*);
|
extern int ASRCmDelete(GENmodel **, IFuid, GENmodel *);
|
||||||
extern int ASRCparam(int,IFvalue*,GENinstance*,IFvalue*);
|
extern int ASRCparam(int, IFvalue *, GENinstance *, IFvalue *);
|
||||||
extern int ASRCpzLoad(GENmodel*,CKTcircuit*,SPcomplex*);
|
extern int ASRCpzLoad(GENmodel *, CKTcircuit *, SPcomplex *);
|
||||||
extern int ASRCacLoad(GENmodel*,CKTcircuit*);
|
extern int ASRCacLoad(GENmodel *, CKTcircuit *);
|
||||||
extern int ASRCsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*);
|
extern int ASRCsetup(SMPmatrix *, GENmodel *, CKTcircuit *, int *);
|
||||||
extern int ASRCunsetup(GENmodel*,CKTcircuit*);
|
extern int ASRCunsetup(GENmodel *, CKTcircuit *);
|
||||||
extern int ASRCtemp(GENmodel*,CKTcircuit*);
|
extern int ASRCtemp(GENmodel *, CKTcircuit *);
|
||||||
|
|
|
||||||
|
|
@ -18,22 +18,23 @@ int
|
||||||
ASRCfindBr(CKTcircuit *ckt, GENmodel *inputModel, IFuid name)
|
ASRCfindBr(CKTcircuit *ckt, GENmodel *inputModel, IFuid name)
|
||||||
{
|
{
|
||||||
ASRCinstance *here;
|
ASRCinstance *here;
|
||||||
ASRCmodel *model = (ASRCmodel*)inputModel;
|
ASRCmodel *model = (ASRCmodel*) inputModel;
|
||||||
int error;
|
int error;
|
||||||
CKTnode *tmp;
|
CKTnode *tmp;
|
||||||
|
|
||||||
for( ; model != NULL; model = model->ASRCnextModel) {
|
for (; model != NULL; model = model->ASRCnextModel) {
|
||||||
for (here = model->ASRCinstances; here != NULL;
|
for (here = model->ASRCinstances; here != NULL;
|
||||||
here = here->ASRCnextInstance) {
|
here = here->ASRCnextInstance) {
|
||||||
if(here->ASRCname == name) {
|
if (here->ASRCname == name) {
|
||||||
if(here->ASRCbranch == 0) {
|
if (here->ASRCbranch == 0) {
|
||||||
error = CKTmkCur(ckt,&tmp, here->ASRCname,"branch");
|
error = CKTmkCur(ckt, &tmp, here->ASRCname, "branch");
|
||||||
if(error) return(error);
|
if (error) return(error);
|
||||||
here->ASRCbranch = tmp->number;
|
here->ASRCbranch = tmp->number;
|
||||||
}
|
}
|
||||||
return(here->ASRCbranch);
|
return(here->ASRCbranch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,19 +9,19 @@
|
||||||
|
|
||||||
SPICEdev ASRCinfo = {
|
SPICEdev ASRCinfo = {
|
||||||
{
|
{
|
||||||
"ASRC",
|
"ASRC",
|
||||||
"Arbitrary Source ",
|
"Arbitrary Source ",
|
||||||
|
|
||||||
&ASRCnSize,
|
&ASRCnSize,
|
||||||
&ASRCnSize,
|
&ASRCnSize,
|
||||||
ASRCnames,
|
ASRCnames,
|
||||||
|
|
||||||
&ASRCpTSize,
|
&ASRCpTSize,
|
||||||
ASRCpTable,
|
ASRCpTable,
|
||||||
|
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
|
|
||||||
#ifdef XSPICE
|
#ifdef XSPICE
|
||||||
/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/
|
/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/
|
||||||
NULL, /* This is a SPICE device, it has no MIF info data */
|
NULL, /* This is a SPICE device, it has no MIF info data */
|
||||||
|
|
@ -35,46 +35,46 @@ SPICEdev ASRCinfo = {
|
||||||
0, /* This is a SPICE device, it has no MIF info data */
|
0, /* This is a SPICE device, it has no MIF info data */
|
||||||
NULL, /* This is a SPICE device, it has no MIF info data */
|
NULL, /* This is a SPICE device, it has no MIF info data */
|
||||||
/*--------------------------- End of SDB fix -------------------------*/
|
/*--------------------------- End of SDB fix -------------------------*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
DEV_DEFAULT
|
DEV_DEFAULT
|
||||||
},
|
},
|
||||||
|
|
||||||
/* DEVparam */ ASRCparam,
|
/* DEVparam */ ASRCparam,
|
||||||
/* DEVmodParam */ NULL,
|
/* DEVmodParam */ NULL,
|
||||||
/* DEVload */ ASRCload,
|
/* DEVload */ ASRCload,
|
||||||
/* DEVsetup */ ASRCsetup,
|
/* DEVsetup */ ASRCsetup,
|
||||||
/* DEVunsetup */ ASRCunsetup,
|
/* DEVunsetup */ ASRCunsetup,
|
||||||
/* DEVpzSetup */ ASRCsetup,
|
/* DEVpzSetup */ ASRCsetup,
|
||||||
/* DEVtemperature*/ ASRCtemp,
|
/* DEVtemperature*/ ASRCtemp,
|
||||||
/* DEVtrunc */ NULL,
|
/* DEVtrunc */ NULL,
|
||||||
/* DEVfindBranch */ ASRCfindBr,
|
/* DEVfindBranch */ ASRCfindBr,
|
||||||
/* DEVacLoad */ ASRCacLoad, /* ac and normal load functions NOT identical */
|
/* DEVacLoad */ ASRCacLoad, /* ac and normal load functions NOT identical */
|
||||||
/* DEVaccept */ NULL,
|
/* DEVaccept */ NULL,
|
||||||
/* DEVdestroy */ ASRCdestroy,
|
/* DEVdestroy */ ASRCdestroy,
|
||||||
/* DEVmodDelete */ ASRCmDelete,
|
/* DEVmodDelete */ ASRCmDelete,
|
||||||
/* DEVdelete */ ASRCdelete,
|
/* DEVdelete */ ASRCdelete,
|
||||||
/* DEVsetic */ NULL,
|
/* DEVsetic */ NULL,
|
||||||
/* DEVask */ ASRCask,
|
/* DEVask */ ASRCask,
|
||||||
/* DEVmodAsk */ NULL,
|
/* DEVmodAsk */ NULL,
|
||||||
/* DEVpzLoad */ ASRCpzLoad,
|
/* DEVpzLoad */ ASRCpzLoad,
|
||||||
/* DEVconvTest */ ASRCconvTest,
|
/* DEVconvTest */ ASRCconvTest,
|
||||||
/* DEVsenSetup */ NULL,
|
/* DEVsenSetup */ NULL,
|
||||||
/* DEVsenLoad */ NULL,
|
/* DEVsenLoad */ NULL,
|
||||||
/* DEVsenUpdate */ NULL,
|
/* DEVsenUpdate */ NULL,
|
||||||
/* DEVsenAcLoad */ NULL,
|
/* DEVsenAcLoad */ NULL,
|
||||||
/* DEVsenPrint */ NULL,
|
/* DEVsenPrint */ NULL,
|
||||||
/* DEVsenTrunc */ NULL,
|
/* DEVsenTrunc */ NULL,
|
||||||
/* DEVdisto */ NULL, /* DISTO */
|
/* DEVdisto */ NULL, /* DISTO */
|
||||||
/* DEVnoise */ NULL, /* NOISE */
|
/* DEVnoise */ NULL, /* NOISE */
|
||||||
/* DEVsoaCheck */ NULL,
|
/* DEVsoaCheck */ NULL,
|
||||||
#ifdef CIDER
|
#ifdef CIDER
|
||||||
/* DEVdump */ NULL,
|
/* DEVdump */ NULL,
|
||||||
/* DEVacct */ NULL,
|
/* DEVacct */ NULL,
|
||||||
#endif
|
#endif
|
||||||
/* DEVinstSize */ &ASRCiSize,
|
/* DEVinstSize */ &ASRCiSize,
|
||||||
/* DEVmodSize */ &ASRCmSize
|
/* DEVmodSize */ &ASRCmSize
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef _ASRCINIT_H
|
#ifndef _ASRCINIT_H
|
||||||
#define _ASRCINIT_H
|
#define _ASRCINIT_H
|
||||||
|
|
||||||
extern IFparm ASRCpTable[ ];
|
extern IFparm ASRCpTable[];
|
||||||
extern char *ASRCnames[ ];
|
extern char *ASRCnames[];
|
||||||
extern int ASRCpTSize;
|
extern int ASRCpTSize;
|
||||||
extern int ASRCnSize;
|
extern int ASRCnSize;
|
||||||
extern int ASRCiSize;
|
extern int ASRCiSize;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
/**********
|
/**********
|
||||||
Copyright 1990 Regents of the University of California. All rights reserved.
|
Copyright 1990 Regents of the University of California. All rights reserved.
|
||||||
**********/
|
**********/
|
||||||
|
|
||||||
#ifndef DEV_ASRC
|
#ifndef DEV_ASRC
|
||||||
#define DEV_ASRC
|
#define DEV_ASRC
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,15 @@ Author: 1987 Kanwar Jit Singh
|
||||||
#include "ngspice/sperror.h"
|
#include "ngspice/sperror.h"
|
||||||
#include "ngspice/suffix.h"
|
#include "ngspice/suffix.h"
|
||||||
|
|
||||||
|
|
||||||
double *asrc_vals, *asrc_derivs;
|
double *asrc_vals, *asrc_derivs;
|
||||||
int asrc_nvals;
|
int asrc_nvals;
|
||||||
|
|
||||||
|
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
int
|
int
|
||||||
ASRCload(GENmodel *inModel, CKTcircuit *ckt)
|
ASRCload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* actually load the current voltage value into the
|
/* actually load the current voltage value into the
|
||||||
* sparse matrix previously provided
|
* sparse matrix previously provided
|
||||||
*/
|
*/
|
||||||
|
|
@ -32,16 +33,17 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
double factor;
|
double factor;
|
||||||
|
|
||||||
/* loop through all the Arbitrary source models */
|
/* loop through all the Arbitrary source models */
|
||||||
for( ; model != NULL; model = model->ASRCnextModel ) {
|
for (; model != NULL; model = model->ASRCnextModel) {
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = model->ASRCinstances; here != NULL ;
|
for (here = model->ASRCinstances; here != NULL;
|
||||||
here=here->ASRCnextInstance)
|
here=here->ASRCnextInstance)
|
||||||
{
|
{
|
||||||
|
|
||||||
difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15;
|
difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15;
|
||||||
factor = 1.0 + (here->ASRCtc1)*difference + (here->ASRCtc2)*difference*difference;
|
factor = 1.0 + (here->ASRCtc1) * difference + (here->ASRCtc2) * difference * difference;
|
||||||
if(here->ASRCreciproctc == 1) {
|
|
||||||
factor = 1/factor;
|
if (here->ASRCreciproctc == 1) {
|
||||||
|
factor = 1 / factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -58,13 +60,13 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
asrc_derivs = NEWN(double, i);
|
asrc_derivs = NEWN(double, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
j=0;
|
j = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fill the vector of values from the previous solution
|
* Fill the vector of values from the previous solution
|
||||||
*/
|
*/
|
||||||
for( i=0; i < here->ASRCtree->numVars; i++)
|
for (i = 0; i < here->ASRCtree->numVars; i++)
|
||||||
if( here->ASRCtree->varTypes[i] == IF_INSTANCE) {
|
if (here->ASRCtree->varTypes[i] == IF_INSTANCE) {
|
||||||
int branch = CKTfndBranch(ckt, here->ASRCtree->vars[i].uValue);
|
int branch = CKTfndBranch(ckt, here->ASRCtree->vars[i].uValue);
|
||||||
asrc_vals[i] = *(ckt->CKTrhsOld + branch);
|
asrc_vals[i] = *(ckt->CKTrhsOld + branch);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -72,65 +74,62 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
asrc_vals[i] = *(ckt->CKTrhsOld + node_num);
|
asrc_vals[i] = *(ckt->CKTrhsOld + node_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (here->ASRCtree->IFeval (here->ASRCtree, ckt->CKTgmin, &rhs, asrc_vals, asrc_derivs) != OK)
|
if (here->ASRCtree->IFeval(here->ASRCtree, ckt->CKTgmin, &rhs, asrc_vals, asrc_derivs) != OK)
|
||||||
return(E_BADPARM);
|
return(E_BADPARM);
|
||||||
|
|
||||||
/* The convergence test */
|
/* The convergence test */
|
||||||
here->ASRCprev_value = rhs;
|
here->ASRCprev_value = rhs;
|
||||||
|
|
||||||
/* The ac load precomputation and storage */
|
/* The ac load precomputation and storage */
|
||||||
|
|
||||||
if (ckt->CKTmode & MODEINITSMSIG) {
|
if (ckt->CKTmode & MODEINITSMSIG) {
|
||||||
int size = (here->ASRCtree->numVars) + 1 ;
|
int size = (here->ASRCtree->numVars) + 1;
|
||||||
here->ASRCacValues = NEWN(double, size);
|
here->ASRCacValues = NEWN(double, size);
|
||||||
for ( i = 0; i < here->ASRCtree->numVars; i++)
|
for (i = 0; i < here->ASRCtree->numVars; i++)
|
||||||
here->ASRCacValues[i] = asrc_derivs[i];
|
here->ASRCacValues[i] = asrc_derivs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if( here->ASRCtype == ASRC_VOLTAGE) {
|
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;
|
||||||
*(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++) {
|
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]) {
|
switch (here->ASRCtree->varTypes[i]) {
|
||||||
case IF_INSTANCE:
|
case IF_INSTANCE:
|
||||||
if( here->ASRCtype == ASRC_VOLTAGE) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
/* CCVS */
|
/* CCVS */
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
|
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
|
||||||
} else{
|
} else {
|
||||||
/* CCCS */
|
/* 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;
|
break;
|
||||||
|
case IF_NODE:
|
||||||
case IF_NODE:
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
if(here->ASRCtype == ASRC_VOLTAGE) {
|
/* VCVS */
|
||||||
/* VCVS */
|
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
|
} else {
|
||||||
} else {
|
/* VCCS */
|
||||||
/* VCCS */
|
*(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;
|
||||||
break;
|
default:
|
||||||
|
return(E_BADPARM);
|
||||||
default:
|
|
||||||
return(E_BADPARM);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert the RHS */
|
/* Insert the RHS */
|
||||||
if( here->ASRCtype == ASRC_VOLTAGE) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
*(ckt->CKTrhs+(here->ASRCbranch)) += factor * rhs;
|
*(ckt->CKTrhs + (here->ASRCbranch)) += factor * rhs;
|
||||||
} else {
|
} else {
|
||||||
*(ckt->CKTrhs+(here->ASRCposNode)) -= factor * rhs;
|
*(ckt->CKTrhs + (here->ASRCposNode)) -= factor * rhs;
|
||||||
*(ckt->CKTrhs+(here->ASRCnegNode)) += factor * rhs;
|
*(ckt->CKTrhs + (here->ASRCnegNode)) += factor * rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Store the rhs for small signal analysis */
|
/* Store the rhs for small signal analysis */
|
||||||
|
|
|
||||||
|
|
@ -15,29 +15,32 @@ Author: 1987 Kanwar Jit Singh
|
||||||
int
|
int
|
||||||
ASRCmDelete(GENmodel **modList, IFuid modname, GENmodel *killModel)
|
ASRCmDelete(GENmodel **modList, IFuid modname, GENmodel *killModel)
|
||||||
{
|
{
|
||||||
|
ASRCmodel **model = (ASRCmodel**) modList;
|
||||||
ASRCmodel **model = (ASRCmodel**)modList;
|
ASRCmodel *modfast = (ASRCmodel*) killModel;
|
||||||
ASRCmodel *modfast = (ASRCmodel*)killModel;
|
|
||||||
ASRCinstance *here;
|
ASRCinstance *here;
|
||||||
ASRCinstance *prev = NULL;
|
ASRCinstance *prev = NULL;
|
||||||
ASRCmodel **oldmod;
|
ASRCmodel **oldmod;
|
||||||
|
|
||||||
oldmod = model;
|
oldmod = model;
|
||||||
for( ; *model ; model = &((*model)->ASRCnextModel)) {
|
for (; *model; model = &((*model)->ASRCnextModel)) {
|
||||||
if( (*model)->ASRCmodName == modname ||
|
if ((*model)->ASRCmodName == modname ||
|
||||||
(modfast && *model == modfast) ) goto delgot;
|
(modfast && *model == modfast)) goto delgot;
|
||||||
oldmod = model;
|
oldmod = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(E_NOMOD);
|
return(E_NOMOD);
|
||||||
|
|
||||||
delgot:
|
delgot:
|
||||||
|
|
||||||
*oldmod = (*model)->ASRCnextModel; /* cut deleted device out of list */
|
*oldmod = (*model)->ASRCnextModel; /* cut deleted device out of list */
|
||||||
for(here = (*model)->ASRCinstances ; here ; here = here->ASRCnextInstance) {
|
|
||||||
FREE(here->ASRCacValues);
|
for (here = (*model)->ASRCinstances; here; here = here->ASRCnextInstance) {
|
||||||
if(prev) FREE(prev);
|
FREE(here->ASRCacValues);
|
||||||
|
if (prev) FREE(prev);
|
||||||
prev = here;
|
prev = here;
|
||||||
}
|
}
|
||||||
if(prev) FREE(prev);
|
|
||||||
|
if (prev) FREE(prev);
|
||||||
FREE(*model);
|
FREE(*model);
|
||||||
return(OK);
|
return(OK);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,33 +17,34 @@ Author: 1987 Kanwar Jit Singh
|
||||||
int
|
int
|
||||||
ASRCparam(int param, IFvalue *value, GENinstance *fast, IFvalue *select)
|
ASRCparam(int param, IFvalue *value, GENinstance *fast, IFvalue *select)
|
||||||
{
|
{
|
||||||
ASRCinstance *here = (ASRCinstance*)fast;
|
ASRCinstance *here = (ASRCinstance*) fast;
|
||||||
|
|
||||||
NG_IGNORE(select);
|
NG_IGNORE(select);
|
||||||
|
|
||||||
switch(param) {
|
switch (param) {
|
||||||
case ASRC_VOLTAGE:
|
case ASRC_VOLTAGE:
|
||||||
here->ASRCtype = ASRC_VOLTAGE;
|
here->ASRCtype = ASRC_VOLTAGE;
|
||||||
here->ASRCtree = value->tValue;
|
here->ASRCtree = value->tValue;
|
||||||
break;
|
break;
|
||||||
case ASRC_CURRENT:
|
case ASRC_CURRENT:
|
||||||
here->ASRCtype = ASRC_CURRENT;
|
here->ASRCtype = ASRC_CURRENT;
|
||||||
here->ASRCtree = value->tValue;
|
here->ASRCtree = value->tValue;
|
||||||
break;
|
break;
|
||||||
case ASRC_TC1:
|
case ASRC_TC1:
|
||||||
here->ASRCtc1 = value->rValue;
|
here->ASRCtc1 = value->rValue;
|
||||||
here->ASRCtc1Given = TRUE;
|
here->ASRCtc1Given = TRUE;
|
||||||
break;
|
break;
|
||||||
case ASRC_TC2:
|
case ASRC_TC2:
|
||||||
here->ASRCtc2 = value->rValue;
|
here->ASRCtc2 = value->rValue;
|
||||||
here->ASRCtc2Given = TRUE;
|
here->ASRCtc2Given = TRUE;
|
||||||
break;
|
break;
|
||||||
case ASRC_RTC:
|
case ASRC_RTC:
|
||||||
here->ASRCreciproctc = value->iValue;
|
here->ASRCreciproctc = value->iValue;
|
||||||
here->ASRCreciproctcGiven = TRUE;
|
here->ASRCreciproctcGiven = TRUE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return(E_BADPARM);
|
return(E_BADPARM);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(OK);
|
return(OK);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,13 @@ Author: 1987 Kanwar Jit Singh
|
||||||
#include "ngspice/suffix.h"
|
#include "ngspice/suffix.h"
|
||||||
#include "ngspice/complex.h"
|
#include "ngspice/complex.h"
|
||||||
|
|
||||||
|
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
int
|
int
|
||||||
ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
||||||
|
/* actually load the current voltage value into the
|
||||||
/* actually load the current voltage value into the
|
* sparse matrix previously provided
|
||||||
* sparse matrix previously provided
|
*/
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
ASRCmodel *model = (ASRCmodel*) inModel;
|
ASRCmodel *model = (ASRCmodel*) inModel;
|
||||||
ASRCinstance *here;
|
ASRCinstance *here;
|
||||||
|
|
@ -28,18 +28,19 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
||||||
NG_IGNORE(s);
|
NG_IGNORE(s);
|
||||||
|
|
||||||
/* loop through all the Arbitrary source models */
|
/* loop through all the Arbitrary source models */
|
||||||
for( ; model != NULL; model = model->ASRCnextModel ) {
|
for (; model != NULL; model = model->ASRCnextModel) {
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = model->ASRCinstances; here != NULL ;
|
for (here = model->ASRCinstances; here != NULL;
|
||||||
here=here->ASRCnextInstance)
|
here = here->ASRCnextInstance)
|
||||||
{
|
{
|
||||||
difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15;
|
|
||||||
factor = 1.0 + (here->ASRCtc1)*difference +
|
difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15;
|
||||||
(here->ASRCtc2)*difference*difference;
|
factor = 1.0 + (here->ASRCtc1) * difference +
|
||||||
if(here->ASRCreciproctc == 1) {
|
(here->ASRCtc2) * difference * difference;
|
||||||
factor = 1/factor;
|
|
||||||
}
|
if (here->ASRCreciproctc == 1) {
|
||||||
|
factor = 1 / factor;
|
||||||
|
}
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
|
|
@ -56,30 +57,30 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill the vector of values from the previous solution */
|
/* Fill the vector of values from the previous solution */
|
||||||
for( i=0; i < here->ASRCtree->numVars; i++) {
|
for (i = 0; i < here->ASRCtree->numVars; i++) {
|
||||||
if( here->ASRCtree->varTypes[i] == IF_INSTANCE) {
|
if (here->ASRCtree->varTypes[i] == IF_INSTANCE) {
|
||||||
int branch = CKTfndBranch(ckt,here->ASRCtree->vars[i].uValue);
|
int branch = CKTfndBranch(ckt, here->ASRCtree->vars[i].uValue);
|
||||||
asrc_vals[i] = *(ckt->CKTrhsOld + branch);
|
asrc_vals[i] = *(ckt->CKTrhsOld + branch);
|
||||||
} else {
|
} else {
|
||||||
int node_num = (here->ASRCtree->vars[i].nValue) -> number;
|
int node_num = (here->ASRCtree->vars[i].nValue) -> number;
|
||||||
asrc_vals[i] = *(ckt->CKTrhsOld + node_num);
|
asrc_vals[i] = *(ckt->CKTrhsOld + node_num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(here->ASRCtree->IFeval (here->ASRCtree, ckt->CKTgmin, &value, asrc_vals, asrc_derivs) != OK)
|
if (here->ASRCtree->IFeval(here->ASRCtree, ckt->CKTgmin, &value, asrc_vals, asrc_derivs) != OK)
|
||||||
return(E_BADPARM);
|
return(E_BADPARM);
|
||||||
|
|
||||||
if( here->ASRCtype == ASRC_VOLTAGE) {
|
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;
|
||||||
*(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++) {
|
for (i = 0; i < here->ASRCtree->numVars; i++) {
|
||||||
switch(here->ASRCtree->varTypes[i]) {
|
switch (here->ASRCtree->varTypes[i]) {
|
||||||
case IF_INSTANCE:
|
case IF_INSTANCE:
|
||||||
if( here->ASRCtype == ASRC_VOLTAGE) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
/* CCVS */
|
/* CCVS */
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor;
|
*(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -89,7 +90,7 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IF_NODE:
|
case IF_NODE:
|
||||||
if(here->ASRCtype == ASRC_VOLTAGE) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
/* VCVS */
|
/* VCVS */
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor;
|
*(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,12 @@ Author: 1987 Kanwar Jit Singh
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
int
|
int
|
||||||
ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
/* load the voltage source structure with those
|
/* load the voltage source structure with those
|
||||||
* pointers needed later for fast matrix loading
|
* pointers needed later for fast matrix loading
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
ASRCinstance *here;
|
ASRCinstance *here;
|
||||||
ASRCmodel *model = (ASRCmodel*)inModel;
|
ASRCmodel *model = (ASRCmodel*) inModel;
|
||||||
int error, i, j;
|
int error, i, j;
|
||||||
int v_first;
|
int v_first;
|
||||||
CKTnode *tmp;
|
CKTnode *tmp;
|
||||||
|
|
@ -30,103 +29,103 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
NG_IGNORE(states);
|
NG_IGNORE(states);
|
||||||
|
|
||||||
/* loop through all the user models*/
|
/* loop through all the user models*/
|
||||||
for( ; model != NULL; model = model->ASRCnextModel ) {
|
for (; model != NULL; model = model->ASRCnextModel) {
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = model->ASRCinstances; here != NULL ;
|
for (here = model->ASRCinstances; here != NULL;
|
||||||
here=here->ASRCnextInstance) {
|
here=here->ASRCnextInstance) {
|
||||||
|
|
||||||
if(!here->ASRCtc1Given) here->ASRCtc1 = 0.0;
|
if (!here->ASRCtc1Given) here->ASRCtc1 = 0.0;
|
||||||
if(!here->ASRCtc2Given) here->ASRCtc2 = 0.0;
|
if (!here->ASRCtc2Given) here->ASRCtc2 = 0.0;
|
||||||
if(!here->ASRCreciproctcGiven) here->ASRCreciproctc = 0;
|
if (!here->ASRCreciproctcGiven) here->ASRCreciproctc = 0;
|
||||||
|
|
||||||
here->ASRCposptr = NULL;
|
here->ASRCposptr = NULL;
|
||||||
j=0; /*strchr of the array holding ptrs to SMP */
|
j = 0; /* strchr of the array holding ptrs to SMP */
|
||||||
v_first = 1;
|
v_first = 1;
|
||||||
if( here->ASRCtype == ASRC_VOLTAGE){
|
|
||||||
if(here->ASRCbranch==0) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
error = CKTmkCur(ckt,&tmp,here->ASRCname,"branch");
|
if (here->ASRCbranch == 0) {
|
||||||
if(error) return(error);
|
error = CKTmkCur(ckt, &tmp, here->ASRCname, "branch");
|
||||||
|
if (error) return(error);
|
||||||
here->ASRCbranch = tmp->number;
|
here->ASRCbranch = tmp->number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* macro to make elements with built in test for out of memory */
|
/* macro to make elements with built in test for out of memory */
|
||||||
#define TSTALLOC(ptr,first,second) \
|
#define TSTALLOC(ptr, first, second) \
|
||||||
do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\
|
do { if ((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL) { \
|
||||||
return(E_NOMEM);\
|
return(E_NOMEM); \
|
||||||
} } while(0)
|
} } while(0)
|
||||||
|
|
||||||
#define MY_TSTALLOC(ptr,first,second) \
|
#define MY_TSTALLOC(ptr, first, second) \
|
||||||
do { if((here->ptr = SMPmakeElt(matrix, here->first, (second)->number)) == NULL){\
|
do { if ((here->ptr = SMPmakeElt(matrix, here->first, (second)->number)) == NULL) { \
|
||||||
return(E_NOMEM);\
|
return(E_NOMEM); \
|
||||||
} } while(0)
|
} } while(0)
|
||||||
|
|
||||||
/* For each controlling variable set the entries
|
/* For each controlling variable set the entries
|
||||||
in the vector of the positions of the SMP */
|
in the vector of the positions of the SMP */
|
||||||
if (!here->ASRCtree)
|
if (!here->ASRCtree)
|
||||||
return E_PARMVAL;
|
return E_PARMVAL;
|
||||||
|
|
||||||
if( here->ASRCtype == ASRC_VOLTAGE) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
|
|
||||||
if(here->ASRCposNode == here->ASRCnegNode) {
|
if (here->ASRCposNode == here->ASRCnegNode) {
|
||||||
SPfrontEnd->IFerrorf (ERR_FATAL,
|
SPfrontEnd->IFerrorf(ERR_FATAL,
|
||||||
"instance %s is a shorted ASRC", here->ASRCname);
|
"instance %s is a shorted ASRC", here->ASRCname);
|
||||||
return(E_UNSUPP);
|
return(E_UNSUPP);
|
||||||
}
|
}
|
||||||
|
|
||||||
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 5);
|
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 5);
|
||||||
TSTALLOC(ASRCposptr[j++],ASRCposNode,ASRCbranch);
|
|
||||||
TSTALLOC(ASRCposptr[j++],ASRCnegNode,ASRCbranch);
|
TSTALLOC(ASRCposptr[j++], ASRCposNode, ASRCbranch);
|
||||||
TSTALLOC(ASRCposptr[j++],ASRCbranch,ASRCnegNode);
|
TSTALLOC(ASRCposptr[j++], ASRCnegNode, ASRCbranch);
|
||||||
TSTALLOC(ASRCposptr[j++],ASRCbranch,ASRCposNode);
|
TSTALLOC(ASRCposptr[j++], ASRCbranch, ASRCnegNode);
|
||||||
}
|
TSTALLOC(ASRCposptr[j++], ASRCbranch, ASRCposNode);
|
||||||
|
}
|
||||||
for( i=0; i < here->ASRCtree->numVars; i++){
|
|
||||||
switch(here->ASRCtree->varTypes[i]){
|
for (i = 0; i < here->ASRCtree->numVars; i++) {
|
||||||
|
switch (here->ASRCtree->varTypes[i]) {
|
||||||
case IF_INSTANCE:
|
case IF_INSTANCE:
|
||||||
here->ASRCcont_br = CKTfndBranch(ckt,
|
here->ASRCcont_br = CKTfndBranch(ckt,
|
||||||
here->ASRCtree->vars[i].uValue);
|
here->ASRCtree->vars[i].uValue);
|
||||||
if(here->ASRCcont_br == 0) {
|
if (here->ASRCcont_br == 0) {
|
||||||
SPfrontEnd->IFerrorf (ERR_FATAL,
|
SPfrontEnd->IFerrorf (ERR_FATAL,
|
||||||
"%s: unknown controlling source %s", here->ASRCname, here->ASRCtree->vars[i].uValue);
|
"%s: unknown controlling source %s", here->ASRCname, here->ASRCtree->vars[i].uValue);
|
||||||
return(E_BADPARM);
|
return(E_BADPARM);
|
||||||
}
|
}
|
||||||
if( here->ASRCtype == ASRC_VOLTAGE){
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
/* CCVS */
|
/* CCVS */
|
||||||
if(v_first){
|
if (v_first) {
|
||||||
TSTALLOC(ASRCposptr[j++],ASRCbranch,ASRCcont_br);
|
TSTALLOC(ASRCposptr[j++], ASRCbranch, ASRCcont_br);
|
||||||
v_first = 0;
|
v_first = 0;
|
||||||
} else{
|
} else {
|
||||||
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1);
|
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1);
|
||||||
TSTALLOC(ASRCposptr[j++],ASRCbranch,ASRCcont_br);
|
TSTALLOC(ASRCposptr[j++], ASRCbranch, ASRCcont_br);
|
||||||
}
|
}
|
||||||
} else if(here->ASRCtype == ASRC_CURRENT){
|
} else if (here->ASRCtype == ASRC_CURRENT) {
|
||||||
/* CCCS */
|
/* CCCS */
|
||||||
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 2);
|
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 2);
|
||||||
TSTALLOC(ASRCposptr[j++],ASRCposNode,ASRCcont_br);
|
TSTALLOC(ASRCposptr[j++], ASRCposNode, ASRCcont_br);
|
||||||
TSTALLOC(ASRCposptr[j++],ASRCnegNode,ASRCcont_br);
|
TSTALLOC(ASRCposptr[j++], ASRCnegNode, ASRCcont_br);
|
||||||
} else{
|
} else {
|
||||||
return (E_BADPARM);
|
return (E_BADPARM);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IF_NODE:
|
case IF_NODE:
|
||||||
if( here->ASRCtype == ASRC_VOLTAGE){
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
/* VCVS */
|
/* VCVS */
|
||||||
if(v_first){
|
if (v_first) {
|
||||||
MY_TSTALLOC(ASRCposptr[j++],ASRCbranch,here->ASRCtree->vars[i].nValue);
|
MY_TSTALLOC(ASRCposptr[j++], ASRCbranch, here->ASRCtree->vars[i].nValue);
|
||||||
v_first = 0;
|
v_first = 0;
|
||||||
} else{
|
} else {
|
||||||
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1);
|
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1);
|
||||||
MY_TSTALLOC(ASRCposptr[j++],ASRCbranch,here->ASRCtree->vars[i].nValue);
|
MY_TSTALLOC(ASRCposptr[j++], ASRCbranch, here->ASRCtree->vars[i].nValue);
|
||||||
}
|
}
|
||||||
} else if(here->ASRCtype == ASRC_CURRENT){
|
} else if (here->ASRCtype == ASRC_CURRENT) {
|
||||||
/* VCCS */
|
/* VCCS */
|
||||||
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 2);
|
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 2);
|
||||||
MY_TSTALLOC(ASRCposptr[j++],ASRCposNode,here->ASRCtree->vars[i].nValue);
|
MY_TSTALLOC(ASRCposptr[j++], ASRCposNode, here->ASRCtree->vars[i].nValue);
|
||||||
MY_TSTALLOC(ASRCposptr[j++],ASRCnegNode,here->ASRCtree->vars[i].nValue);
|
MY_TSTALLOC(ASRCposptr[j++], ASRCnegNode, here->ASRCtree->vars[i].nValue);
|
||||||
} else{
|
} else {
|
||||||
return (E_BADPARM);
|
return (E_BADPARM);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -136,9 +135,11 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, (second)->number)) == NULL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(OK);
|
return(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ASRCunsetup(
|
ASRCunsetup(
|
||||||
GENmodel *inModel,
|
GENmodel *inModel,
|
||||||
|
|
@ -147,17 +148,18 @@ ASRCunsetup(
|
||||||
ASRCmodel *model;
|
ASRCmodel *model;
|
||||||
ASRCinstance *here;
|
ASRCinstance *here;
|
||||||
|
|
||||||
for (model = (ASRCmodel *)inModel; model != NULL;
|
for (model = (ASRCmodel *) inModel; model != NULL;
|
||||||
model = model->ASRCnextModel)
|
model = model->ASRCnextModel)
|
||||||
{
|
{
|
||||||
for (here = model->ASRCinstances; here != NULL;
|
for (here = model->ASRCinstances; here != NULL;
|
||||||
here=here->ASRCnextInstance)
|
here = here->ASRCnextInstance)
|
||||||
{
|
{
|
||||||
if (here->ASRCbranch) {
|
if (here->ASRCbranch) {
|
||||||
CKTdltNNum(ckt, here->ASRCbranch);
|
CKTdltNNum(ckt, here->ASRCbranch);
|
||||||
here->ASRCbranch = 0;
|
here->ASRCbranch = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,31 +8,32 @@ Author: 1985 Thomas L. Quarles
|
||||||
#include "asrcdefs.h"
|
#include "asrcdefs.h"
|
||||||
#include "ngspice/sperror.h"
|
#include "ngspice/sperror.h"
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ASRCtemp(GENmodel *inModel, CKTcircuit *ckt)
|
ASRCtemp(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
{
|
{
|
||||||
ASRCmodel *model = (ASRCmodel *)inModel;
|
ASRCmodel *model = (ASRCmodel *) inModel;
|
||||||
ASRCinstance *here;
|
ASRCinstance *here;
|
||||||
|
|
||||||
/* loop through all the source models */
|
/* loop through all the source models */
|
||||||
for( ; model != NULL; model = model->ASRCnextModel ) {
|
for (; model != NULL; model = model->ASRCnextModel) {
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = model->ASRCinstances; here != NULL ;
|
for (here = model->ASRCinstances; here != NULL;
|
||||||
here=here->ASRCnextInstance) {
|
here = here->ASRCnextInstance) {
|
||||||
|
|
||||||
/* Default Value Processing for Source Instance */
|
/* Default Value Processing for Source Instance */
|
||||||
|
|
||||||
if(!here->ASRCtempGiven) {
|
if (!here->ASRCtempGiven) {
|
||||||
here->ASRCtemp = ckt->CKTtemp;
|
here->ASRCtemp = ckt->CKTtemp;
|
||||||
if(!here->ASRCdtempGiven) here->ASRCdtemp = 0.0;
|
if (!here->ASRCdtempGiven) here->ASRCdtemp = 0.0;
|
||||||
} else { /* ASRCtempGiven */
|
} else { /* ASRCtempGiven */
|
||||||
here->ASRCdtemp = 0.0;
|
here->ASRCdtemp = 0.0;
|
||||||
if (here->ASRCdtempGiven)
|
if (here->ASRCdtempGiven)
|
||||||
printf("%s: Instance temperature specified, dtemp ignored\n", here->ASRCname);
|
printf("%s: Instance temperature specified, dtemp ignored\n", here->ASRCname);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(OK);
|
return(OK);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue