Add temperature coefficients for B sources
This commit is contained in:
parent
1a7fa85e3c
commit
d9561123f9
|
|
@ -1,3 +1,9 @@
|
||||||
|
2012-02-11 Dietmar Warning
|
||||||
|
* src/spicelib/devices/asrc/*.c,*.h,Makefile.am
|
||||||
|
* src/frontend/inpcom.c,
|
||||||
|
* vngspice.vcproj
|
||||||
|
Add temperature coefficients for B sources
|
||||||
|
|
||||||
2012-02-11 Holger Vogt
|
2012-02-11 Holger Vogt
|
||||||
* inpcom.c: Robert's patch, reading libs, incs etc.
|
* inpcom.c: Robert's patch, reading libs, incs etc.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4871,10 +4871,11 @@ static void inp_bsource_compat(struct line *deck)
|
||||||
}
|
}
|
||||||
buf[i] = '\0';
|
buf[i] = '\0';
|
||||||
/* no parens {} around time, hertz, temper, the constants
|
/* no parens {} around time, hertz, temper, the constants
|
||||||
pi and e which are defined in inpptree.c and around pwl */
|
pi and e which are defined in inpptree.c, around pwl and temp. coeffs */
|
||||||
if ((*str_ptr == '(') || cieq(buf, "hertz") || cieq(buf, "temper")
|
if ((*str_ptr == '(') || cieq(buf, "hertz") || cieq(buf, "temper")
|
||||||
|| cieq(buf, "time") || cieq(buf, "pi") || cieq(buf, "e")
|
|| cieq(buf, "time") || cieq(buf, "pi") || cieq(buf, "e")
|
||||||
|| cieq(buf, "pwl")) {
|
|| cieq(buf, "pwl")
|
||||||
|
|| cieq(buf, "tc") || cieq(buf, "tc1") || cieq(buf, "tc2")) {
|
||||||
/* special handling of pwl lines:
|
/* special handling of pwl lines:
|
||||||
Put braces around tokens and around expressions, use ','
|
Put braces around tokens and around expressions, use ','
|
||||||
as separator like:
|
as separator like:
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ libasrc_la_SOURCES = \
|
||||||
asrcmdel.c \
|
asrcmdel.c \
|
||||||
asrcpar.c \
|
asrcpar.c \
|
||||||
asrcpzld.c \
|
asrcpzld.c \
|
||||||
asrcset.c
|
asrcset.c \
|
||||||
|
asrctemp.c
|
||||||
|
|
||||||
|
|
||||||
AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include
|
AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,14 @@ Author: 1987 Kanwar Jit Singh
|
||||||
|
|
||||||
/* 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"),
|
||||||
OP( "i", ASRC_OUTPUTCURRENT, IF_REAL, "Current through 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"),
|
||||||
|
IOPU( "tc1", ASRC_TC1, IF_REAL, "First order temp. coefficient"),
|
||||||
|
IOPU( "tc2", ASRC_TC2, IF_REAL, "Second order temp. coefficient"),
|
||||||
|
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")
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ ASRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
int i, j;
|
int i, j;
|
||||||
double *derivs;
|
double *derivs;
|
||||||
double rhs;
|
double rhs;
|
||||||
|
double difference;
|
||||||
|
double factor;
|
||||||
|
|
||||||
NG_IGNORE(ckt);
|
NG_IGNORE(ckt);
|
||||||
|
|
||||||
|
|
@ -42,6 +44,13 @@ ASRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
if (here->ASRCowner != ARCHme)
|
if (here->ASRCowner != ARCHme)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if(!here->ASRCtc1Given) here->ASRCtc1 = 0.0;
|
||||||
|
if(!here->ASRCtc2Given) here->ASRCtc2 = 0.0;
|
||||||
|
|
||||||
|
difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15;
|
||||||
|
factor = 1.0 + (here->ASRCtc1)*difference +
|
||||||
|
(here->ASRCtc2)*difference*difference;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the function and its derivatives from the
|
* Get the function and its derivatives from the
|
||||||
* field in the instance structure. The field is
|
* field in the instance structure. The field is
|
||||||
|
|
@ -65,21 +74,21 @@ ASRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
case IF_INSTANCE:
|
case IF_INSTANCE:
|
||||||
if( here->ASRCtype == ASRC_VOLTAGE) {
|
if( here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
/* CCVS */
|
/* CCVS */
|
||||||
*(here->ASRCposptr[j++]) -= derivs[i];
|
*(here->ASRCposptr[j++]) -= derivs[i] / factor;
|
||||||
} else{
|
} else{
|
||||||
/* CCCS */
|
/* CCCS */
|
||||||
*(here->ASRCposptr[j++]) += derivs[i];
|
*(here->ASRCposptr[j++]) += derivs[i] / factor;
|
||||||
*(here->ASRCposptr[j++]) -= derivs[i];
|
*(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];
|
*(here->ASRCposptr[j++]) -= derivs[i] / factor;
|
||||||
} else {
|
} else {
|
||||||
/*VCCS*/
|
/* VCCS */
|
||||||
*(here->ASRCposptr[j++]) += derivs[i];
|
*(here->ASRCposptr[j++]) += derivs[i] / factor;
|
||||||
*(here->ASRCposptr[j++]) -= derivs[i];
|
*(here->ASRCposptr[j++]) -= derivs[i] / factor;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -29,13 +29,25 @@ ASRCask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, IFvalu
|
||||||
NG_IGNORE(select);
|
NG_IGNORE(select);
|
||||||
|
|
||||||
switch(which) {
|
switch(which) {
|
||||||
|
case ASRC_TEMP:
|
||||||
|
value->rValue = here->ASRCtemp - CONSTCtoK;
|
||||||
|
return(OK);
|
||||||
|
case ASRC_DTEMP:
|
||||||
|
value->rValue = here->ASRCdtemp;
|
||||||
|
return(OK);
|
||||||
|
case ASRC_TC1:
|
||||||
|
value->rValue = here->ASRCtc1;
|
||||||
|
return(OK);
|
||||||
|
case ASRC_TC2:
|
||||||
|
value->rValue = here->ASRCtc2;
|
||||||
|
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;
|
||||||
|
|
@ -44,12 +56,12 @@ ASRCask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, IFvalu
|
||||||
value->iValue = here->ASRCnegNode;
|
value->iValue = here->ASRCnegNode;
|
||||||
return (OK);
|
return (OK);
|
||||||
case ASRC_OUTPUTCURRENT:
|
case ASRC_OUTPUTCURRENT:
|
||||||
value->rValue = ckt->CKTrhsOld[here->ASRCbranch];
|
value->rValue = ckt->CKTrhsOld[here->ASRCbranch];
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,34 +6,41 @@ Author: 1985 Thomas L. Quarles
|
||||||
#ifndef ASRC
|
#ifndef ASRC
|
||||||
#define ASRC
|
#define ASRC
|
||||||
|
|
||||||
|
|
||||||
#include "ngspice/cktdefs.h"
|
#include "ngspice/cktdefs.h"
|
||||||
#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 ASRCowner; /* number of owner process */
|
int ASRCowner; /* number of owner process */
|
||||||
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 ASRCdtemp; /* delta-temperature of a particular instance */
|
||||||
|
double ASRCtc1; /* first temperature coefficient of resistors */
|
||||||
|
double ASRCtc2; /* second temperature coefficient of resistors */
|
||||||
double **ASRCposptr; /* pointer to pointers of the elements
|
double **ASRCposptr; /* pointer to pointers of the elements
|
||||||
* in the sparce matrix */
|
* in the sparce matrix */
|
||||||
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 ASRCdtempGiven : 1; /* indicates delta-temp specified */
|
||||||
|
unsigned ASRCtc1Given : 1; /* indicates tc1 parameter specified */
|
||||||
|
unsigned ASRCtc2Given : 1; /* indicates tc2 parameter specified */
|
||||||
|
|
||||||
} ASRCinstance ;
|
} ASRCinstance ;
|
||||||
|
|
||||||
|
|
@ -59,6 +66,10 @@ typedef struct sASRCmodel { /* model structure for a source */
|
||||||
#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_DTEMP 9
|
||||||
|
#define ASRC_TC1 10
|
||||||
|
#define ASRC_TC2 11
|
||||||
|
|
||||||
/* module-wide variables */
|
/* module-wide variables */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,4 @@ 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*);
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ SPICEdev ASRCinfo = {
|
||||||
/* DEVsetup */ ASRCsetup,
|
/* DEVsetup */ ASRCsetup,
|
||||||
/* DEVunsetup */ ASRCunsetup,
|
/* DEVunsetup */ ASRCunsetup,
|
||||||
/* DEVpzSetup */ ASRCsetup,
|
/* DEVpzSetup */ ASRCsetup,
|
||||||
/* DEVtemperature*/ NULL,
|
/* 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 */
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ Author: 1987 Kanwar Jit Singh
|
||||||
#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
|
||||||
|
|
@ -28,109 +28,117 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
ASRCinstance *here;
|
ASRCinstance *here;
|
||||||
int i, j;
|
int i, j;
|
||||||
double rhs;
|
double rhs;
|
||||||
|
double difference;
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
if (here->ASRCowner != ARCHme)
|
if (here->ASRCowner != ARCHme)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
if(!here->ASRCtc1Given) here->ASRCtc1 = 0.0;
|
||||||
* Get the function and its derivatives evaluated
|
if(!here->ASRCtc2Given) here->ASRCtc2 = 0.0;
|
||||||
*/
|
|
||||||
i = here->ASRCtree->numVars;
|
|
||||||
if (asrc_nvals < i) {
|
|
||||||
if (asrc_nvals) {
|
|
||||||
FREE(asrc_vals);
|
|
||||||
FREE(asrc_derivs);
|
|
||||||
}
|
|
||||||
asrc_nvals = i;
|
|
||||||
asrc_vals = NEWN(double, i);
|
|
||||||
asrc_derivs = NEWN(double, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
j=0;
|
difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15;
|
||||||
|
factor = 1.0 + (here->ASRCtc1)*difference + (here->ASRCtc2)*difference*difference;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fill the vector of values from the previous solution
|
* Get the function and its derivatives evaluated
|
||||||
*/
|
*/
|
||||||
for( i=0; i < here->ASRCtree->numVars; i++)
|
i = here->ASRCtree->numVars;
|
||||||
if( here->ASRCtree->varTypes[i] == IF_INSTANCE) {
|
if (asrc_nvals < i) {
|
||||||
int branch = CKTfndBranch(ckt, here->ASRCtree->vars[i].uValue);
|
if (asrc_nvals) {
|
||||||
asrc_vals[i] = *(ckt->CKTrhsOld + branch);
|
FREE(asrc_vals);
|
||||||
} else {
|
FREE(asrc_derivs);
|
||||||
int node_num = (here->ASRCtree->vars[i].nValue) -> number;
|
}
|
||||||
asrc_vals[i] = *(ckt->CKTrhsOld + node_num);
|
asrc_nvals = i;
|
||||||
}
|
asrc_vals = NEWN(double, i);
|
||||||
|
asrc_derivs = NEWN(double, i);
|
||||||
if (here->ASRCtree->IFeval (here->ASRCtree, ckt->CKTgmin, &rhs, asrc_vals, asrc_derivs) != OK)
|
|
||||||
return(E_BADPARM);
|
|
||||||
|
|
||||||
/* The convergence test */
|
|
||||||
here->ASRCprev_value = rhs;
|
|
||||||
|
|
||||||
/* The ac load precomputation and storage */
|
|
||||||
|
|
||||||
if (ckt->CKTmode & MODEINITSMSIG) {
|
|
||||||
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];
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0; i < here->ASRCtree->numVars; i++) {
|
j=0;
|
||||||
rhs -= (asrc_vals[i] * asrc_derivs[i]);
|
|
||||||
|
|
||||||
switch(here->ASRCtree->varTypes[i]) {
|
/*
|
||||||
case IF_INSTANCE:
|
* Fill the vector of values from the previous solution
|
||||||
if( here->ASRCtype == ASRC_VOLTAGE) {
|
*/
|
||||||
/* CCVS */
|
for( i=0; i < here->ASRCtree->numVars; i++)
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i];
|
if( here->ASRCtree->varTypes[i] == IF_INSTANCE) {
|
||||||
} else{
|
int branch = CKTfndBranch(ckt, here->ASRCtree->vars[i].uValue);
|
||||||
/* CCCS */
|
asrc_vals[i] = *(ckt->CKTrhsOld + branch);
|
||||||
*(here->ASRCposptr[j++]) += asrc_derivs[i];
|
} else {
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i];
|
int node_num = (here->ASRCtree->vars[i].nValue) -> number;
|
||||||
}
|
asrc_vals[i] = *(ckt->CKTrhsOld + node_num);
|
||||||
break;
|
}
|
||||||
|
|
||||||
case IF_NODE:
|
if (here->ASRCtree->IFeval (here->ASRCtree, ckt->CKTgmin, &rhs, asrc_vals, asrc_derivs) != OK)
|
||||||
if(here->ASRCtype == ASRC_VOLTAGE) {
|
return(E_BADPARM);
|
||||||
/* VCVS */
|
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i];
|
|
||||||
} else {
|
|
||||||
/*VCCS*/
|
|
||||||
*(here->ASRCposptr[j++]) += asrc_derivs[i];
|
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
/* The convergence test */
|
||||||
return(E_BADPARM);
|
here->ASRCprev_value = rhs;
|
||||||
|
|
||||||
|
/* The ac load precomputation and storage */
|
||||||
|
|
||||||
|
if (ckt->CKTmode & MODEINITSMSIG) {
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=0; i < here->ASRCtree->numVars; i++) {
|
||||||
|
rhs -= (asrc_vals[i] * asrc_derivs[i]);
|
||||||
|
|
||||||
|
switch(here->ASRCtree->varTypes[i]) {
|
||||||
|
case IF_INSTANCE:
|
||||||
|
if( here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
|
/* CCVS */
|
||||||
|
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
|
||||||
|
} else{
|
||||||
|
/* CCCS */
|
||||||
|
*(here->ASRCposptr[j++]) += asrc_derivs[i] * factor;
|
||||||
|
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IF_NODE:
|
||||||
|
if(here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
|
/* VCVS */
|
||||||
|
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
|
||||||
|
} else {
|
||||||
|
/* VCCS */
|
||||||
|
*(here->ASRCposptr[j++]) += asrc_derivs[i] * factor;
|
||||||
|
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return(E_BADPARM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert the RHS */
|
/* Insert the RHS */
|
||||||
if( here->ASRCtype == ASRC_VOLTAGE) {
|
if( here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
*(ckt->CKTrhs+(here->ASRCbranch)) += rhs;
|
*(ckt->CKTrhs+(here->ASRCbranch)) += factor * rhs;
|
||||||
} else {
|
} else {
|
||||||
*(ckt->CKTrhs+(here->ASRCposNode)) -= rhs;
|
*(ckt->CKTrhs+(here->ASRCposNode)) -= factor * rhs;
|
||||||
*(ckt->CKTrhs+(here->ASRCnegNode)) += rhs;
|
*(ckt->CKTrhs+(here->ASRCnegNode)) += factor * rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Store the rhs for small signal analysis */
|
/* Store the rhs for small signal analysis */
|
||||||
if (ckt->CKTmode & MODEINITSMSIG) {
|
if (ckt->CKTmode & MODEINITSMSIG) {
|
||||||
here->ASRCacValues[here->ASRCtree->numVars] = rhs;
|
here->ASRCacValues[here->ASRCtree->numVars] = factor * rhs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,19 @@ ASRCparam(int param, IFvalue *value, GENinstance *fast, IFvalue *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;
|
||||||
|
case ASRC_TC1:
|
||||||
|
here->ASRCtc1 = value->rValue;
|
||||||
|
here->ASRCtc1Given = TRUE;
|
||||||
|
break;
|
||||||
|
case ASRC_TC2:
|
||||||
|
here->ASRCtc2 = value->rValue;
|
||||||
|
here->ASRCtc2Given = TRUE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return(E_BADPARM);
|
return(E_BADPARM);
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
||||||
ASRCinstance *here;
|
ASRCinstance *here;
|
||||||
double value;
|
double value;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
double difference;
|
||||||
|
double factor;
|
||||||
|
|
||||||
NG_IGNORE(s);
|
NG_IGNORE(s);
|
||||||
|
|
||||||
|
|
@ -35,6 +37,13 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
||||||
if (here->ASRCowner != ARCHme)
|
if (here->ASRCowner != ARCHme)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if(!here->ASRCtc1Given) here->ASRCtc1 = 0.0;
|
||||||
|
if(!here->ASRCtc2Given) here->ASRCtc2 = 0.0;
|
||||||
|
|
||||||
|
difference = (here->ASRCtemp + here->ASRCdtemp) - 300.15;
|
||||||
|
factor = 1.0 + (here->ASRCtc1)*difference +
|
||||||
|
(here->ASRCtc2)*difference*difference;
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
/* Get the function evaluated and the derivatives too */
|
/* Get the function evaluated and the derivatives too */
|
||||||
|
|
@ -75,21 +84,21 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
||||||
case IF_INSTANCE:
|
case IF_INSTANCE:
|
||||||
if( here->ASRCtype == ASRC_VOLTAGE) {
|
if( here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
/* CCVS */
|
/* CCVS */
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i];
|
*(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor;
|
||||||
} else {
|
} else {
|
||||||
/* CCCS */
|
/* CCCS */
|
||||||
*(here->ASRCposptr[j++]) += asrc_derivs[i];
|
*(here->ASRCposptr[j++]) += asrc_derivs[i] / factor;
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i];
|
*(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];
|
*(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor;
|
||||||
} else {
|
} else {
|
||||||
/* VCCS */
|
/* VCCS */
|
||||||
*(here->ASRCposptr[j++]) += asrc_derivs[i];
|
*(here->ASRCposptr[j++]) += asrc_derivs[i] / factor;
|
||||||
*(here->ASRCposptr[j++]) -= asrc_derivs[i];
|
*(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
17724
visualc/vngspice.vcproj
17724
visualc/vngspice.vcproj
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue