From b50f9b97bb4e1715ccb682d97129643ff59f2a0a Mon Sep 17 00:00:00 2001 From: h_vogt Date: Wed, 8 May 2013 22:32:10 +0200 Subject: [PATCH] devices/cap: implement `tc1', `tc2' instance parameters --- src/spicelib/devices/cap/cap.c | 2 ++ src/spicelib/devices/cap/capdefs.h | 6 ++++++ src/spicelib/devices/cap/capparam.c | 8 ++++++++ src/spicelib/devices/cap/captemp.c | 19 ++++++++++++++++--- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/spicelib/devices/cap/cap.c b/src/spicelib/devices/cap/cap.c index 88841cae4..3b0984fe9 100644 --- a/src/spicelib/devices/cap/cap.c +++ b/src/spicelib/devices/cap/cap.c @@ -20,6 +20,8 @@ IFparm CAPpTable[] = { /* parameters */ IOPAU("w", CAP_WIDTH, IF_REAL, "Device width"), IOPAU("l", CAP_LENGTH, IF_REAL, "Device length"), IOPU( "m", CAP_M, IF_REAL, "Parallel multiplier"), + IOPU( "tc1", CAP_TC1, IF_REAL, "First order temp. coefficient"), + IOPU( "tc2", CAP_TC2, IF_REAL, "Second order temp. coefficient"), IOPU( "scale", CAP_SCALE, IF_REAL, "Scale factor"), IP( "sens_cap", CAP_CAP_SENS, IF_FLAG, "flag to request sens. WRT cap."), OP( "i", CAP_CURRENT, IF_REAL, "Device current"), diff --git a/src/spicelib/devices/cap/capdefs.h b/src/spicelib/devices/cap/capdefs.h index 321460c59..785149ecf 100644 --- a/src/spicelib/devices/cap/capdefs.h +++ b/src/spicelib/devices/cap/capdefs.h @@ -35,6 +35,8 @@ typedef struct sCAPinstance { double CAPlength; /* length of the capacitor */ double CAPscale; /* scale factor */ double CAPm; /* parallel multiplier */ + double CAPtc1; /* first temperature coefficient of capacitors */ + double CAPtc2; /* second temperature coefficient of capacitors */ double *CAPposPosptr; /* pointer to sparse matrix diagonal at * (positive,positive) */ @@ -52,6 +54,8 @@ typedef struct sCAPinstance { unsigned CAPdtempGiven : 1; /* flag to indicate delta temp given */ unsigned CAPscaleGiven : 1; /* flag to indicate scale factor given */ unsigned CAPmGiven : 1; /* flag to indicate parallel multiplier given */ + unsigned CAPtc1Given : 1; /* flag indicates tc1 was specified */ + unsigned CAPtc2Given : 1; /* flag indicates tc2 was specified */ int CAPsenParmNo; /* parameter # for sensitivity use; set equal to 0 if not a design parameter*/ @@ -113,6 +117,8 @@ typedef struct sCAPmodel { /* model structure for a capacitor */ #define CAP_DTEMP 9 #define CAP_SCALE 10 #define CAP_M 11 +#define CAP_TC1 12 +#define CAP_TC2 13 /* model parameters */ #define CAP_MOD_CJ 101 diff --git a/src/spicelib/devices/cap/capparam.c b/src/spicelib/devices/cap/capparam.c index 1a11fd5c4..f37ced9c8 100644 --- a/src/spicelib/devices/cap/capparam.c +++ b/src/spicelib/devices/cap/capparam.c @@ -59,6 +59,14 @@ CAPparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select) case CAP_CAP_SENS: here->CAPsenParmNo = value->iValue; break; + case CAP_TC1: + here->CAPtc1 = value->rValue; + here->CAPtc1Given = TRUE; + break; + case CAP_TC2: + here->CAPtc2 = value->rValue; + here->CAPtc2Given = TRUE; + break; default: return(E_BADPARM); } diff --git a/src/spicelib/devices/cap/captemp.c b/src/spicelib/devices/cap/captemp.c index 03f196461..4d82b3a57 100644 --- a/src/spicelib/devices/cap/captemp.c +++ b/src/spicelib/devices/cap/captemp.c @@ -26,6 +26,7 @@ CAPtemp(GENmodel *inModel, CKTcircuit *ckt) CAPinstance *here; double difference; double factor; + double tc1, tc2; /* loop through all the capacitor models */ for( ; model != NULL; model = model->CAPnextModel ) { @@ -66,10 +67,22 @@ CAPtemp(GENmodel *inModel, CKTcircuit *ckt) } difference = (here->CAPtemp + here->CAPdtemp) - model->CAPtnom; - - factor = 1.0 + (model->CAPtempCoeff1)*difference + - (model->CAPtempCoeff2)*difference*difference; + /* instance parameters tc1 and tc2 will override + model parameters tc1 and tc2 */ + if (here->CAPtc1Given) + tc1 = here->CAPtc1; /* instance */ + else + tc1 = model->CAPtempCoeff1; /* model */ + + if (here->CAPtc2Given) + tc2 = here->CAPtc2; + else + tc2 = model->CAPtempCoeff2; + + factor = 1.0 + tc1*difference + + tc2*difference*difference; + here->CAPcapac = here->CAPcapac * factor * here->CAPscale; }