diff --git a/src/spicelib/devices/ind/Makefile.am b/src/spicelib/devices/ind/Makefile.am index abe6e9b6c..94ab7147c 100644 --- a/src/spicelib/devices/ind/Makefile.am +++ b/src/spicelib/devices/ind/Makefile.am @@ -14,7 +14,9 @@ libind_a_SOURCES = \ indinit.h \ inditf.h \ indload.c \ + indmask.c \ indmdel.c \ + indmpar.c \ indparam.c \ indpzld.c \ indsacl.c \ @@ -23,6 +25,7 @@ libind_a_SOURCES = \ indsprt.c \ indsset.c \ indsupd.c \ + indtemp.c \ indtrunc.c \ mutacld.c \ mutask.c \ @@ -33,7 +36,8 @@ libind_a_SOURCES = \ mutpzld.c \ mutsetup.c \ mutsprt.c \ - mutsset.c + mutsset.c \ + muttemp.c diff --git a/src/spicelib/devices/ind/ind.c b/src/spicelib/devices/ind/ind.c index 6906ebd04..fe27f6db9 100644 --- a/src/spicelib/devices/ind/ind.c +++ b/src/spicelib/devices/ind/ind.c @@ -10,26 +10,44 @@ Author: 1985 Thomas L. Quarles #include "suffix.h" IFparm INDpTable[] = { /* parameters */ - IOPAP("inductance",IND_IND, IF_REAL,"Inductance of inductor"), - IOPAU("ic", IND_IC, IF_REAL,"Initial current through inductor"), - IP( "sens_ind", IND_IND_SENS,IF_FLAG, - "flag to request sensitivity WRT inductance"), - 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,""), - OP( "i", IND_CURRENT,IF_REAL,"Current through the inductor"), - OPR( "current", IND_CURRENT,IF_REAL,""), - OP( "p", IND_POWER, IF_REAL, - "instantaneous power dissipated by the inductor"), - OPU( "sens_dc", IND_QUEST_SENS_DC, IF_REAL, "dc sensitivity sensitivity"), - OPU( "sens_real", IND_QUEST_SENS_REAL, IF_REAL, "real part of ac sensitivity"), - OPU( "sens_imag", IND_QUEST_SENS_IMAG, IF_REAL, - "dc sensitivity and imag part of ac sensitivty"), - OPU( "sens_mag", IND_QUEST_SENS_MAG, IF_REAL, "sensitivity of AC magnitude"), - OPU( "sens_ph", IND_QUEST_SENS_PH, IF_REAL, "sensitivity of AC phase"), - OPU( "sens_cplx", IND_QUEST_SENS_CPLX, IF_COMPLEX, "ac sensitivity") + IOPAP("inductance",IND_IND, IF_REAL, "Inductance of inductor"), + IOPAU("ic", IND_IC, IF_REAL, "Initial current through inductor"), + IP( "sens_ind", IND_IND_SENS, IF_FLAG, + "flag to request sensitivity WRT inductance"), + IOPZU("temp", IND_TEMP, IF_REAL, "Instance operating temperature"), + 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"), + 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, ""), + OP( "i", IND_CURRENT, IF_REAL, "Current through the inductor"), + OPR( "current", IND_CURRENT, IF_REAL, ""), + OP( "p", IND_POWER, IF_REAL, + "instantaneous power dissipated by the inductor"), + OPU( "sens_dc", IND_QUEST_SENS_DC, IF_REAL, "dc sensitivity sensitivity"), + OPU( "sens_real", IND_QUEST_SENS_REAL, IF_REAL, "real part of ac sensitivity"), + OPU( "sens_imag", IND_QUEST_SENS_IMAG, IF_REAL, + "dc sensitivity and imag part of ac sensitivty"), + OPU( "sens_mag", IND_QUEST_SENS_MAG, IF_REAL, "sensitivity of AC magnitude"), + OPU( "sens_ph", IND_QUEST_SENS_PH, IF_REAL, "sensitivity of AC phase"), + OPU( "sens_cplx", IND_QUEST_SENS_CPLX, IF_COMPLEX, "ac sensitivity") }; +IFparm INDmPTable[] = { /* model parameters */ + IOPA( "ind", IND_MOD_IND, IF_REAL,"Model inductance"), + IOPA( "tc1", IND_MOD_TC1, IF_REAL,"First order temp. coefficient"), + 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( "length", IND_MOD_LENGTH, IF_REAL,"Inductor length"), + IOPA( "n", IND_MOD_N, IF_REAL,"Number of turns"), + IOPA( "mu", IND_MOD_MU, IF_REAL,"Relative magnetic permeability"), + IP( "l", IND_MOD_L, IF_FLAG,"Inductor model") +}; + + char *INDnames[] = { "L+", "L-" @@ -38,7 +56,7 @@ char *INDnames[] = { int INDnSize = NUMELEMS(INDnames); int INDpTSize = NUMELEMS(INDpTable); -int INDmPTSize = 0; +int INDmPTSize = NUMELEMS(INDmPTable); int INDiSize = sizeof(INDinstance); int INDmSize = sizeof(INDmodel); diff --git a/src/spicelib/devices/ind/indacld.c b/src/spicelib/devices/ind/indacld.c index faef1446e..aea9b03cd 100644 --- a/src/spicelib/devices/ind/indacld.c +++ b/src/spicelib/devices/ind/indacld.c @@ -13,9 +13,7 @@ Author: 1985 Thomas L. Quarles int -INDacLoad(inModel,ckt) - GENmodel *inModel; - CKTcircuit *ckt; +INDacLoad(GENmodel *inModel, CKTcircuit *ckt) { INDmodel *model = (INDmodel*)inModel; double val; @@ -24,14 +22,16 @@ INDacLoad(inModel,ckt) for( ; model != NULL; model = model->INDnextModel) { for( here = model->INDinstances;here != NULL; here = here->INDnextInstance) { + if (here->INDowner != ARCHme) continue; val = ckt->CKTomega * here->INDinduct; - *(here->INDposIbrptr) += 1; - *(here->INDnegIbrptr) -= 1; - *(here->INDibrPosptr) += 1; - *(here->INDibrNegptr) -= 1; - *(here->INDibrIbrptr +1) -= val; + + *(here->INDposIbrptr) += 1; + *(here->INDnegIbrptr) -= 1; + *(here->INDibrPosptr) += 1; + *(here->INDibrNegptr) -= 1; + *(here->INDibrIbrptr +1) -= val; } } return(OK); diff --git a/src/spicelib/devices/ind/indask.c b/src/spicelib/devices/ind/indask.c index 5a0154937..ee39b2eeb 100644 --- a/src/spicelib/devices/ind/indask.c +++ b/src/spicelib/devices/ind/indask.c @@ -12,12 +12,8 @@ Author: 1985 Thomas L. Quarles /*ARGSUSED*/ int -INDask(ckt,inst,which,value,select) - CKTcircuit *ckt; - GENinstance *inst; - int which; - IFvalue *value; - IFvalue *select; +INDask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, + IFvalue *select) { INDinstance *here = (INDinstance*)inst; double vr; @@ -39,6 +35,18 @@ INDask(ckt,inst,which,value,select) case IND_IC: value->rValue = here->INDinitCond; return(OK); + case IND_TEMP: + value->rValue = here->INDtemp - CONSTCtoK; + return(OK); + case IND_DTEMP: + value->rValue = here->INDdtemp; + return(OK); + case IND_M: + value->rValue = here->INDm; + return(OK); + case IND_SCALE: + value->rValue = here->INDscale; + return(OK); case IND_CURRENT : if (ckt->CKTcurrentAnalysis & DOING_AC) { errMsg = MALLOC(strlen(msg)+1); @@ -47,6 +55,7 @@ INDask(ckt,inst,which,value,select) return(E_ASKCURRENT); } else { value->rValue = *(ckt->CKTrhsOld + here->INDbrEq); + value->rValue *= here->INDm; } return(OK); case IND_POWER : @@ -58,6 +67,7 @@ INDask(ckt,inst,which,value,select) } 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 8a37eb819..5efb2b7e9 100644 --- a/src/spicelib/devices/ind/inddefs.h +++ b/src/spicelib/devices/ind/inddefs.h @@ -32,6 +32,10 @@ typedef struct sINDinstance { int INDbrEq; /* number of the branch equation added for current */ double INDinduct; /* inductance */ + double INDm; /* Parallel multiplier */ + double INDtemp; /* Instance operating temperature */ + double INDdtemp; /* Delta temp. of instance */ + double INDscale; /* Scale factor */ double INDinitCond; /* initial inductor voltage if specified */ double *INDposIbrptr; /* pointer to sparse matrix diagonal at @@ -44,8 +48,13 @@ typedef struct sINDinstance { * (branch eq,positive) */ double *INDibrIbrptr; /* pointer to sparse matrix offdiagonal at * (branch eq,branch eq) */ - unsigned INDindGiven : 1; /* flag to indicate inductance was specified */ - unsigned INDicGiven : 1; /* flag to indicate init. cond. was specified */ + + unsigned INDindGiven : 1; /* flag to indicate inductance was specified */ + unsigned INDicGiven : 1; /* flag to indicate init. cond. was specified */ + unsigned INDmGiven : 1; /* flag to indicate multiplier given */ + unsigned INDtempGiven : 1; /* flag to indicate operating temp. given */ + unsigned INDdtempGiven : 1; /* flag to indicate delta temp. given */ + unsigned INDscaleGiven : 1; /* flsg to indicate scale factor given */ int INDsenParmNo; /* parameter # for sensitivity use; set equal to 0 if not a design parameter*/ @@ -67,6 +76,23 @@ typedef struct sINDmodel { /* model structure for an inductor */ INDinstance * INDinstances; /* pointer to list of instances that have this * model */ IFuid INDmodName; /* pointer to character string naming this model */ + + double INDmInd; /* Model inductance */ + double INDtnom; /* temperature at which inductance measured */ + 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 INDmu; /* Relative magnetic permeability */ + 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 INDmuGiven : 1; /* flag to indicate mu_r given */ + unsigned INDmIndGiven : 1; /* flag to indicate model inductance given */ } INDmodel; @@ -121,8 +147,21 @@ typedef struct sMUTmodel { /* model structure for a mutual inductor */ #define IND_IND_SENS 5 #define IND_CURRENT 6 #define IND_POWER 7 +#define IND_M 8 +#define IND_TEMP 9 +#define IND_DTEMP 10 +#define IND_SCALE 11 /* model parameters */ +#define IND_MOD_IND 100 +#define IND_MOD_TC1 101 +#define IND_MOD_TC2 102 +#define IND_MOD_TNOM 103 +#define IND_MOD_CSECT 104 +#define IND_MOD_LENGTH 105 +#define IND_MOD_N 106 +#define IND_MOD_MU 107 +#define IND_MOD_L 108 /* device questions */ #define IND_QUEST_SENS_REAL 201 diff --git a/src/spicelib/devices/ind/inddel.c b/src/spicelib/devices/ind/inddel.c index 12a449b19..ff30059a0 100644 --- a/src/spicelib/devices/ind/inddel.c +++ b/src/spicelib/devices/ind/inddel.c @@ -12,10 +12,7 @@ Author: 1985 Thomas L. Quarles int -INDdelete(inModel,name,kill) - GENmodel *inModel; - IFuid name; - GENinstance **kill; +INDdelete(GENmodel *inModel, IFuid name, GENinstance **kill) { INDmodel *model = (INDmodel*)inModel; INDinstance **fast = (INDinstance**)kill; diff --git a/src/spicelib/devices/ind/inddest.c b/src/spicelib/devices/ind/inddest.c index d249737bd..eaa1cdecc 100644 --- a/src/spicelib/devices/ind/inddest.c +++ b/src/spicelib/devices/ind/inddest.c @@ -11,8 +11,7 @@ Author: 1985 Thomas L. Quarles void -INDdestroy(inModel) - GENmodel **inModel; +INDdestroy(GENmodel **inModel) { INDmodel **model = (INDmodel**)inModel; INDinstance *here; diff --git a/src/spicelib/devices/ind/indext.h b/src/spicelib/devices/ind/indext.h index 2c08067de..8d2fa035c 100644 --- a/src/spicelib/devices/ind/indext.h +++ b/src/spicelib/devices/ind/indext.h @@ -7,10 +7,12 @@ Author: 1985 Thomas L. Quarles extern int INDacLoad(GENmodel*,CKTcircuit*); extern int INDask(CKTcircuit*,GENinstance*,int,IFvalue*,IFvalue*); +extern int INDmAsk(CKTcircuit*, GENmodel*, int, IFvalue*); extern int INDdelete(GENmodel*,IFuid,GENinstance**); extern void INDdestroy(GENmodel**); extern int INDload(GENmodel*,CKTcircuit*); extern int INDmDelete(GENmodel**,IFuid,GENmodel*); +extern int INDmParam(int, IFvalue*, GENmodel*); extern int INDparam(int,IFvalue*,GENinstance*,IFvalue*); extern int INDpzLoad(GENmodel*,CKTcircuit*,SPcomplex*); extern int INDsAcLoad(GENmodel*,CKTcircuit*); @@ -20,6 +22,7 @@ extern int INDsSetup(SENstruct*,GENmodel*); extern int INDsUpdate(GENmodel*,CKTcircuit*); extern int INDsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); extern int INDunsetup(GENmodel*,CKTcircuit*); +extern int INDtemp(GENmodel*, CKTcircuit*); extern int INDtrunc(GENmodel*,CKTcircuit*,double*); extern int MUTacLoad(GENmodel*,CKTcircuit*); @@ -32,5 +35,5 @@ extern int MUTpzLoad(GENmodel*,CKTcircuit*,SPcomplex*); extern void MUTsPrint(GENmodel*,CKTcircuit*); extern int MUTsSetup(SENstruct*,GENmodel*); extern int MUTsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); - +extern int MUTtemp(GENmodel *inModel, CKTcircuit *ckt); #endif diff --git a/src/spicelib/devices/ind/indinit.c b/src/spicelib/devices/ind/indinit.c index 73a4a8919..9b74897bf 100644 --- a/src/spicelib/devices/ind/indinit.c +++ b/src/spicelib/devices/ind/indinit.c @@ -10,7 +10,7 @@ SPICEdev INDinfo = { { "Inductor", - "Inductors", + "Fixed inductor", &INDnSize, &INDnSize, @@ -19,8 +19,8 @@ SPICEdev INDinfo = { &INDpTSize, INDpTable, - 0, - NULL, + &INDmPTSize, + INDmPTable, #ifdef XSPICE /*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ @@ -40,12 +40,12 @@ SPICEdev INDinfo = { }, DEVparam : INDparam, - DEVmodParam : NULL, + DEVmodParam : INDmParam, DEVload : INDload, DEVsetup : INDsetup, DEVunsetup : INDunsetup, DEVpzSetup : INDsetup, - DEVtemperature: NULL, + DEVtemperature: INDtemp, DEVtrunc : INDtrunc, DEVfindBranch : NULL, DEVacLoad : INDacLoad, @@ -55,7 +55,7 @@ SPICEdev INDinfo = { DEVdelete : INDdelete, DEVsetic : NULL, DEVask : INDask, - DEVmodAsk : NULL, + DEVmodAsk : INDmAsk, DEVpzLoad : INDpzLoad, DEVconvTest : NULL, DEVsenSetup : INDsSetup, @@ -108,34 +108,37 @@ SPICEdev MUTinfo = { 0 }, - MUTparam, - NULL, - NULL,/* load handled by INDload */ - MUTsetup, - NULL, - MUTsetup, - NULL, - NULL, - NULL, - MUTacLoad, - NULL, - MUTdestroy, - MUTmDelete, - MUTdelete, - NULL, - MUTask, - NULL, - MUTpzLoad, - NULL, - MUTsSetup, - NULL, - NULL, - NULL, - MUTsPrint, - NULL, - NULL, /* DISTO */ - NULL, /* NOISE */ - + DEVparam : MUTparam, + DEVmodParam : NULL, + DEVload : NULL,/* load handled by INDload */ + DEVsetup : MUTsetup, + DEVunsetup : NULL, + DEVpzSetup : MUTsetup, + DEVtemperature: MUTtemp, + DEVtrunc : NULL, + DEVfindBranch : NULL, + DEVacLoad : MUTacLoad, + DEVaccept : NULL, + DEVdestroy : MUTdestroy, + DEVmodDelete : MUTmDelete, + DEVdelete : MUTdelete, + DEVsetic : NULL, + DEVask : MUTask, + DEVmodAsk : NULL, + DEVpzLoad : MUTpzLoad, + DEVconvTest : NULL, + DEVsenSetup : MUTsSetup, + DEVsenLoad : NULL, + DEVsenUpdate : NULL, + DEVsenAcLoad : NULL, + DEVsenPrint : MUTsPrint, + DEVsenTrunc : NULL, + DEVdisto : NULL, /* DISTO */ + DEVnoise :NULL, /* NOISE */ +#ifdef CIDER + DEVdump : NULL, + DEVacct : NULL, +#endif &MUTiSize, &MUTmSize diff --git a/src/spicelib/devices/ind/indinit.h b/src/spicelib/devices/ind/indinit.h index 9e4913c68..dafe8e5e4 100644 --- a/src/spicelib/devices/ind/indinit.h +++ b/src/spicelib/devices/ind/indinit.h @@ -2,8 +2,11 @@ #define _INDINIT_H extern IFparm INDpTable[ ]; +extern IFparm INDmPTable[ ]; extern char *INDnames[ ]; extern int INDpTSize; +extern int INDmPTSize; + extern int INDnSize; extern int INDiSize; extern int INDmSize; diff --git a/src/spicelib/devices/ind/indload.c b/src/spicelib/devices/ind/indload.c index 645d5b1c2..ef1fe83d3 100644 --- a/src/spicelib/devices/ind/indload.c +++ b/src/spicelib/devices/ind/indload.c @@ -15,15 +15,14 @@ Author: 1985 Thomas L. Quarles #include "suffix.h" int -INDload(inModel,ckt) - GENmodel *inModel; - CKTcircuit *ckt; +INDload(GENmodel *inModel, CKTcircuit *ckt) { INDmodel *model = (INDmodel*)inModel; INDinstance *here; double veq; double req; int error; + #ifdef MUTUAL MUTinstance *muthere; MUTmodel *mutmodel; @@ -37,6 +36,7 @@ INDload(inModel,ckt) /* loop through all the instances of the model */ for (here = model->INDinstances; here != NULL ; here=here->INDnextInstance) { + if (here->INDowner != ARCHme) continue; if(!(ckt->CKTmode & (MODEDC|MODEINITPRED))) { @@ -59,16 +59,19 @@ INDload(inModel,ckt) /* loop through all the instances of the model */ for (muthere = mutmodel->MUTinstances; muthere != NULL ; muthere=muthere->MUTnextInstance) { + if (muthere->MUTowner != ARCHme) continue; if(!(ckt->CKTmode& (MODEDC|MODEINITPRED))) { - *(ckt->CKTstate0 + muthere->MUTind1->INDflux) += - muthere->MUTfactor * *(ckt->CKTrhsOld+ + *(ckt->CKTstate0 + muthere->MUTind1->INDflux) += + muthere->MUTfactor * *(ckt->CKTrhsOld + muthere->MUTind2->INDbrEq); - *(ckt->CKTstate0 + muthere->MUTind2->INDflux) += - muthere->MUTfactor * *(ckt->CKTrhsOld+ + + *(ckt->CKTstate0 + muthere->MUTind2->INDflux) += + muthere->MUTfactor * *(ckt->CKTrhsOld + muthere->MUTind1->INDbrEq); } + *(muthere->MUTbr1br2) -= muthere->MUTfactor*ckt->CKTag[0]; *(muthere->MUTbr2br1) -= muthere->MUTfactor*ckt->CKTag[0]; } @@ -85,8 +88,8 @@ INDload(inModel,ckt) #endif /*MUTUAL*/ if(ckt->CKTmode & MODEDC) { - req = 0; - veq = 0; + req = 0.0; + veq = 0.0; } else { #ifndef PREDICTOR if(ckt->CKTmode & MODEINITPRED) { @@ -104,16 +107,19 @@ INDload(inModel,ckt) error=NIintegrate(ckt,&req,&veq,here->INDinduct,here->INDflux); if(error) return(error); } + *(ckt->CKTrhs+here->INDbrEq) += veq; - if(ckt->CKTmode & MODEINITTRAN) { + + if(ckt->CKTmode & MODEINITTRAN) { *(ckt->CKTstate1+here->INDvolt) = *(ckt->CKTstate0+here->INDvolt); } - *(here->INDposIbrptr) += 1; - *(here->INDnegIbrptr) -= 1; - *(here->INDibrPosptr) += 1; - *(here->INDibrNegptr) -= 1; - *(here->INDibrIbrptr) -= req; + + *(here->INDposIbrptr) += 1; + *(here->INDnegIbrptr) -= 1; + *(here->INDibrPosptr) += 1; + *(here->INDibrNegptr) -= 1; + *(here->INDibrIbrptr) -= req; } } return(OK); diff --git a/src/spicelib/devices/ind/indmask.c b/src/spicelib/devices/ind/indmask.c new file mode 100644 index 000000000..fd6ee794d --- /dev/null +++ b/src/spicelib/devices/ind/indmask.c @@ -0,0 +1,50 @@ +/********** +Copyright 2003 Paolo Nenzi +Author: 2003 Paolo Nenzi +**********/ +/* + */ + +#include "ngspice.h" +#include "cktdefs.h" +#include "devdefs.h" +#include "inddefs.h" +#include "sperror.h" +#include "ifsim.h" +#include "suffix.h" + + +/* ARGSUSED */ +int +INDmAsk(CKTcircuit *ckt, GENmodel *inst, int which, IFvalue *value) +{ + INDmodel *here = (INDmodel*)inst; + switch(which) { + case IND_MOD_IND: + value->rValue = here->INDmInd; + return(OK); + case IND_MOD_TNOM: + value->rValue = here->INDtnom-CONSTCtoK; + return(OK); + case IND_MOD_TC1: + value->rValue = here->INDtempCoeff1; + return(OK); + case IND_MOD_TC2: + value->rValue = here->INDtempCoeff2; + return(OK); + case IND_MOD_CSECT: + value->rValue = here->INDcsect; + return(OK); + case IND_MOD_LENGTH: + value->rValue = here->INDlength; + return(OK); + case IND_MOD_N: + value->rValue = here->INDn; + return(OK); + case IND_MOD_MU: + value->rValue = here->INDmu; + return(OK); + default: + return(E_BADPARM); + } +} diff --git a/src/spicelib/devices/ind/indmdel.c b/src/spicelib/devices/ind/indmdel.c index a4c84d303..ab8e579a2 100644 --- a/src/spicelib/devices/ind/indmdel.c +++ b/src/spicelib/devices/ind/indmdel.c @@ -12,10 +12,7 @@ Author: 1985 Thomas L. Quarles int -INDmDelete(inModel,modname,kill) - GENmodel **inModel; - IFuid modname; - GENmodel *kill; +INDmDelete(GENmodel **inModel, IFuid modname, GENmodel *kill) { INDmodel **model = (INDmodel**)inModel; INDmodel *modfast = (INDmodel*)kill; diff --git a/src/spicelib/devices/ind/indmpar.c b/src/spicelib/devices/ind/indmpar.c new file mode 100644 index 000000000..b80245c99 --- /dev/null +++ b/src/spicelib/devices/ind/indmpar.c @@ -0,0 +1,61 @@ +/********** +Copyright 2003 Paolo Nenzi +Author: 2003 Paolo Nenzi +**********/ +/* + */ + +#include "ngspice.h" +#include "ifsim.h" +#include "inddefs.h" +#include "sperror.h" +#include "suffix.h" + + +int +INDmParam(int param, IFvalue *value, GENmodel *inModel) +{ + INDmodel *mod = (INDmodel*)inModel; + switch(param) { + case IND_MOD_IND: + mod->INDmInd = value->rValue; + mod->INDmIndGiven = TRUE; + break; + case IND_MOD_TNOM: + mod->INDtnom = value->rValue+CONSTCtoK; + mod->INDtnomGiven = TRUE; + break; + case IND_MOD_TC1: + mod->INDtempCoeff1 = value->rValue; + mod->INDtc1Given = TRUE; + break; + case IND_MOD_TC2: + mod->INDtempCoeff2 = value->rValue; + mod->INDtc2Given = TRUE; + break; + case IND_MOD_CSECT: + mod->INDcsect = value->rValue; + mod->INDcsectGiven = TRUE; + break; + case IND_MOD_LENGTH : + mod->INDlength = value->rValue; + mod->INDlengthGiven = TRUE; + break; + case IND_MOD_N : + mod->INDn = value->rValue; + mod->INDnGiven = TRUE; + break; + case IND_MOD_MU: + mod->INDmu = value->rValue; + mod->INDmuGiven = TRUE; + break; + case IND_MOD_L: + /* just being reassured by the user that we are an inductor */ + /* no-op */ + break; + default: + return(E_BADPARM); + } + return(OK); +} + diff --git a/src/spicelib/devices/ind/indparam.c b/src/spicelib/devices/ind/indparam.c index ff2f7bc5d..faa0be3ab 100644 --- a/src/spicelib/devices/ind/indparam.c +++ b/src/spicelib/devices/ind/indparam.c @@ -14,18 +14,30 @@ Author: 1985 Thomas L. Quarles /* ARGSUSED */ int -INDparam(param,value,inst,select) - int param; - IFvalue *value; - GENinstance *inst; - IFvalue *select; +INDparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select) { INDinstance *here = (INDinstance*)inst; switch(param) { case IND_IND: here->INDinduct = value->rValue; here->INDindGiven = TRUE; + break; + case IND_TEMP: + here->INDtemp = value->rValue + CONSTCtoK; + here->INDtempGiven = TRUE; break; + case IND_DTEMP: + here->INDdtemp = value->rValue; + here->INDdtempGiven = TRUE; + break; + case IND_M: + here->INDm = value->rValue; + here->INDmGiven = TRUE; + break; + case IND_SCALE: + here->INDscale = value->rValue; + here->INDscaleGiven = TRUE; + break; case IND_IC: here->INDinitCond = value->rValue; here->INDicGiven = TRUE; diff --git a/src/spicelib/devices/ind/indpzld.c b/src/spicelib/devices/ind/indpzld.c index 10388522b..2b7e8ef51 100644 --- a/src/spicelib/devices/ind/indpzld.c +++ b/src/spicelib/devices/ind/indpzld.c @@ -15,10 +15,7 @@ Author: 1985 Thomas L. Quarles /* ARGSUSED */ int -INDpzLoad(inModel,ckt,s) - GENmodel *inModel; - CKTcircuit *ckt; - SPcomplex *s; +INDpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) { INDmodel *model = (INDmodel*)inModel; double val; @@ -27,14 +24,16 @@ INDpzLoad(inModel,ckt,s) for( ; model != NULL; model = model->INDnextModel) { for( here = model->INDinstances;here != NULL; here = here->INDnextInstance) { + if (here->INDowner != ARCHme) continue; val = here->INDinduct; - *(here->INDposIbrptr) += 1; - *(here->INDnegIbrptr) -= 1; - *(here->INDibrPosptr) += 1; - *(here->INDibrNegptr) -= 1; - *(here->INDibrIbrptr ) -= val * s->real; + + *(here->INDposIbrptr) += 1; + *(here->INDnegIbrptr) -= 1; + *(here->INDibrPosptr) += 1; + *(here->INDibrNegptr) -= 1; + *(here->INDibrIbrptr ) -= val * s->real; *(here->INDibrIbrptr +1) -= val * s->imag; } } diff --git a/src/spicelib/devices/ind/indsacl.c b/src/spicelib/devices/ind/indsacl.c index 1885bf83e..7f0a51695 100644 --- a/src/spicelib/devices/ind/indsacl.c +++ b/src/spicelib/devices/ind/indsacl.c @@ -15,9 +15,7 @@ Author: 1985 Thomas L. Quarles #include "suffix.h" int -INDsAcLoad(inModel,ckt) - GENmodel *inModel; - CKTcircuit *ckt; +INDsAcLoad(GENmodel *inModel, CKTcircuit *ckt) { INDmodel *model = (INDmodel*)inModel; INDinstance *here; diff --git a/src/spicelib/devices/ind/indsetup.c b/src/spicelib/devices/ind/indsetup.c index 3e54ec7fb..2efc4c7b3 100644 --- a/src/spicelib/devices/ind/indsetup.c +++ b/src/spicelib/devices/ind/indsetup.c @@ -11,11 +11,7 @@ Author: 1985 Thomas L. Quarles #include "suffix.h" int -INDsetup(matrix,inModel,ckt,states) - SMPmatrix *matrix; - GENmodel *inModel; - CKTcircuit *ckt; - int *states; +INDsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) /* load the inductor structure with those pointers needed later * for fast matrix loading */ @@ -27,7 +23,51 @@ INDsetup(matrix,inModel,ckt,states) /* loop through all the inductor models */ for( ; model != NULL; model = model->INDnextModel ) { - + + /* Default Value Processing for Model Parameters */ + if (!model->INDmIndGiven) { + model->INDmInd = 0.0; + } + if (!model->INDtnomGiven) { + model->INDtnom = ckt->CKTnomTemp; + } + if (!model->INDtc1Given) { + model->INDtempCoeff1 = 0.0; + } + if (!model->INDtc2Given) { + model->INDtempCoeff2 = 0.0; + } + if (!model->INDcsectGiven){ + model->INDcsect = 0.0; + } + if (!model->INDlengthGiven) { + model->INDlength = 0.0; + } + if (!model->INDnGiven) { + model->INDn = 0.0; + } + if (!model->INDmuGiven) { + model->INDmu = 0.0; + } + + if (!model->INDmIndGiven) { + 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; + + } else { + model->INDmInd = 0.0; + } + } /* loop through all the instances of the model */ for (here = model->INDinstances; here != NULL ; here=here->INDnextInstance) { @@ -63,9 +103,7 @@ if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NULL){\ } int -INDunsetup(inModel,ckt) - GENmodel *inModel; - CKTcircuit *ckt; +INDunsetup(GENmodel *inModel, CKTcircuit *ckt) { INDmodel *model; INDinstance *here; diff --git a/src/spicelib/devices/ind/indsload.c b/src/spicelib/devices/ind/indsload.c index fdcba9369..b9e3f3555 100644 --- a/src/spicelib/devices/ind/indsload.c +++ b/src/spicelib/devices/ind/indsload.c @@ -15,9 +15,7 @@ Author: 1985 Thomas L. Quarles #include "suffix.h" int -INDsLoad(inModel,ckt) - GENmodel *inModel; - CKTcircuit *ckt; +INDsLoad(GENmodel *inModel, CKTcircuit *ckt) { INDmodel *model = (INDmodel*)inModel; INDinstance *here; diff --git a/src/spicelib/devices/ind/indsprt.c b/src/spicelib/devices/ind/indsprt.c index 7597283d9..f35905837 100644 --- a/src/spicelib/devices/ind/indsprt.c +++ b/src/spicelib/devices/ind/indsprt.c @@ -15,9 +15,7 @@ Author: 1985 Thomas L. Quarles #include "suffix.h" void -INDsPrint(inModel,ckt) -GENmodel *inModel; -CKTcircuit *ckt; +INDsPrint(GENmodel *inModel, CKTcircuit *ckt) { INDmodel *model = (INDmodel*)inModel; INDinstance *here; diff --git a/src/spicelib/devices/ind/indsset.c b/src/spicelib/devices/ind/indsset.c index 7a443290c..faf79ee64 100644 --- a/src/spicelib/devices/ind/indsset.c +++ b/src/spicelib/devices/ind/indsset.c @@ -15,9 +15,7 @@ Author: 1985 Thomas L. Quarles #include "suffix.h" int -INDsSetup(info,inModel) - SENstruct *info; - GENmodel *inModel; +INDsSetup(SENstruct *info, GENmodel *inModel) { INDmodel *model = (INDmodel*)inModel; INDinstance *here; diff --git a/src/spicelib/devices/ind/indsupd.c b/src/spicelib/devices/ind/indsupd.c index 593883f02..f23bcb04a 100644 --- a/src/spicelib/devices/ind/indsupd.c +++ b/src/spicelib/devices/ind/indsupd.c @@ -13,9 +13,7 @@ Author: 1985 Thomas L. Quarles #include "suffix.h" int -INDsUpdate(inModel,ckt) - GENmodel *inModel; - CKTcircuit *ckt; +INDsUpdate(GENmodel *inModel, CKTcircuit *ckt) { INDmodel *model = (INDmodel*)inModel; INDinstance *here; diff --git a/src/spicelib/devices/ind/indtemp.c b/src/spicelib/devices/ind/indtemp.c new file mode 100644 index 000000000..981589c32 --- /dev/null +++ b/src/spicelib/devices/ind/indtemp.c @@ -0,0 +1,63 @@ +/********** +Copyright 2003 Paolo Nenzi +Author: 2003 Paolo Nenzi +**********/ +/* + */ + + +#include "ngspice.h" +#include "cktdefs.h" +#include "inddefs.h" +#include "sperror.h" +#include "suffix.h" + + +/*ARGSUSED*/ +int +INDtemp(GENmodel *inModel, CKTcircuit *ckt) +{ + INDmodel *model = (INDmodel*)inModel; + INDinstance *here; + double difference; + double factor; + + /* loop through all the inductor models */ + for( ; model != NULL; model = model->INDnextModel ) { + + /* loop through all the instances of the model */ + for (here = model->INDinstances; here != NULL ; + here=here->INDnextInstance) { + if (here->INDowner != ARCHme) continue; + + /* Default Value Processing for Inductor Instance */ + + if(!here->INDtempGiven) { + here->INDtemp = ckt->CKTtemp; + if(!here->INDdtempGiven) here->INDdtemp = 0.0; + } else { /* INDtempGiven */ + here->INDdtemp = 0.0; + if (here->INDdtempGiven) + printf("%s: Instance temperature specified, dtemp ignored\n", + here->INDname); + } + + if (!here->INDscaleGiven) here->INDscale = 1.0; + if (!here->INDmGiven) here->INDm = 1.0; + + if (!here->INDindGiven) /* No instance inductance given */ + here->INDinduct = model->INDmInd; + + difference = (here->INDtemp + here->INDdtemp) - model->INDtnom; + + factor = 1.0 + (model->INDtempCoeff1)*difference + + (model->INDtempCoeff2)*difference*difference; + + here->INDinduct = here->INDinduct * factor * here->INDscale; + here->INDinduct = here->INDinduct / here->INDm; + + } + } + return(OK); +} + diff --git a/src/spicelib/devices/ind/indtrunc.c b/src/spicelib/devices/ind/indtrunc.c index d391dcac1..5a3946294 100644 --- a/src/spicelib/devices/ind/indtrunc.c +++ b/src/spicelib/devices/ind/indtrunc.c @@ -13,10 +13,7 @@ Author: 1985 Thomas L. Quarles int -INDtrunc(inModel,ckt,timeStep) - GENmodel *inModel; - CKTcircuit *ckt; - double *timeStep; +INDtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) { INDmodel *model = (INDmodel*)inModel; INDinstance *here; diff --git a/src/spicelib/devices/ind/mutacld.c b/src/spicelib/devices/ind/mutacld.c index f6e91fd51..432f0cccd 100644 --- a/src/spicelib/devices/ind/mutacld.c +++ b/src/spicelib/devices/ind/mutacld.c @@ -14,9 +14,7 @@ Author: 1985 Thomas L. Quarles #ifdef MUTUAL int -MUTacLoad(inModel,ckt) - GENmodel *inModel; - CKTcircuit *ckt; +MUTacLoad(GENmodel *inModel, CKTcircuit *ckt) { MUTmodel *model = (MUTmodel*)inModel; double val; diff --git a/src/spicelib/devices/ind/mutask.c b/src/spicelib/devices/ind/mutask.c index dd0cf42ac..534c92d17 100644 --- a/src/spicelib/devices/ind/mutask.c +++ b/src/spicelib/devices/ind/mutask.c @@ -14,12 +14,8 @@ Author: 1985 Thomas L. Quarles /*ARGSUSED*/ int -MUTask(ckt,inst,which,value,select) - CKTcircuit *ckt; - GENinstance *inst; - int which; - IFvalue *value; - IFvalue *select; +MUTask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, + IFvalue *select) { MUTinstance *here = (MUTinstance*)inst; double vr; diff --git a/src/spicelib/devices/ind/mutdel.c b/src/spicelib/devices/ind/mutdel.c index 78ad9019b..1d21ab4c3 100644 --- a/src/spicelib/devices/ind/mutdel.c +++ b/src/spicelib/devices/ind/mutdel.c @@ -13,10 +13,7 @@ Author: 1985 Thomas L. Quarles #ifdef MUTUAL int -MUTdelete(inModel,name,kill) - GENmodel *inModel; - IFuid name; - GENinstance **kill; +MUTdelete(GENmodel *inModel, IFuid name, GENinstance **kill) { MUTmodel *model = (MUTmodel*)inModel; MUTinstance **fast = (MUTinstance**)kill; diff --git a/src/spicelib/devices/ind/mutdest.c b/src/spicelib/devices/ind/mutdest.c index 6034e1fd7..804ef9011 100644 --- a/src/spicelib/devices/ind/mutdest.c +++ b/src/spicelib/devices/ind/mutdest.c @@ -12,8 +12,7 @@ Author: 1985 Thomas L. Quarles #ifdef MUTUAL void -MUTdestroy(inModel) - GENmodel **inModel; +MUTdestroy(GENmodel **inModel) { MUTmodel **model = (MUTmodel**)inModel; MUTinstance *here; diff --git a/src/spicelib/devices/ind/mutmdel.c b/src/spicelib/devices/ind/mutmdel.c index fe11a2227..5fb5321cd 100644 --- a/src/spicelib/devices/ind/mutmdel.c +++ b/src/spicelib/devices/ind/mutmdel.c @@ -13,10 +13,7 @@ Author: 1985 Thomas L. Quarles #ifdef MUTUAL int -MUTmDelete(inModel,modname,kill) - GENmodel **inModel; - IFuid modname; - GENmodel *kill; +MUTmDelete(GENmodel **inModel, IFuid modname, GENmodel *kill) { MUTmodel **model = (MUTmodel**)inModel; MUTmodel *modfast = (MUTmodel*)kill; diff --git a/src/spicelib/devices/ind/mutparam.c b/src/spicelib/devices/ind/mutparam.c index d26d37500..440cf8d94 100644 --- a/src/spicelib/devices/ind/mutparam.c +++ b/src/spicelib/devices/ind/mutparam.c @@ -15,11 +15,7 @@ Author: 1985 Thomas L. Quarles #ifdef MUTUAL /* ARGSUSED */ int -MUTparam(param,value,inst,select) - int param; - IFvalue *value; - GENinstance *inst; - IFvalue *select; +MUTparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select) { MUTinstance *here = (MUTinstance*)inst; switch(param) { diff --git a/src/spicelib/devices/ind/mutpzld.c b/src/spicelib/devices/ind/mutpzld.c index 87f273a3f..82586c57b 100644 --- a/src/spicelib/devices/ind/mutpzld.c +++ b/src/spicelib/devices/ind/mutpzld.c @@ -16,10 +16,7 @@ Author: 1985 Thomas L. Quarles #ifdef MUTUAL /* ARGSUSED */ int -MUTpzLoad(inModel,ckt,s) - GENmodel *inModel; - CKTcircuit *ckt; - SPcomplex *s; +MUTpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) { MUTmodel *model = (MUTmodel*)inModel; double val; diff --git a/src/spicelib/devices/ind/mutsetup.c b/src/spicelib/devices/ind/mutsetup.c index cdc23e1b3..d16a1c529 100644 --- a/src/spicelib/devices/ind/mutsetup.c +++ b/src/spicelib/devices/ind/mutsetup.c @@ -19,11 +19,7 @@ Author: 1985 Thomas L. Quarles #ifdef MUTUAL /*ARGSUSED*/ int -MUTsetup(matrix,inModel,ckt,states) - SMPmatrix *matrix; - GENmodel *inModel; - CKTcircuit *ckt; - int *states; +MUTsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) { MUTmodel *model = (MUTmodel*)inModel; MUTinstance *here; @@ -68,9 +64,6 @@ MUTsetup(matrix,inModel,ckt,states) namarray); } - here->MUTfactor = here->MUTcoupling *sqrt(here->MUTind1->INDinduct * - here->MUTind2->INDinduct); - /* macro to make elements with built in test for out of memory */ #define TSTALLOC(ptr,first,second) \ diff --git a/src/spicelib/devices/ind/mutsprt.c b/src/spicelib/devices/ind/mutsprt.c index 9b2da891b..2211cea77 100644 --- a/src/spicelib/devices/ind/mutsprt.c +++ b/src/spicelib/devices/ind/mutsprt.c @@ -18,9 +18,7 @@ Author: 1985 Thomas L. Quarles #ifdef MUTUAL /* ARGSUSED */ void -MUTsPrint(inModel,ckt) - GENmodel *inModel; - CKTcircuit* ckt; +MUTsPrint(GENmodel *inModel, CKTcircuit* ckt) { MUTmodel *model = (MUTmodel*)inModel; MUTinstance *here; diff --git a/src/spicelib/devices/ind/mutsset.c b/src/spicelib/devices/ind/mutsset.c index 2dc9e865f..fdbf124d1 100644 --- a/src/spicelib/devices/ind/mutsset.c +++ b/src/spicelib/devices/ind/mutsset.c @@ -18,9 +18,7 @@ Author: 1985 Thomas L. Quarles #ifdef MUTUAL /*ARGSUSED*/ int -MUTsSetup(info,inModel) - SENstruct *info; - GENmodel *inModel; +MUTsSetup(SENstruct *info, GENmodel *inModel) { MUTmodel *model = (MUTmodel*)inModel; MUTinstance *here; diff --git a/src/spicelib/devices/ind/muttemp.c b/src/spicelib/devices/ind/muttemp.c new file mode 100644 index 000000000..e9b5241e6 --- /dev/null +++ b/src/spicelib/devices/ind/muttemp.c @@ -0,0 +1,44 @@ +/********** +Copyright 2003 Paolo Nenzi +Author: 2003 Paolo Nenzi +**********/ +/* + */ + + +#include "ngspice.h" +#include "cktdefs.h" +#include "inddefs.h" +#include "sperror.h" +#include "suffix.h" + + +/*ARGSUSED*/ +int +MUTtemp(GENmodel *inModel, CKTcircuit *ckt) +{ + MUTmodel *model = (MUTmodel*)inModel; + MUTinstance *here; + double ind1, ind2; + + /* loop through all the inductor models */ + for( ; model != NULL; model = model->MUTnextModel ) { + + /* loop through all the instances of the model */ + for (here = model->MUTinstances; here != NULL ; + here=here->MUTnextInstance) { + if (here->MUTowner != ARCHme) continue; + + /* Value Processing for mutual inductors */ + + ind1 = here->MUTind1->INDinduct; + ind2 = here->MUTind2->INDinduct; + + + here->MUTfactor = here->MUTcoupling * sqrt(ind1 * ind2); + + } + } + return(OK); +} +