From 858a227a578d9b5e70960a042940c44bf45a98c4 Mon Sep 17 00:00:00 2001 From: pnenzi Date: Sun, 26 Oct 2003 13:20:54 +0000 Subject: [PATCH] Cleaned and fixed inductor code. --- src/spicelib/devices/ind/ind.c | 1 - src/spicelib/devices/ind/indask.c | 2 -- src/spicelib/devices/ind/inddefs.h | 9 +++++---- src/spicelib/devices/ind/indsetup.c | 12 ++++++------ src/spicelib/devices/ind/indtemp.c | 4 ++-- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/spicelib/devices/ind/ind.c b/src/spicelib/devices/ind/ind.c index 6889d6be4..c7be3a0dc 100644 --- a/src/spicelib/devices/ind/ind.c +++ b/src/spicelib/devices/ind/ind.c @@ -45,7 +45,6 @@ IFparm INDmPTable[] = { /* model parameters */ IOPA( "length", IND_MOD_LENGTH, IF_REAL,"Inductor length"), IOPA( "nt", IND_MOD_NT, IF_REAL,"Model number of turns"), IOPA( "mu", IND_MOD_MU, IF_REAL,"Relative magnetic permeability"), - OPU( "sind", IND_MOD_SIND, IF_REAL,"Specific model inductance"), IP( "l", IND_MOD_L, IF_FLAG,"Inductor model") }; diff --git a/src/spicelib/devices/ind/indask.c b/src/spicelib/devices/ind/indask.c index 1268d2ec9..f25f81d71 100644 --- a/src/spicelib/devices/ind/indask.c +++ b/src/spicelib/devices/ind/indask.c @@ -58,7 +58,6 @@ INDask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(E_ASKCURRENT); } else { value->rValue = *(ckt->CKTrhsOld + here->INDbrEq); - value->rValue *= here->INDm; } return(OK); case IND_POWER : @@ -70,7 +69,6 @@ INDask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, } else { value->rValue = *(ckt->CKTrhsOld + here->INDbrEq) * *(ckt->CKTstate0+here->INDvolt); - value->rValue *= here->INDm; } return(OK); case IND_QUEST_SENS_DC: diff --git a/src/spicelib/devices/ind/inddefs.h b/src/spicelib/devices/ind/inddefs.h index a942a0553..ea7ef04e6 100644 --- a/src/spicelib/devices/ind/inddefs.h +++ b/src/spicelib/devices/ind/inddefs.h @@ -87,7 +87,7 @@ typedef struct sINDmodel { /* model structure for an inductor */ double INDlength; /* Mean length of magnetic path */ double INDmodNt; /* Model number of turns */ double INDmu; /* Relative magnetic permeability */ - double INDspecInd; /* Specific (one turn) inductance */ + unsigned INDtnomGiven : 1; /* flag to indicate nominal temp was given */ unsigned INDtc1Given : 1; /* flag to indicate tc1 was specified */ unsigned INDtc2Given : 1; /* flag to indicate tc2 was specified */ @@ -95,7 +95,9 @@ typedef struct sINDmodel { /* model structure for an inductor */ unsigned INDlengthGiven: 1; /* flag to indicate length given */ unsigned INDmodNtGiven : 1; /* flag to indicate mod. n. of turns given */ unsigned INDmuGiven : 1; /* flag to indicate mu_r given */ - unsigned INDmIndGiven : 1; /* flag to indicate model inductance given */ + unsigned INDmIndGiven : 1; /* flag to indicate model inductance given */ + + double INDspecInd; /* Specific (one turn) inductance */ } INDmodel; @@ -165,8 +167,7 @@ typedef struct sMUTmodel { /* model structure for a mutual inductor */ #define IND_MOD_LENGTH 105 #define IND_MOD_NT 106 #define IND_MOD_MU 107 -#define IND_MOD_SIND 108 -#define IND_MOD_L 109 +#define IND_MOD_L 108 /* device questions */ #define IND_QUEST_SENS_REAL 201 diff --git a/src/spicelib/devices/ind/indsetup.c b/src/spicelib/devices/ind/indsetup.c index ecf16ea68..650e526c5 100644 --- a/src/spicelib/devices/ind/indsetup.c +++ b/src/spicelib/devices/ind/indsetup.c @@ -12,9 +12,9 @@ Author: 1985 Thomas L. Quarles int INDsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) - /* load the inductor structure with those pointers needed later - * for fast matrix loading - */ + /* load the inductor structure with those pointers needed later + * for fast matrix loading + */ { INDmodel *model = (INDmodel*)inModel; INDinstance *here; @@ -56,10 +56,10 @@ INDsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) if (model->INDmuGiven) model->INDspecInd = (model->INDmu * CONSTmuZero - * model->INDcsect) / model->INDlength; + * model->INDcsect * model->INDcsect) / model->INDlength; else - model->INDspecInd = (CONSTmuZero * model->INDcsect) - / model->INDlength; + model->INDspecInd = (CONSTmuZero * model->INDcsect + * model->INDcsect ) / model->INDlength; } else { model->INDspecInd = 0.0; diff --git a/src/spicelib/devices/ind/indtemp.c b/src/spicelib/devices/ind/indtemp.c index 16064bb34..aa9e6febc 100644 --- a/src/spicelib/devices/ind/indtemp.c +++ b/src/spicelib/devices/ind/indtemp.c @@ -51,7 +51,7 @@ INDtemp(GENmodel *inModel, CKTcircuit *ckt) here->INDinduct = model->INDspecInd * here->INDnt * here->INDnt; else here->INDinduct = model->INDmInd; - } + } difference = (here->INDtemp + here->INDdtemp) - model->INDtnom; factor = 1.0 + (model->INDtempCoeff1)*difference + @@ -59,7 +59,7 @@ INDtemp(GENmodel *inModel, CKTcircuit *ckt) here->INDinduct = here->INDinduct * factor * here->INDscale; here->INDinduct = here->INDinduct / here->INDm; - + } } return(OK);