devices/asrc, cleanup #6/9, cleanup
This commit is contained in:
parent
bd5ac3e4fc
commit
036a45f348
|
|
@ -15,8 +15,7 @@ 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"),
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,12 @@ ASRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
NG_IGNORE(ckt);
|
NG_IGNORE(ckt);
|
||||||
|
|
||||||
for (; model; model = model->ASRCnextModel) {
|
for (; model; model = model->ASRCnextModel) {
|
||||||
for (here = model->ASRCinstances; here;
|
for (here = model->ASRCinstances; here; 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->ASRCtc2) * difference * difference;
|
+ (here->ASRCtc1) * difference
|
||||||
|
+ (here->ASRCtc2) * difference * difference;
|
||||||
|
|
||||||
if (here->ASRCreciproctc == 1) {
|
if (here->ASRCreciproctc == 1) {
|
||||||
factor = 1 / factor;
|
factor = 1 / factor;
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,12 @@ ASRCask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, IFvalu
|
||||||
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->ASRCtree : NULL;
|
(here->ASRCtype == ASRC_CURRENT) ? here->ASRCtree : NULL;
|
||||||
return(OK);
|
return(OK);
|
||||||
case ASRC_VOLTAGE:
|
case ASRC_VOLTAGE:
|
||||||
value->tValue = here->ASRCtype == ASRC_VOLTAGE ?
|
value->tValue =
|
||||||
here->ASRCtree : NULL;
|
(here->ASRCtype == ASRC_VOLTAGE) ? here->ASRCtree : NULL;
|
||||||
return(OK);
|
return(OK);
|
||||||
case ASRC_POS_NODE:
|
case ASRC_POS_NODE:
|
||||||
value->iValue = here->ASRCposNode;
|
value->iValue = here->ASRCposNode;
|
||||||
|
|
@ -58,7 +58,8 @@ ASRCask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, IFvalu
|
||||||
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:
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,7 @@ ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
double rhs;
|
double rhs;
|
||||||
|
|
||||||
for (; model; model = model->ASRCnextModel) {
|
for (; model; model = model->ASRCnextModel) {
|
||||||
for (here = model->ASRCinstances; here;
|
for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) {
|
||||||
here = here->ASRCnextInstance) {
|
|
||||||
|
|
||||||
i = here->ASRCtree->numVars;
|
i = here->ASRCtree->numVars;
|
||||||
if (asrc_nvals < i) {
|
if (asrc_nvals < i) {
|
||||||
|
|
@ -54,11 +53,11 @@ ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
diff = fabs(prev - rhs);
|
diff = fabs(prev - rhs);
|
||||||
|
|
||||||
if (here->ASRCtype == ASRC_VOLTAGE) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
tol = ckt->CKTreltol *
|
tol = ckt->CKTreltol * MAX(fabs(rhs), fabs(prev))
|
||||||
MAX(fabs(rhs), fabs(prev)) + ckt->CKTvoltTol;
|
+ ckt->CKTvoltTol;
|
||||||
} else {
|
} else {
|
||||||
tol = ckt->CKTreltol *
|
tol = ckt->CKTreltol * MAX(fabs(rhs), fabs(prev))
|
||||||
MAX(fabs(rhs), fabs(prev)) + ckt->CKTabstol;
|
+ ckt->CKTabstol;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diff > tol) {
|
if (diff > tol) {
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@ ASRCfindBr(CKTcircuit *ckt, GENmodel *inputModel, IFuid name)
|
||||||
CKTnode *tmp;
|
CKTnode *tmp;
|
||||||
|
|
||||||
for (; model; model = model->ASRCnextModel) {
|
for (; model; model = model->ASRCnextModel) {
|
||||||
for (here = model->ASRCinstances; here;
|
for (here = model->ASRCinstances; here; 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);
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,12 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
double factor;
|
double factor;
|
||||||
|
|
||||||
for (; model; model = model->ASRCnextModel) {
|
for (; model; model = model->ASRCnextModel) {
|
||||||
for (here = model->ASRCinstances; here;
|
for (here = model->ASRCinstances; here; 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) {
|
if (here->ASRCreciproctc == 1) {
|
||||||
factor = 1 / factor;
|
factor = 1 / factor;
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ ASRCmDelete(GENmodel **modList, IFuid modname, GENmodel *killModel)
|
||||||
|
|
||||||
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))
|
||||||
(modfast && *model == modfast)) goto delgot;
|
goto delgot;
|
||||||
oldmod = model;
|
oldmod = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,11 +33,13 @@ ASRCmDelete(GENmodel **modList, IFuid modname, GENmodel *killModel)
|
||||||
|
|
||||||
for (here = (*model)->ASRCinstances; here; here = here->ASRCnextInstance) {
|
for (here = (*model)->ASRCinstances; here; here = here->ASRCnextInstance) {
|
||||||
FREE(here->ASRCacValues);
|
FREE(here->ASRCacValues);
|
||||||
if (prev) FREE(prev);
|
if (prev)
|
||||||
|
FREE(prev);
|
||||||
prev = here;
|
prev = here;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev) FREE(prev);
|
if (prev)
|
||||||
|
FREE(prev);
|
||||||
FREE(*model);
|
FREE(*model);
|
||||||
return(OK);
|
return(OK);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,13 +28,12 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
||||||
NG_IGNORE(s);
|
NG_IGNORE(s);
|
||||||
|
|
||||||
for (; model; model = model->ASRCnextModel) {
|
for (; model; model = model->ASRCnextModel) {
|
||||||
for (here = model->ASRCinstances; here;
|
for (here = model->ASRCinstances; here; 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->ASRCtc2) * difference * difference;
|
+ (here->ASRCtc1) * difference
|
||||||
|
+ (here->ASRCtc2) * difference * difference;
|
||||||
|
|
||||||
if (here->ASRCreciproctc == 1) {
|
if (here->ASRCreciproctc == 1) {
|
||||||
factor = 1 / factor;
|
factor = 1 / factor;
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,14 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
NG_IGNORE(states);
|
NG_IGNORE(states);
|
||||||
|
|
||||||
for (; model; model = model->ASRCnextModel) {
|
for (; model; model = model->ASRCnextModel) {
|
||||||
for (here = model->ASRCinstances; here;
|
for (here = model->ASRCinstances; here; here=here->ASRCnextInstance) {
|
||||||
here=here->ASRCnextInstance) {
|
|
||||||
|
|
||||||
if (!here->ASRCtc1Given) here->ASRCtc1 = 0.0;
|
if (!here->ASRCtc1Given)
|
||||||
if (!here->ASRCtc2Given) here->ASRCtc2 = 0.0;
|
here->ASRCtc1 = 0.0;
|
||||||
if (!here->ASRCreciproctcGiven) here->ASRCreciproctc = 0;
|
if (!here->ASRCtc2Given)
|
||||||
|
here->ASRCtc2 = 0.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 */
|
||||||
|
|
@ -40,7 +42,8 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
if (here->ASRCtype == ASRC_VOLTAGE) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -64,8 +67,7 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,11 +82,10 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
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:
|
||||||
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",
|
||||||
"%s: unknown controlling source %s", here->ASRCname, here->ASRCtree->vars[i].uValue);
|
here->ASRCname, here->ASRCtree->vars[i].uValue);
|
||||||
return(E_BADPARM);
|
return(E_BADPARM);
|
||||||
}
|
}
|
||||||
if (here->ASRCtype == ASRC_VOLTAGE) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
|
|
@ -136,19 +137,13 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ASRCunsetup(
|
ASRCunsetup(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
GENmodel *inModel,
|
|
||||||
CKTcircuit *ckt)
|
|
||||||
{
|
{
|
||||||
ASRCmodel *model = (ASRCmodel *) inModel;
|
ASRCmodel *model = (ASRCmodel *) inModel;
|
||||||
ASRCinstance *here;
|
ASRCinstance *here;
|
||||||
|
|
||||||
for (; model;
|
for (; model; model = model->ASRCnextModel) {
|
||||||
model = model->ASRCnextModel)
|
for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) {
|
||||||
{
|
|
||||||
for (here = model->ASRCinstances; here;
|
|
||||||
here = here->ASRCnextInstance)
|
|
||||||
{
|
|
||||||
if (here->ASRCbranch) {
|
if (here->ASRCbranch) {
|
||||||
CKTdltNNum(ckt, here->ASRCbranch);
|
CKTdltNNum(ckt, here->ASRCbranch);
|
||||||
here->ASRCbranch = 0;
|
here->ASRCbranch = 0;
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,14 @@ ASRCtemp(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
ASRCinstance *here;
|
ASRCinstance *here;
|
||||||
|
|
||||||
for (; model; model = model->ASRCnextModel) {
|
for (; model; model = model->ASRCnextModel) {
|
||||||
for (here = model->ASRCinstances; here;
|
for (here = model->ASRCinstances; here; 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 {
|
} else {
|
||||||
here->ASRCdtemp = 0.0;
|
here->ASRCdtemp = 0.0;
|
||||||
if (here->ASRCdtempGiven)
|
if (here->ASRCdtempGiven)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue