From 94821b2aff2e88b6b446ea5843c143d35fd663b5 Mon Sep 17 00:00:00 2001 From: pnenzi Date: Mon, 6 Oct 2003 07:34:34 +0000 Subject: [PATCH] Small change in inductor code. Added "nt" instance parameter. --- src/spicelib/devices/ind/ind.c | 6 +++-- src/spicelib/devices/ind/indask.c | 5 +++- src/spicelib/devices/ind/inddefs.h | 15 ++++++++---- src/spicelib/devices/ind/indmask.c | 4 ++-- src/spicelib/devices/ind/indmpar.c | 6 ++--- src/spicelib/devices/ind/indparam.c | 6 ++++- src/spicelib/devices/ind/indsacl.c | 2 ++ src/spicelib/devices/ind/indsetup.c | 37 ++++++++++++++++------------- src/spicelib/devices/ind/indsload.c | 2 ++ src/spicelib/devices/ind/indsprt.c | 2 ++ src/spicelib/devices/ind/indsset.c | 2 ++ src/spicelib/devices/ind/indsupd.c | 2 ++ src/spicelib/devices/ind/indtemp.c | 10 +++++--- src/spicelib/devices/ind/mutsprt.c | 2 ++ src/spicelib/devices/ind/mutsset.c | 2 ++ src/spicelib/devices/ind/muttemp.c | 4 +++- 16 files changed, 72 insertions(+), 35 deletions(-) diff --git a/src/spicelib/devices/ind/ind.c b/src/spicelib/devices/ind/ind.c index fe27f6db9..6889d6be4 100644 --- a/src/spicelib/devices/ind/ind.c +++ b/src/spicelib/devices/ind/ind.c @@ -18,7 +18,8 @@ IFparm INDpTable[] = { /* parameters */ IOPZ( "dtemp", IND_DTEMP, IF_REAL, "Instance temperature difference with the rest of the circuit"), IOPU( "m", IND_M, IF_REAL, "Multiplication Factor"), - IOPU( "scale", IND_SCALE, IF_REAL, "Scale factor"), + IOPU( "scale", IND_SCALE, IF_REAL, "Scale factor"), + IOP( "nt", IND_NT, IF_REAL, "Number of turns"), OP( "flux", IND_FLUX, IF_REAL, "Flux through inductor"), OP( "v", IND_VOLT, IF_REAL, "Terminal voltage of inductor"), OPR( "volt", IND_VOLT, IF_REAL, ""), @@ -42,8 +43,9 @@ IFparm INDmPTable[] = { /* model parameters */ IOPXU( "tnom", IND_MOD_TNOM, IF_REAL,"Parameter measurement temperature"), IOPA( "csect", IND_MOD_CSECT, IF_REAL,"Inductor cross section"), IOPA( "length", IND_MOD_LENGTH, IF_REAL,"Inductor length"), - IOPA( "n", IND_MOD_N, IF_REAL,"Number of turns"), + 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 ee39b2eeb..1268d2ec9 100644 --- a/src/spicelib/devices/ind/indask.c +++ b/src/spicelib/devices/ind/indask.c @@ -46,7 +46,10 @@ INDask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case IND_SCALE: value->rValue = here->INDscale; - return(OK); + return(OK); + case IND_NT: + value->rValue = here->INDnt; + return(OK); case IND_CURRENT : if (ckt->CKTcurrentAnalysis & DOING_AC) { errMsg = MALLOC(strlen(msg)+1); diff --git a/src/spicelib/devices/ind/inddefs.h b/src/spicelib/devices/ind/inddefs.h index a12a3b319..a942a0553 100644 --- a/src/spicelib/devices/ind/inddefs.h +++ b/src/spicelib/devices/ind/inddefs.h @@ -36,6 +36,7 @@ typedef struct sINDinstance { double INDtemp; /* Instance operating temperature */ double INDdtemp; /* Delta temp. of instance */ double INDscale; /* Scale factor */ + double INDnt; /* Number of turns */ double INDinitCond; /* initial inductor voltage if specified */ double *INDposIbrptr; /* pointer to sparse matrix diagonal at @@ -55,6 +56,7 @@ typedef struct sINDinstance { unsigned INDtempGiven : 1; /* flag to indicate operating temp. given */ unsigned INDdtempGiven : 1; /* flag to indicate delta temp. given */ unsigned INDscaleGiven : 1; /* flag to indicate scale factor given */ + unsigned INDntGiven : 1; /* flag to indicate number of turns given */ int INDsenParmNo; /* parameter # for sensitivity use; set equal to 0 if not a design parameter*/ @@ -82,15 +84,16 @@ typedef struct sINDmodel { /* model structure for an inductor */ double INDtempCoeff1; /* first temperature coefficient */ double INDtempCoeff2; /* second temperature coefficient */ double INDcsect; /* Cross section of inductor */ - double INDlength; /* Length of inductor */ - double INDn; /* Number of turns */ + 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 */ unsigned INDcsectGiven : 1; /* flag to indicate cross section given */ unsigned INDlengthGiven: 1; /* flag to indicate length given */ - unsigned INDnGiven : 1; /* flag to indicate n. of turns 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 */ } INDmodel; @@ -151,6 +154,7 @@ typedef struct sMUTmodel { /* model structure for a mutual inductor */ #define IND_TEMP 9 #define IND_DTEMP 10 #define IND_SCALE 11 +#define IND_NT 12 /* model parameters */ #define IND_MOD_IND 100 @@ -159,9 +163,10 @@ typedef struct sMUTmodel { /* model structure for a mutual inductor */ #define IND_MOD_TNOM 103 #define IND_MOD_CSECT 104 #define IND_MOD_LENGTH 105 -#define IND_MOD_N 106 +#define IND_MOD_NT 106 #define IND_MOD_MU 107 -#define IND_MOD_L 108 +#define IND_MOD_SIND 108 +#define IND_MOD_L 109 /* device questions */ #define IND_QUEST_SENS_REAL 201 diff --git a/src/spicelib/devices/ind/indmask.c b/src/spicelib/devices/ind/indmask.c index fd6ee794d..f5b3b7bbf 100644 --- a/src/spicelib/devices/ind/indmask.c +++ b/src/spicelib/devices/ind/indmask.c @@ -38,8 +38,8 @@ INDmAsk(CKTcircuit *ckt, GENmodel *inst, int which, IFvalue *value) case IND_MOD_LENGTH: value->rValue = here->INDlength; return(OK); - case IND_MOD_N: - value->rValue = here->INDn; + case IND_MOD_NT: + value->rValue = here->INDmodNt; return(OK); case IND_MOD_MU: value->rValue = here->INDmu; diff --git a/src/spicelib/devices/ind/indmpar.c b/src/spicelib/devices/ind/indmpar.c index b80245c99..3797d3e43 100644 --- a/src/spicelib/devices/ind/indmpar.c +++ b/src/spicelib/devices/ind/indmpar.c @@ -41,9 +41,9 @@ INDmParam(int param, IFvalue *value, GENmodel *inModel) mod->INDlength = value->rValue; mod->INDlengthGiven = TRUE; break; - case IND_MOD_N : - mod->INDn = value->rValue; - mod->INDnGiven = TRUE; + case IND_MOD_NT : + mod->INDmodNt = value->rValue; + mod->INDmodNtGiven = TRUE; break; case IND_MOD_MU: mod->INDmu = value->rValue; diff --git a/src/spicelib/devices/ind/indparam.c b/src/spicelib/devices/ind/indparam.c index faa0be3ab..2f02ed4cc 100644 --- a/src/spicelib/devices/ind/indparam.c +++ b/src/spicelib/devices/ind/indparam.c @@ -37,7 +37,11 @@ INDparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select) case IND_SCALE: here->INDscale = value->rValue; here->INDscaleGiven = TRUE; - break; + break; + case IND_NT: + here->INDnt = value->rValue; + here->INDntGiven = TRUE; + break; case IND_IC: here->INDinitCond = value->rValue; here->INDicGiven = TRUE; diff --git a/src/spicelib/devices/ind/indsacl.c b/src/spicelib/devices/ind/indsacl.c index 7f0a51695..846aea1d8 100644 --- a/src/spicelib/devices/ind/indsacl.c +++ b/src/spicelib/devices/ind/indsacl.c @@ -1,6 +1,8 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Thomas L. Quarles + +This function is obsolete (was used by an old sensitivity analysis) **********/ /* actually load the current ac sensitivity diff --git a/src/spicelib/devices/ind/indsetup.c b/src/spicelib/devices/ind/indsetup.c index 2efc4c7b3..ecf16ea68 100644 --- a/src/spicelib/devices/ind/indsetup.c +++ b/src/spicelib/devices/ind/indsetup.c @@ -43,31 +43,34 @@ INDsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) if (!model->INDlengthGiven) { model->INDlength = 0.0; } - if (!model->INDnGiven) { - model->INDn = 0.0; + if (!model->INDmodNtGiven) { + model->INDmodNt = 0.0; } if (!model->INDmuGiven) { model->INDmu = 0.0; } - - if (!model->INDmIndGiven) { - if((model->INDlengthGiven) + + /* precompute specific inductance (one turn) */ + if((model->INDlengthGiven) && (model->INDlength > 0.0)) { if (model->INDmuGiven) - model->INDmInd = ((model->INDmu * CONSTmuZero) - * model->INDn * model->INDn * model->INDcsect) - / model->INDlength; - - else - model->INDmInd = (CONSTmuZero - * model->INDn * model->INDn * model->INDcsect) - / model->INDlength; + model->INDspecInd = (model->INDmu * CONSTmuZero + * model->INDcsect) / model->INDlength; + else + model->INDspecInd = (CONSTmuZero * model->INDcsect) + / model->INDlength; + + } else { + model->INDspecInd = 0.0; + } + + if (!model->INDmIndGiven) + model->INDmInd = model->INDmodNt * model->INDmodNt * model->INDspecInd; - } else { - model->INDmInd = 0.0; - } - } + + + /* loop through all the instances of the model */ for (here = model->INDinstances; here != NULL ; here=here->INDnextInstance) { diff --git a/src/spicelib/devices/ind/indsload.c b/src/spicelib/devices/ind/indsload.c index b9e3f3555..a629a0995 100644 --- a/src/spicelib/devices/ind/indsload.c +++ b/src/spicelib/devices/ind/indsload.c @@ -1,6 +1,8 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Thomas L. Quarles + +This function is obsolete (was used by an old sensitivity analysis) **********/ /* actually load the current ac sensitivity diff --git a/src/spicelib/devices/ind/indsprt.c b/src/spicelib/devices/ind/indsprt.c index f35905837..ad882713d 100644 --- a/src/spicelib/devices/ind/indsprt.c +++ b/src/spicelib/devices/ind/indsprt.c @@ -1,6 +1,8 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Thomas L. Quarles + +This function is obsolete (was used by an old sensitivity analysis) **********/ /* Pretty print the sensitivity info for all diff --git a/src/spicelib/devices/ind/indsset.c b/src/spicelib/devices/ind/indsset.c index faf79ee64..740f78264 100644 --- a/src/spicelib/devices/ind/indsset.c +++ b/src/spicelib/devices/ind/indsset.c @@ -1,6 +1,8 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Thomas L. Quarles + +This function is obsolete (was used by an old sensitivity analysis) **********/ /* loop through all the devices and diff --git a/src/spicelib/devices/ind/indsupd.c b/src/spicelib/devices/ind/indsupd.c index f23bcb04a..ea6b5b531 100644 --- a/src/spicelib/devices/ind/indsupd.c +++ b/src/spicelib/devices/ind/indsupd.c @@ -1,6 +1,8 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Thomas L. Quarles + +This function is obsolete (was used by an old sensitivity analysis) **********/ /* update the charge sensitivities and their derivatives */ diff --git a/src/spicelib/devices/ind/indtemp.c b/src/spicelib/devices/ind/indtemp.c index 981589c32..16064bb34 100644 --- a/src/spicelib/devices/ind/indtemp.c +++ b/src/spicelib/devices/ind/indtemp.c @@ -44,10 +44,14 @@ INDtemp(GENmodel *inModel, CKTcircuit *ckt) if (!here->INDscaleGiven) here->INDscale = 1.0; if (!here->INDmGiven) here->INDm = 1.0; + if (!here->INDntGiven) here->INDnt = 0.0; - if (!here->INDindGiven) /* No instance inductance given */ - here->INDinduct = model->INDmInd; - + if (!here->INDindGiven) { /* No instance inductance given */ + if (here->INDntGiven) + 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 + diff --git a/src/spicelib/devices/ind/mutsprt.c b/src/spicelib/devices/ind/mutsprt.c index 2211cea77..0b0e6f6b1 100644 --- a/src/spicelib/devices/ind/mutsprt.c +++ b/src/spicelib/devices/ind/mutsprt.c @@ -1,6 +1,8 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Thomas L. Quarles + +This function is obsolete (was used by an old sensitivity analysis) **********/ /* Pretty print the sensitivity info for all diff --git a/src/spicelib/devices/ind/mutsset.c b/src/spicelib/devices/ind/mutsset.c index fdbf124d1..7f316c202 100644 --- a/src/spicelib/devices/ind/mutsset.c +++ b/src/spicelib/devices/ind/mutsset.c @@ -1,6 +1,8 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Thomas L. Quarles + +This function is obsolete (was used by an old sensitivity analysis) **********/ /* loop through all the devices and diff --git a/src/spicelib/devices/ind/muttemp.c b/src/spicelib/devices/ind/muttemp.c index e9b5241e6..348703e71 100644 --- a/src/spicelib/devices/ind/muttemp.c +++ b/src/spicelib/devices/ind/muttemp.c @@ -34,7 +34,9 @@ MUTtemp(GENmodel *inModel, CKTcircuit *ckt) ind1 = here->MUTind1->INDinduct; ind2 = here->MUTind2->INDinduct; - + /* _______ + * M = k * \/l1 * l2 + */ here->MUTfactor = here->MUTcoupling * sqrt(ind1 * ind2); }