devices/asrc, cleanup #2/9, whitespace

This commit is contained in:
rlar 2015-04-11 21:25:22 +02:00
parent df147cd8b8
commit 2cb727476f
18 changed files with 483 additions and 460 deletions

View File

@ -9,27 +9,30 @@ 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 ASRCnSize = NUMELEMS(ASRCnames);
int ASRCpTSize = NUMELEMS(ASRCpTable); int ASRCpTSize = NUMELEMS(ASRCpTable);
int ASRCmPTSize = 0; int ASRCmPTSize = 0;

View File

@ -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,17 +33,17 @@ 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) {
factor = 1 / factor;
} }
/* /*
@ -54,30 +53,30 @@ ASRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
* entries of the jacobian. * entries of the jacobian.
*/ */
j=0; j = 0;
derivs = here->ASRCacValues; derivs = here->ASRCacValues;
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++]) -= 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 {

View File

@ -24,7 +24,7 @@ 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);
@ -44,29 +44,29 @@ ASRCask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, IFvalu
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 */
} }

View File

@ -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,8 +21,8 @@ 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;
@ -35,36 +36,38 @@ ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt)
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){
if (here->ASRCtype == ASRC_VOLTAGE) {
tol = ckt->CKTreltol * tol = ckt->CKTreltol *
MAX(fabs(rhs),fabs(prev)) + ckt->CKTvoltTol; MAX(fabs(rhs), fabs(prev)) + ckt->CKTvoltTol;
} else { } else {
tol = ckt->CKTreltol * tol = ckt->CKTreltol *
MAX(fabs(rhs),fabs(prev)) + ckt->CKTabstol; MAX(fabs(rhs), fabs(prev)) + ckt->CKTabstol;
} }
if ( diff > tol) { if (diff > tol) {
ckt->CKTnoncon++; ckt->CKTnoncon++;
ckt->CKTtroubleElt = (GENinstance *) here; ckt->CKTtroubleElt = (GENinstance *) here;
return(OK); return(OK);
} }
} }
} }
return(OK); return(OK);
} }

View File

@ -10,9 +10,10 @@ 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 */
@ -24,9 +25,11 @@ typedef struct sASRCinstance {
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 ASRCtype; /* Whether source is voltage or current */
int ASRCbranch; /* number of branch equation added for v source */ int ASRCbranch; /* number of branch equation added for v source */
IFparseTree *ASRCtree; /* The parse tree */ IFparseTree *ASRCtree; /* The parse tree */
double ASRCtemp; /* temperature at which this resistor operates */ double ASRCtemp; /* temperature at which this resistor operates */
double ASRCdtemp; /* delta-temperature of a particular instance */ double ASRCdtemp; /* delta-temperature of a particular instance */
double ASRCtc1; /* first temperature coefficient of resistors */ double ASRCtc1; /* first temperature coefficient of resistors */
@ -37,12 +40,15 @@ typedef struct sASRCinstance {
double ASRCprev_value; /* Previous value for the convergence test */ double ASRCprev_value; /* Previous value for the convergence test */
double *ASRCacValues; /* Store rhs and derivatives for ac anal */ double *ASRCacValues; /* Store rhs and derivatives for ac anal */
int ASRCcont_br; /* Temporary store for controlling current branch */ int ASRCcont_br; /* Temporary store for controlling current branch */
unsigned ASRCtempGiven : 1; /* indicates temperature specified */ unsigned ASRCtempGiven : 1; /* indicates temperature specified */
unsigned ASRCdtempGiven : 1; /* indicates delta-temp specified */ unsigned ASRCdtempGiven : 1; /* indicates delta-temp specified */
unsigned ASRCtc1Given : 1; /* indicates tc1 parameter specified */ unsigned ASRCtc1Given : 1; /* indicates tc1 parameter specified */
unsigned ASRCtc2Given : 1; /* indicates tc2 parameter specified */ unsigned ASRCtc2Given : 1; /* indicates tc2 parameter specified */
unsigned ASRCreciproctcGiven : 1; /* indicates reciproctc flag parameter specified */ unsigned ASRCreciproctcGiven : 1; /* indicates reciproctc flag parameter specified */
} ASRCinstance ;
} ASRCinstance;
#define ASRCvOld ASRCstates #define ASRCvOld ASRCstates
#define ASRCcontVOld ASRCstates + 1 #define ASRCcontVOld ASRCstates + 1
@ -52,8 +58,8 @@ typedef struct sASRCinstance {
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 */
@ -61,6 +67,7 @@ typedef struct sASRCmodel { /* model structure for a source */
} ASRCmodel; } ASRCmodel;
/* device parameters */ /* device parameters */
#define ASRC_VOLTAGE 1 #define ASRC_VOLTAGE 1
#define ASRC_CURRENT 2 #define ASRC_CURRENT 2
@ -87,4 +94,5 @@ extern int asrc_nvals;
/* model questions */ /* model questions */
#include "asrcext.h" #include "asrcext.h"
#endif /*ASRC*/ #endif /*ASRC*/

View File

@ -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);
} }

View File

@ -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;
} }

View File

@ -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 *);

View File

@ -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);
} }

View File

@ -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;

View File

@ -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

View File

@ -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,45 +74,43 @@ 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 {
@ -119,18 +119,17 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt)
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor; *(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
} }
break; break;
default: default:
return(E_BADPARM); 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 */

View File

@ -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) {
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);
} }

View File

@ -17,11 +17,11 @@ 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;
@ -45,5 +45,6 @@ ASRCparam(int param, IFvalue *value, GENinstance *fast, IFvalue *select)
default: default:
return(E_BADPARM); return(E_BADPARM);
} }
return(OK); return(OK);
} }

View File

@ -10,11 +10,11 @@ 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
*/ */
{ {
@ -28,17 +28,18 @@ 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; 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) {
factor = 1 / factor;
} }
j = 0; j = 0;
@ -56,9 +57,9 @@ 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;
@ -66,20 +67,20 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
} }
} }
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 {

View File

@ -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++){ 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", 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,11 +148,11 @@ 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);
@ -159,5 +160,6 @@ ASRCunsetup(
} }
} }
} }
return OK; return OK;
} }

View File

@ -8,24 +8,24 @@ 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)
@ -34,5 +34,6 @@ ASRCtemp(GENmodel *inModel, CKTcircuit *ckt)
} }
} }
return(OK); return(OK);
} }