Browse Source

Add temperature coefficients for B sources

dwarning 14 years ago
parent
commit
d9561123f9
  1. 6
      ChangeLog
  2. 5
      src/frontend/inpcom.c
  3. 3
      src/spicelib/devices/asrc/Makefile.am
  4. 5
      src/spicelib/devices/asrc/asrc.c
  5. 21
      src/spicelib/devices/asrc/asrcacld.c
  6. 12
      src/spicelib/devices/asrc/asrcask.c
  7. 13
      src/spicelib/devices/asrc/asrcdefs.h
  8. 2
      src/spicelib/devices/asrc/asrcext.h
  9. 2
      src/spicelib/devices/asrc/asrcinit.c
  10. 28
      src/spicelib/devices/asrc/asrcload.c
  11. 8
      src/spicelib/devices/asrc/asrcpar.c
  12. 21
      src/spicelib/devices/asrc/asrcpzld.c
  13. 30
      visualc/vngspice.vcproj

6
ChangeLog

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

5
src/frontend/inpcom.c

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

3
src/spicelib/devices/asrc/Makefile.am

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

5
src/spicelib/devices/asrc/asrc.c

@ -13,6 +13,11 @@ Author: 1987 Kanwar Jit Singh
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"),
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( "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"),

21
src/spicelib/devices/asrc/asrcacld.c

@ -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];
*(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];
*(here->ASRCposptr[j++]) -= derivs[i] / factor;
} else { } else {
/* VCCS */ /* VCCS */
*(here->ASRCposptr[j++]) += derivs[i];
*(here->ASRCposptr[j++]) -= derivs[i];
*(here->ASRCposptr[j++]) += derivs[i] / factor;
*(here->ASRCposptr[j++]) -= derivs[i] / factor;
} }
break; break;
default: default:

12
src/spicelib/devices/asrc/asrcask.c

@ -29,6 +29,18 @@ 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;

13
src/spicelib/devices/asrc/asrcdefs.h

@ -6,7 +6,6 @@ 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"
@ -29,11 +28,19 @@ typedef struct sASRCinstance {
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 */

2
src/spicelib/devices/asrc/asrcext.h

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

2
src/spicelib/devices/asrc/asrcinit.c

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

28
src/spicelib/devices/asrc/asrcload.c

@ -28,6 +28,8 @@ 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 ) {
@ -39,6 +41,12 @@ ASRCload(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 evaluated * Get the function and its derivatives evaluated
*/ */
@ -96,22 +104,22 @@ ASRCload(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++]) -= 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];
*(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];
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
} else { } else {
/* VCCS */ /* VCCS */
*(here->ASRCposptr[j++]) += asrc_derivs[i];
*(here->ASRCposptr[j++]) -= asrc_derivs[i];
*(here->ASRCposptr[j++]) += asrc_derivs[i] * factor;
*(here->ASRCposptr[j++]) -= asrc_derivs[i] * factor;
} }
break; break;
@ -122,15 +130,15 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt)
/* 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->ASRCnegNode)) += rhs;
*(ckt->CKTrhs+(here->ASRCposNode)) -= factor * 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;
} }
} }
} }

8
src/spicelib/devices/asrc/asrcpar.c

@ -30,6 +30,14 @@ ASRCparam(int param, IFvalue *value, GENinstance *fast, IFvalue *select)
here->ASRCtype = ASRC_CURRENT; here->ASRCtype = ASRC_CURRENT;
here->ASRCtree = value->tValue; here->ASRCtree = value->tValue;
break; break;
case ASRC_TC1:
here->ASRCtc1 = value->rValue;
here->ASRCtc1Given = TRUE;
break;
case ASRC_TC2:
here->ASRCtc2 = value->rValue;
here->ASRCtc2Given = TRUE;
break;
default: default:
return(E_BADPARM); return(E_BADPARM);
} }

21
src/spicelib/devices/asrc/asrcpzld.c

@ -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];
*(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];
*(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor;
} else { } else {
/* VCCS */ /* VCCS */
*(here->ASRCposptr[j++]) += asrc_derivs[i];
*(here->ASRCposptr[j++]) -= asrc_derivs[i];
*(here->ASRCposptr[j++]) += asrc_derivs[i] / factor;
*(here->ASRCposptr[j++]) -= asrc_derivs[i] / factor;
} }
break; break;
default: default:

30
visualc/vngspice.vcproj

@ -1933,10 +1933,6 @@
RelativePath="..\src\include\ngspice\ftedefs.h" RelativePath="..\src\include\ngspice\ftedefs.h"
> >
</File> </File>
<File
RelativePath="..\src\include\ngspice\fteoptdefs.h"
>
</File>
<File <File
RelativePath="..\src\include\ngspice\ftedev.h" RelativePath="..\src\include\ngspice\ftedev.h"
> >
@ -1961,6 +1957,10 @@
RelativePath="..\src\include\ngspice\fteinput.h" RelativePath="..\src\include\ngspice\fteinput.h"
> >
</File> </File>
<File
RelativePath="..\src\include\ngspice\fteoptdefs.h"
>
</File>
<File <File
RelativePath="..\src\include\ngspice\fteparse.h" RelativePath="..\src\include\ngspice\fteparse.h"
> >
@ -2146,11 +2146,11 @@
> >
</File> </File>
<File <File
RelativePath="..\src\spicelib\parser\inp.h"
RelativePath="..\src\frontend\inp.h"
> >
</File> </File>
<File <File
RelativePath="..\src\frontend\inp.h"
RelativePath="..\src\spicelib\parser\inp.h"
> >
</File> </File>
<File <File
@ -3281,6 +3281,10 @@
RelativePath="..\src\spicelib\devices\asrc\asrcset.c" RelativePath="..\src\spicelib\devices\asrc\asrcset.c"
> >
</File> </File>
<File
RelativePath="..\src\spicelib\devices\asrc\asrctemp.c"
>
</File>
<File <File
RelativePath="..\src\maths\deriv\atander.c" RelativePath="..\src\maths\deriv\atander.c"
> >
@ -5617,6 +5621,10 @@
RelativePath="..\src\frontend\fourier.c" RelativePath="..\src\frontend\fourier.c"
> >
</File> </File>
<File
RelativePath="..\src\frontend\ftesopt.c"
>
</File>
<File <File
RelativePath="..\src\frontend\gens.c" RelativePath="..\src\frontend\gens.c"
> >
@ -5657,10 +5665,6 @@
RelativePath="..\src\misc\hash.c" RelativePath="..\src\misc\hash.c"
> >
</File> </File>
<File
RelativePath="..\src\frontend\ftesopt.c"
>
</File>
<File <File
RelativePath="..\src\frontend\hcomp.c" RelativePath="..\src\frontend\hcomp.c"
> >
@ -6286,15 +6290,15 @@
> >
</File> </File>
<File <File
RelativePath="..\src\frontend\inventory.c"
RelativePath="..\src\maths\poly\interpolate.c"
> >
</File> </File>
<File <File
RelativePath="..\src\maths\poly\interpolate.c"
RelativePath="..\src\maths\deriv\invderiv.c"
> >
</File> </File>
<File <File
RelativePath="..\src\maths\deriv\invderiv.c"
RelativePath="..\src\frontend\inventory.c"
> >
</File> </File>
<File <File

Loading…
Cancel
Save