From 8d2a6c24056a8fa15411e28c4f236c5a9e1983b2 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Wed, 22 Jun 2022 13:26:57 +0200 Subject: [PATCH] Add coil diameter dia to the inductor parameters. dia (diameter) takes preference over csect (cross section) --- src/spicelib/devices/ind/ind.c | 1 + src/spicelib/devices/ind/inddefs.h | 3 ++ src/spicelib/devices/ind/indmpar.c | 4 +++ src/spicelib/devices/ind/indsetup.c | 45 ++++++++++++++++------------- 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/spicelib/devices/ind/ind.c b/src/spicelib/devices/ind/ind.c index 24d1eeccb..d34c8a75e 100644 --- a/src/spicelib/devices/ind/ind.c +++ b/src/spicelib/devices/ind/ind.c @@ -44,6 +44,7 @@ IFparm INDmPTable[] = { /* model parameters */ IOPA( "tc2", IND_MOD_TC2, IF_REAL,"Second order temp. coefficient"), IOPXU( "tnom", IND_MOD_TNOM, IF_REAL,"Parameter measurement temperature"), IOPA( "csect", IND_MOD_CSECT, IF_REAL,"Inductor cross section"), + IOPA( "dia", IND_MOD_DIA, IF_REAL,"Inductor diameter"), 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"), diff --git a/src/spicelib/devices/ind/inddefs.h b/src/spicelib/devices/ind/inddefs.h index 5f55f995a..f39d152ed 100644 --- a/src/spicelib/devices/ind/inddefs.h +++ b/src/spicelib/devices/ind/inddefs.h @@ -101,6 +101,7 @@ struct sINDmodel { /* model structure for an inductor */ double INDtempCoeff1; /* first temperature coefficient */ double INDtempCoeff2; /* second temperature coefficient */ double INDcsect; /* Cross section of inductor */ + double INDdia; /* Diameter of (cylindrical) inductor */ double INDlength; /* Mean length of magnetic path */ double INDmodNt; /* Model number of turns */ double INDmu; /* Relative magnetic permeability */ @@ -109,6 +110,7 @@ struct sINDmodel { /* model structure for an inductor */ 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 INDdiaGiven : 1; /* flag to indicate diameter given */ 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 */ @@ -196,6 +198,7 @@ enum { IND_MOD_TC2, IND_MOD_TNOM, IND_MOD_CSECT, + IND_MOD_DIA, IND_MOD_LENGTH, IND_MOD_NT, IND_MOD_MU, diff --git a/src/spicelib/devices/ind/indmpar.c b/src/spicelib/devices/ind/indmpar.c index ee641d5af..adaad131f 100644 --- a/src/spicelib/devices/ind/indmpar.c +++ b/src/spicelib/devices/ind/indmpar.c @@ -37,6 +37,10 @@ INDmParam(int param, IFvalue *value, GENmodel *inModel) mod->INDcsect = value->rValue; mod->INDcsectGiven = TRUE; break; + case IND_MOD_DIA: + mod->INDdia = value->rValue; + mod->INDdiaGiven = TRUE; + break; case IND_MOD_LENGTH : mod->INDlength = value->rValue; mod->INDlengthGiven = TRUE; diff --git a/src/spicelib/devices/ind/indsetup.c b/src/spicelib/devices/ind/indsetup.c index e50d0f564..a33d7c31a 100644 --- a/src/spicelib/devices/ind/indsetup.c +++ b/src/spicelib/devices/ind/indsetup.c @@ -32,10 +32,10 @@ INDsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) if (!model->INDmIndGiven) { model->INDmInd = 0.0; } - if (!model->INDtnomGiven) { + if (!model->INDtnomGiven) { model->INDtnom = ckt->CKTnomTemp; } - if (!model->INDtc1Given) { + if (!model->INDtc1Given) { model->INDtempCoeff1 = 0.0; } if (!model->INDtc2Given) { @@ -44,6 +44,9 @@ INDsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) if (!model->INDcsectGiven){ model->INDcsect = 0.0; } + if (!model->INDdiaGiven){ + model->INDdia = 0.0; + } if (!model->INDlengthGiven) { model->INDlength = 0.0; } @@ -53,30 +56,32 @@ INDsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) if (!model->INDmuGiven) { model->INDmu = 1.0; } - - /* precompute specific inductance (one turn) */ - if((model->INDlengthGiven) && (model->INDlength > 0.0)) { - model->INDspecInd = (model->INDmu * CONSTmuZero - * model->INDcsect) / model->INDlength; - } else { - model->INDspecInd = 0.0; - } - /* Lundin's geometry correction factor */ - model->INDspecInd *= Lundin(model->INDlength, model->INDcsect); + /* diameter takes preference over cross section */ + if (model->INDdiaGiven) { + model->INDcsect = PI * model->INDdia * model->INDdia / 4.; + } + + /* precompute specific inductance (one turn) */ + if((model->INDlengthGiven) && (model->INDlength > 0.0)) { + model->INDspecInd = (model->INDmu * CONSTmuZero + * model->INDcsect) / model->INDlength; + } else { + model->INDspecInd = 0.0; + } + + /* Lundin's geometry correction factor */ + model->INDspecInd *= Lundin(model->INDlength, model->INDcsect); /* - double kl = Lundin(model->INDlength, model->INDcsect); - double Dl = model->INDlength / sqrt(model->INDcsect / PI) / 2.; - fprintf(stdout, "Lundin's correction factor %f at l/D %f\n", kl, Dl); + double kl = Lundin(model->INDlength, model->INDcsect); + double Dl = model->INDlength / sqrt(model->INDcsect / PI) / 2.; + fprintf(stdout, "Lundin's correction factor %f at l/D %f\n", kl, Dl); */ - /* How many turns ? */ - if (!model->INDmIndGiven) + /* How many turns ? */ + if (!model->INDmIndGiven) model->INDmInd = model->INDmodNt * model->INDmodNt * model->INDspecInd; - - - /* loop through all the instances of the model */ for (here = INDinstances(model); here != NULL ;