devices/asrc, cleanup #6/9, cleanup

This commit is contained in:
rlar 2015-04-11 21:27:01 +02:00
parent bd5ac3e4fc
commit 036a45f348
10 changed files with 52 additions and 57 deletions

View File

@ -15,8 +15,7 @@ IFparm ASRCpTable[] = { /* parameters */
IP("i", ASRC_CURRENT, IF_PARSETREE, "Current source"),
IP("v", ASRC_VOLTAGE, IF_PARSETREE, "Voltage source"),
IOPZU("temp", ASRC_TEMP, IF_REAL, "Instance operating temperature"),
IOPZ("dtemp", ASRC_DTEMP, IF_REAL,
"Instance temperature difference with the rest of the circuit"),
IOPZ("dtemp", ASRC_DTEMP, IF_REAL, "Instance temperature difference with the rest of the circuit"),
IOPU("tc1", ASRC_TC1, IF_REAL, "First 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"),

View File

@ -29,12 +29,12 @@ ASRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
NG_IGNORE(ckt);
for (; model; model = model->ASRCnextModel) {
for (here = model->ASRCinstances; here;
here = here->ASRCnextInstance) {
for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) {
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;

View File

@ -38,12 +38,12 @@ ASRCask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, IFvalu
value->rValue = here->ASRCtc2;
return(OK);
case ASRC_CURRENT:
value->tValue = here->ASRCtype == ASRC_CURRENT ?
here->ASRCtree : NULL;
value->tValue =
(here->ASRCtype == ASRC_CURRENT) ? here->ASRCtree : NULL;
return(OK);
case ASRC_VOLTAGE:
value->tValue = here->ASRCtype == ASRC_VOLTAGE ?
here->ASRCtree : NULL;
value->tValue =
(here->ASRCtype == ASRC_VOLTAGE) ? here->ASRCtree : NULL;
return(OK);
case ASRC_POS_NODE:
value->iValue = here->ASRCposNode;
@ -58,7 +58,8 @@ ASRCask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, IFvalu
value->rValue = here->ASRCprev_value;
return(OK);
case ASRC_OUTPUTVOLTAGE:
value->rValue = ckt->CKTrhsOld[here->ASRCposNode] -
value->rValue =
ckt->CKTrhsOld[here->ASRCposNode] -
ckt->CKTrhsOld[here->ASRCnegNode];
return(OK);
default:

View File

@ -22,8 +22,7 @@ ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt)
double rhs;
for (; model; model = model->ASRCnextModel) {
for (here = model->ASRCinstances; here;
here = here->ASRCnextInstance) {
for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) {
i = here->ASRCtree->numVars;
if (asrc_nvals < i) {
@ -54,11 +53,11 @@ ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt)
diff = fabs(prev - rhs);
if (here->ASRCtype == ASRC_VOLTAGE) {
tol = ckt->CKTreltol *
MAX(fabs(rhs), fabs(prev)) + ckt->CKTvoltTol;
tol = ckt->CKTreltol * MAX(fabs(rhs), fabs(prev))
+ ckt->CKTvoltTol;
} else {
tol = ckt->CKTreltol *
MAX(fabs(rhs), fabs(prev)) + ckt->CKTabstol;
tol = ckt->CKTreltol * MAX(fabs(rhs), fabs(prev))
+ ckt->CKTabstol;
}
if (diff > tol) {

View File

@ -20,12 +20,12 @@ ASRCfindBr(CKTcircuit *ckt, GENmodel *inputModel, IFuid name)
CKTnode *tmp;
for (; model; model = model->ASRCnextModel) {
for (here = model->ASRCinstances; here;
here = here->ASRCnextInstance) {
for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) {
if (here->ASRCname == name) {
if (here->ASRCbranch == 0) {
error = CKTmkCur(ckt, &tmp, here->ASRCname, "branch");
if (error) return(error);
if (error)
return(error);
here->ASRCbranch = tmp->number;
}
return(here->ASRCbranch);

View File

@ -29,12 +29,12 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt)
double factor;
for (; model; model = model->ASRCnextModel) {
for (here = model->ASRCinstances; here;
here=here->ASRCnextInstance)
{
for (here = model->ASRCinstances; here; here=here->ASRCnextInstance) {
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;

View File

@ -20,8 +20,8 @@ ASRCmDelete(GENmodel **modList, IFuid modname, GENmodel *killModel)
oldmod = model;
for (; *model; model = &((*model)->ASRCnextModel)) {
if ((*model)->ASRCmodName == modname ||
(modfast && *model == modfast)) goto delgot;
if ((*model)->ASRCmodName == modname || (modfast && *model == modfast))
goto delgot;
oldmod = model;
}
@ -33,11 +33,13 @@ ASRCmDelete(GENmodel **modList, IFuid modname, GENmodel *killModel)
for (here = (*model)->ASRCinstances; here; here = here->ASRCnextInstance) {
FREE(here->ASRCacValues);
if (prev) FREE(prev);
if (prev)
FREE(prev);
prev = here;
}
if (prev) FREE(prev);
if (prev)
FREE(prev);
FREE(*model);
return(OK);
}

View File

@ -28,13 +28,12 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
NG_IGNORE(s);
for (; model; model = model->ASRCnextModel) {
for (here = model->ASRCinstances; here;
here = here->ASRCnextInstance)
{
for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) {
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;

View File

@ -26,12 +26,14 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
NG_IGNORE(states);
for (; model; model = model->ASRCnextModel) {
for (here = model->ASRCinstances; here;
here=here->ASRCnextInstance) {
for (here = model->ASRCinstances; here; here=here->ASRCnextInstance) {
if (!here->ASRCtc1Given) here->ASRCtc1 = 0.0;
if (!here->ASRCtc2Given) here->ASRCtc2 = 0.0;
if (!here->ASRCreciproctcGiven) here->ASRCreciproctc = 0;
if (!here->ASRCtc1Given)
here->ASRCtc1 = 0.0;
if (!here->ASRCtc2Given)
here->ASRCtc2 = 0.0;
if (!here->ASRCreciproctcGiven)
here->ASRCreciproctc = 0;
here->ASRCposptr = NULL;
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->ASRCbranch == 0) {
error = CKTmkCur(ckt, &tmp, here->ASRCname, "branch");
if (error) return(error);
if (error)
return(error);
here->ASRCbranch = tmp->number;
}
}
@ -64,8 +67,7 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
if (here->ASRCtype == ASRC_VOLTAGE) {
if (here->ASRCposNode == here->ASRCnegNode) {
SPfrontEnd->IFerrorf(ERR_FATAL,
"instance %s is a shorted ASRC", here->ASRCname);
SPfrontEnd->IFerrorf(ERR_FATAL, "instance %s is a shorted ASRC", here->ASRCname);
return(E_UNSUPP);
}
@ -80,11 +82,10 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
for (i = 0; i < here->ASRCtree->numVars; i++) {
switch (here->ASRCtree->varTypes[i]) {
case IF_INSTANCE:
here->ASRCcont_br = CKTfndBranch(ckt,
here->ASRCtree->vars[i].uValue);
here->ASRCcont_br = CKTfndBranch(ckt, here->ASRCtree->vars[i].uValue);
if (here->ASRCcont_br == 0) {
SPfrontEnd->IFerrorf (ERR_FATAL,
"%s: unknown controlling source %s", here->ASRCname, here->ASRCtree->vars[i].uValue);
SPfrontEnd->IFerrorf(ERR_FATAL, "%s: unknown controlling source %s",
here->ASRCname, here->ASRCtree->vars[i].uValue);
return(E_BADPARM);
}
if (here->ASRCtype == ASRC_VOLTAGE) {
@ -136,19 +137,13 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
int
ASRCunsetup(
GENmodel *inModel,
CKTcircuit *ckt)
ASRCunsetup(GENmodel *inModel, CKTcircuit *ckt)
{
ASRCmodel *model = (ASRCmodel *) inModel;
ASRCinstance *here;
for (; model;
model = model->ASRCnextModel)
{
for (here = model->ASRCinstances; here;
here = here->ASRCnextInstance)
{
for (; model; model = model->ASRCnextModel) {
for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) {
if (here->ASRCbranch) {
CKTdltNNum(ckt, here->ASRCbranch);
here->ASRCbranch = 0;

View File

@ -16,14 +16,14 @@ ASRCtemp(GENmodel *inModel, CKTcircuit *ckt)
ASRCinstance *here;
for (; model; model = model->ASRCnextModel) {
for (here = model->ASRCinstances; here;
here = here->ASRCnextInstance) {
for (here = model->ASRCinstances; here; here = here->ASRCnextInstance) {
/* Default Value Processing for Source Instance */
if (!here->ASRCtempGiven) {
here->ASRCtemp = ckt->CKTtemp;
if (!here->ASRCdtempGiven) here->ASRCdtemp = 0.0;
if (!here->ASRCdtempGiven)
here->ASRCdtemp = 0.0;
} else {
here->ASRCdtemp = 0.0;
if (here->ASRCdtempGiven)