devices/ind/*, cleanup
This commit is contained in:
parent
0c5196e773
commit
24aee8bf2a
|
|
@ -15,14 +15,19 @@ Author: 1985 Thomas L. Quarles
|
||||||
#include "ngspice/gendefs.h"
|
#include "ngspice/gendefs.h"
|
||||||
#include "ngspice/cktdefs.h"
|
#include "ngspice/cktdefs.h"
|
||||||
|
|
||||||
|
typedef struct sINDinstance INDinstance;
|
||||||
|
typedef struct sINDmodel INDmodel;
|
||||||
|
typedef struct sMUTinstance MUTinstance;
|
||||||
|
typedef struct sMUTmodel MUTmodel;
|
||||||
|
|
||||||
/* structures used to descrive inductors */
|
/* structures used to descrive inductors */
|
||||||
|
|
||||||
|
|
||||||
/* information needed for each instance */
|
/* information needed for each instance */
|
||||||
|
|
||||||
typedef struct sINDinstance {
|
struct sINDinstance {
|
||||||
struct sINDmodel *INDmodPtr; /* backpointer to model */
|
INDmodel *INDmodPtr; /* backpointer to model */
|
||||||
struct sINDinstance *INDnextInstance; /* pointer to next instance of
|
INDinstance *INDnextInstance; /* pointer to next instance of
|
||||||
* current model*/
|
* current model*/
|
||||||
IFuid INDname; /* pointer to character string naming this instance */
|
IFuid INDname; /* pointer to character string naming this instance */
|
||||||
int INDstate; /* pointer to beginning of state vector for inductor */
|
int INDstate; /* pointer to beginning of state vector for inductor */
|
||||||
|
|
@ -63,7 +68,7 @@ typedef struct sINDinstance {
|
||||||
int INDsenParmNo; /* parameter # for sensitivity use;
|
int INDsenParmNo; /* parameter # for sensitivity use;
|
||||||
set equal to 0 if not a design parameter*/
|
set equal to 0 if not a design parameter*/
|
||||||
|
|
||||||
} INDinstance ;
|
};
|
||||||
|
|
||||||
#define INDflux INDstate /* flux in the inductor */
|
#define INDflux INDstate /* flux in the inductor */
|
||||||
#define INDvolt INDstate+1 /* voltage - save an entry in table */
|
#define INDvolt INDstate+1 /* voltage - save an entry in table */
|
||||||
|
|
@ -74,9 +79,9 @@ beginning of the array */
|
||||||
|
|
||||||
/* per model data */
|
/* per model data */
|
||||||
|
|
||||||
typedef struct sINDmodel { /* model structure for an inductor */
|
struct sINDmodel { /* model structure for an inductor */
|
||||||
int INDmodType; /* type index of this device type */
|
int INDmodType; /* type index of this device type */
|
||||||
struct sINDmodel *INDnextModel; /* pointer to next possible model in
|
INDmodel *INDnextModel; /* pointer to next possible model in
|
||||||
* linked list */
|
* linked list */
|
||||||
INDinstance * INDinstances; /* pointer to list of instances that have this
|
INDinstance * INDinstances; /* pointer to list of instances that have this
|
||||||
* model */
|
* model */
|
||||||
|
|
@ -103,7 +108,7 @@ typedef struct sINDmodel { /* model structure for an inductor */
|
||||||
unsigned INDmIndGiven : 1; /* flag to indicate model inductance given */
|
unsigned INDmIndGiven : 1; /* flag to indicate model inductance given */
|
||||||
|
|
||||||
double INDspecInd; /* Specific (one turn) inductance */
|
double INDspecInd; /* Specific (one turn) inductance */
|
||||||
} INDmodel;
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef MUTUAL
|
#ifdef MUTUAL
|
||||||
|
|
@ -113,9 +118,9 @@ typedef struct sINDmodel { /* model structure for an inductor */
|
||||||
|
|
||||||
/* information needed for each instance */
|
/* information needed for each instance */
|
||||||
|
|
||||||
typedef struct sMUTinstance {
|
struct sMUTinstance {
|
||||||
struct sMUTmodel *MUTmodPtr; /* backpointer to model */
|
MUTmodel *MUTmodPtr; /* backpointer to model */
|
||||||
struct sMUTinstance *MUTnextInstance; /* pointer to next instance of
|
MUTinstance *MUTnextInstance; /* pointer to next instance of
|
||||||
* current model*/
|
* current model*/
|
||||||
IFuid MUTname; /* pointer to character string naming this instance */
|
IFuid MUTname; /* pointer to character string naming this instance */
|
||||||
double MUTcoupling; /* mutual inductance input by user */
|
double MUTcoupling; /* mutual inductance input by user */
|
||||||
|
|
@ -132,14 +137,14 @@ int MUTsenParmNo; /* parameter # for sensitivity use;
|
||||||
set equal to 0 if not a design parameter*/
|
set equal to 0 if not a design parameter*/
|
||||||
|
|
||||||
|
|
||||||
} MUTinstance ;
|
};
|
||||||
|
|
||||||
|
|
||||||
/* per model data */
|
/* per model data */
|
||||||
|
|
||||||
typedef struct sMUTmodel { /* model structure for a mutual inductor */
|
struct sMUTmodel { /* model structure for a mutual inductor */
|
||||||
int MUTmodType; /* type index of this device type */
|
int MUTmodType; /* type index of this device type */
|
||||||
struct sMUTmodel *MUTnextModel; /* pointer to next possible model in
|
MUTmodel *MUTnextModel; /* pointer to next possible model in
|
||||||
* linked list */
|
* linked list */
|
||||||
MUTinstance * MUTinstances; /* pointer to list of instances that have this
|
MUTinstance * MUTinstances; /* pointer to list of instances that have this
|
||||||
* model */
|
* model */
|
||||||
|
|
@ -147,7 +152,7 @@ IFuid MUTmodName; /* pointer to character string naming this model */
|
||||||
|
|
||||||
/* --- end of generic struct GENmodel --- */
|
/* --- end of generic struct GENmodel --- */
|
||||||
|
|
||||||
} MUTmodel;
|
};
|
||||||
|
|
||||||
#endif /*MUTUAL*/
|
#endif /*MUTUAL*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,25 +16,27 @@ Author: 1985 Thomas L. Quarles
|
||||||
#include "ngspice/suffix.h"
|
#include "ngspice/suffix.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define TSTALLOC(ptr, first, second) \
|
||||||
|
do { \
|
||||||
|
if ((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL) { \
|
||||||
|
return(E_NOMEM); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
|
||||||
#ifdef MUTUAL
|
#ifdef MUTUAL
|
||||||
/*ARGSUSED*/
|
|
||||||
int
|
int
|
||||||
MUTsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
MUTsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
{
|
{
|
||||||
MUTmodel *model = (MUTmodel*)inModel;
|
MUTmodel *model = (MUTmodel*)inModel;
|
||||||
MUTinstance *here;
|
MUTinstance *here;
|
||||||
int ktype;
|
|
||||||
|
|
||||||
NG_IGNORE(states);
|
NG_IGNORE(states);
|
||||||
|
|
||||||
/* loop through all the inductor models */
|
for (; model; model = model->MUTnextModel)
|
||||||
for( ; model != NULL; model = model->MUTnextModel ) {
|
for (here = model->MUTinstances; here; here = here->MUTnextInstance) {
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
int ktype = CKTtypelook("Inductor");
|
||||||
for (here = model->MUTinstances; here != NULL ;
|
|
||||||
here=here->MUTnextInstance) {
|
|
||||||
|
|
||||||
ktype = CKTtypelook("Inductor");
|
|
||||||
if(ktype <= 0) {
|
if(ktype <= 0) {
|
||||||
SPfrontEnd->IFerrorf (ERR_PANIC,
|
SPfrontEnd->IFerrorf (ERR_PANIC,
|
||||||
"mutual inductor, but inductors not available!");
|
"mutual inductor, but inductors not available!");
|
||||||
|
|
@ -56,17 +58,9 @@ MUTsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
here->MUTname, here->MUTindName2);
|
here->MUTname, here->MUTindName2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* macro to make elements with built in test for out of memory */
|
|
||||||
#define TSTALLOC(ptr,first,second) \
|
|
||||||
do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\
|
|
||||||
return(E_NOMEM);\
|
|
||||||
} } while(0)
|
|
||||||
|
|
||||||
TSTALLOC(MUTbr1br2,MUTind1->INDbrEq,MUTind2->INDbrEq);
|
TSTALLOC(MUTbr1br2,MUTind1->INDbrEq,MUTind2->INDbrEq);
|
||||||
TSTALLOC(MUTbr2br1,MUTind2->INDbrEq,MUTind1->INDbrEq);
|
TSTALLOC(MUTbr2br1,MUTind2->INDbrEq,MUTind1->INDbrEq);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return(OK);
|
return(OK);
|
||||||
}
|
}
|
||||||
#endif /* MUTUAL */
|
#endif /* MUTUAL */
|
||||||
|
|
|
||||||
|
|
@ -19,21 +19,16 @@ MUTtemp(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
{
|
{
|
||||||
MUTmodel *model = (MUTmodel*)inModel;
|
MUTmodel *model = (MUTmodel*)inModel;
|
||||||
MUTinstance *here;
|
MUTinstance *here;
|
||||||
double ind1, ind2;
|
|
||||||
|
|
||||||
NG_IGNORE(ckt);
|
NG_IGNORE(ckt);
|
||||||
|
|
||||||
/* loop through all the inductor models */
|
for (; model; model = model->MUTnextModel)
|
||||||
for( ; model != NULL; model = model->MUTnextModel ) {
|
for (here = model->MUTinstances; here; here = here->MUTnextInstance) {
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
|
||||||
for (here = model->MUTinstances; here != NULL ;
|
|
||||||
here=here->MUTnextInstance) {
|
|
||||||
|
|
||||||
/* Value Processing for mutual inductors */
|
/* Value Processing for mutual inductors */
|
||||||
|
|
||||||
ind1 = here->MUTind1->INDinduct;
|
double ind1 = here->MUTind1->INDinduct;
|
||||||
ind2 = here->MUTind2->INDinduct;
|
double ind2 = here->MUTind2->INDinduct;
|
||||||
|
|
||||||
/* _______
|
/* _______
|
||||||
* M = k * \/l1 * l2
|
* M = k * \/l1 * l2
|
||||||
|
|
@ -41,6 +36,5 @@ MUTtemp(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
here->MUTfactor = here->MUTcoupling * sqrt(ind1 * ind2);
|
here->MUTfactor = here->MUTcoupling * sqrt(ind1 * ind2);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return(OK);
|
return(OK);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue