devices/asrc, cleanup #8/9, cleanup parentheses and braces

This commit is contained in:
rlar 2015-04-11 21:28:52 +02:00
parent 39a25ba114
commit 21ff522441
6 changed files with 20 additions and 32 deletions

View File

@ -33,12 +33,11 @@ ASRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15;
factor = 1.0
+ (here->ASRCtc1) * difference
+ (here->ASRCtc2) * difference * difference;
+ here->ASRCtc1 * difference
+ here->ASRCtc2 * difference * difference;
if (here->ASRCreciproctc == 1) {
if (here->ASRCreciproctc == 1)
factor = 1 / factor;
}
/*
* Get the function and its derivatives from the

View File

@ -35,7 +35,7 @@ ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt)
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) {
branch = CKTfndBranch(ckt, here->ASRCtree->vars[i].uValue);
asrc_vals[i] = ckt->CKTrhsOld[branch];
@ -43,7 +43,6 @@ ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt)
node_num = here->ASRCtree->vars[i].nValue->number;
asrc_vals[i] = ckt->CKTrhsOld[node_num];
}
}
if (here->ASRCtree->IFeval(here->ASRCtree, ckt->CKTgmin, &rhs,
asrc_vals, asrc_derivs) != OK)
@ -52,13 +51,12 @@ ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt)
prev = here->ASRCprev_value;
diff = fabs(prev - rhs);
if (here->ASRCtype == ASRC_VOLTAGE) {
if (here->ASRCtype == ASRC_VOLTAGE)
tol = ckt->CKTreltol * MAX(fabs(rhs), fabs(prev))
+ ckt->CKTvoltTol;
} else {
else
tol = ckt->CKTreltol * MAX(fabs(rhs), fabs(prev))
+ ckt->CKTabstol;
}
if (diff > tol) {
ckt->CKTnoncon++;

View File

@ -19,8 +19,8 @@ ASRCfindBr(CKTcircuit *ckt, GENmodel *inputModel, IFuid name)
int error;
CKTnode *tmp;
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->ASRCname == name) {
if (here->ASRCbranch == 0) {
error = CKTmkCur(ckt, &tmp, here->ASRCname, "branch");
@ -30,8 +30,6 @@ ASRCfindBr(CKTcircuit *ckt, GENmodel *inputModel, IFuid name)
}
return(here->ASRCbranch);
}
}
}
return(0);
}

View File

@ -33,12 +33,11 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt)
difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15;
factor = 1.0
+ (here->ASRCtc1) * difference
+ (here->ASRCtc2) * difference * difference;
+ here->ASRCtc1 * difference
+ here->ASRCtc2 * difference * difference;
if (here->ASRCreciproctc == 1) {
if (here->ASRCreciproctc == 1)
factor = 1 / factor;
}
/*
* Get the function and its derivatives evaluated
@ -76,7 +75,7 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt)
/* The ac load precomputation and storage */
if (ckt->CKTmode & MODEINITSMSIG) {
int size = (here->ASRCtree->numVars) + 1;
int size = here->ASRCtree->numVars + 1;
here->ASRCacValues = NEWN(double, size);
for (i = 0; i < here->ASRCtree->numVars; i++)
here->ASRCacValues[i] = asrc_derivs[i];
@ -127,9 +126,8 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt)
}
/* Store the rhs for small signal analysis */
if (ckt->CKTmode & MODEINITSMSIG) {
if (ckt->CKTmode & MODEINITSMSIG)
here->ASRCacValues[here->ASRCtree->numVars] = factor * rhs;
}
}
}

View File

@ -32,12 +32,11 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15;
factor = 1.0
+ (here->ASRCtc1) * difference
+ (here->ASRCtc2) * difference * difference;
+ here->ASRCtc1 * difference
+ here->ASRCtc2 * difference * difference;
if (here->ASRCreciproctc == 1) {
if (here->ASRCreciproctc == 1)
factor = 1 / factor;
}
j = 0;
@ -54,7 +53,7 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
}
/* 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) {
int branch = CKTfndBranch(ckt, here->ASRCtree->vars[i].uValue);
asrc_vals[i] = *(ckt->CKTrhsOld + branch);
@ -62,7 +61,6 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
int node_num = (here->ASRCtree->vars[i].nValue) -> number;
asrc_vals[i] = *(ckt->CKTrhsOld + node_num);
}
}
if (here->ASRCtree->IFeval(here->ASRCtree, ckt->CKTgmin, &value, asrc_vals, asrc_derivs) != OK)
return(E_BADPARM);

View File

@ -39,14 +39,13 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
j = 0; /* strchr of the array holding ptrs to SMP */
v_first = 1;
if (here->ASRCtype == ASRC_VOLTAGE) {
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) \
@ -142,14 +141,12 @@ 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;
}
}
}
return OK;
}