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/cktdefs.h"
|
||||
|
||||
typedef struct sINDinstance INDinstance;
|
||||
typedef struct sINDmodel INDmodel;
|
||||
typedef struct sMUTinstance MUTinstance;
|
||||
typedef struct sMUTmodel MUTmodel;
|
||||
|
||||
/* structures used to descrive inductors */
|
||||
|
||||
|
||||
/* information needed for each instance */
|
||||
|
||||
typedef struct sINDinstance {
|
||||
struct sINDmodel *INDmodPtr; /* backpointer to model */
|
||||
struct sINDinstance *INDnextInstance; /* pointer to next instance of
|
||||
struct sINDinstance {
|
||||
INDmodel *INDmodPtr; /* backpointer to model */
|
||||
INDinstance *INDnextInstance; /* pointer to next instance of
|
||||
* current model*/
|
||||
IFuid INDname; /* pointer to character string naming this instance */
|
||||
int INDstate; /* pointer to beginning of state vector for inductor */
|
||||
|
|
@ -63,7 +68,7 @@ typedef struct sINDinstance {
|
|||
int INDsenParmNo; /* parameter # for sensitivity use;
|
||||
set equal to 0 if not a design parameter*/
|
||||
|
||||
} INDinstance ;
|
||||
};
|
||||
|
||||
#define INDflux INDstate /* flux in the inductor */
|
||||
#define INDvolt INDstate+1 /* voltage - save an entry in table */
|
||||
|
|
@ -74,9 +79,9 @@ beginning of the array */
|
|||
|
||||
/* 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 */
|
||||
struct sINDmodel *INDnextModel; /* pointer to next possible model in
|
||||
INDmodel *INDnextModel; /* pointer to next possible model in
|
||||
* linked list */
|
||||
INDinstance * INDinstances; /* pointer to list of instances that have this
|
||||
* model */
|
||||
|
|
@ -103,7 +108,7 @@ typedef struct sINDmodel { /* model structure for an inductor */
|
|||
unsigned INDmIndGiven : 1; /* flag to indicate model inductance given */
|
||||
|
||||
double INDspecInd; /* Specific (one turn) inductance */
|
||||
} INDmodel;
|
||||
};
|
||||
|
||||
|
||||
#ifdef MUTUAL
|
||||
|
|
@ -113,9 +118,9 @@ typedef struct sINDmodel { /* model structure for an inductor */
|
|||
|
||||
/* information needed for each instance */
|
||||
|
||||
typedef struct sMUTinstance {
|
||||
struct sMUTmodel *MUTmodPtr; /* backpointer to model */
|
||||
struct sMUTinstance *MUTnextInstance; /* pointer to next instance of
|
||||
struct sMUTinstance {
|
||||
MUTmodel *MUTmodPtr; /* backpointer to model */
|
||||
MUTinstance *MUTnextInstance; /* pointer to next instance of
|
||||
* current model*/
|
||||
IFuid MUTname; /* pointer to character string naming this instance */
|
||||
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*/
|
||||
|
||||
|
||||
} MUTinstance ;
|
||||
};
|
||||
|
||||
|
||||
/* 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 */
|
||||
struct sMUTmodel *MUTnextModel; /* pointer to next possible model in
|
||||
MUTmodel *MUTnextModel; /* pointer to next possible model in
|
||||
* linked list */
|
||||
MUTinstance * MUTinstances; /* pointer to list of instances that have this
|
||||
* model */
|
||||
|
|
@ -147,7 +152,7 @@ IFuid MUTmodName; /* pointer to character string naming this model */
|
|||
|
||||
/* --- end of generic struct GENmodel --- */
|
||||
|
||||
} MUTmodel;
|
||||
};
|
||||
|
||||
#endif /*MUTUAL*/
|
||||
|
||||
|
|
|
|||
|
|
@ -16,25 +16,27 @@ Author: 1985 Thomas L. Quarles
|
|||
#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
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
MUTsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||
{
|
||||
MUTmodel *model = (MUTmodel*)inModel;
|
||||
MUTinstance *here;
|
||||
int ktype;
|
||||
|
||||
NG_IGNORE(states);
|
||||
|
||||
/* 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) {
|
||||
for (; model; model = model->MUTnextModel)
|
||||
for (here = model->MUTinstances; here; here = here->MUTnextInstance) {
|
||||
|
||||
ktype = CKTtypelook("Inductor");
|
||||
int ktype = CKTtypelook("Inductor");
|
||||
if(ktype <= 0) {
|
||||
SPfrontEnd->IFerrorf (ERR_PANIC,
|
||||
"mutual inductor, but inductors not available!");
|
||||
|
|
@ -56,17 +58,9 @@ MUTsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
|||
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(MUTbr2br1,MUTind2->INDbrEq,MUTind1->INDbrEq);
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
}
|
||||
#endif /* MUTUAL */
|
||||
|
|
|
|||
|
|
@ -19,21 +19,16 @@ MUTtemp(GENmodel *inModel, CKTcircuit *ckt)
|
|||
{
|
||||
MUTmodel *model = (MUTmodel*)inModel;
|
||||
MUTinstance *here;
|
||||
double ind1, ind2;
|
||||
|
||||
NG_IGNORE(ckt);
|
||||
|
||||
/* 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) {
|
||||
for (; model; model = model->MUTnextModel)
|
||||
for (here = model->MUTinstances; here; here = here->MUTnextInstance) {
|
||||
|
||||
/* Value Processing for mutual inductors */
|
||||
|
||||
ind1 = here->MUTind1->INDinduct;
|
||||
ind2 = here->MUTind2->INDinduct;
|
||||
double ind1 = here->MUTind1->INDinduct;
|
||||
double ind2 = here->MUTind2->INDinduct;
|
||||
|
||||
/* _______
|
||||
* M = k * \/l1 * l2
|
||||
|
|
@ -41,6 +36,5 @@ MUTtemp(GENmodel *inModel, CKTcircuit *ckt)
|
|||
here->MUTfactor = here->MUTcoupling * sqrt(ind1 * ind2);
|
||||
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue