devices/isrc: implement multiplier `m' for current sources
This commit is contained in:
parent
56449f54a3
commit
6801f77cc1
|
|
@ -11,6 +11,7 @@ Author: 1987 Thomas L. Quarles
|
|||
|
||||
IFparm ISRCpTable[] = { /* parameters */
|
||||
IOPP("dc", ISRC_DC, IF_REAL ,"DC value of source"),
|
||||
IOP ( "m", ISRC_M, IF_REAL ,"Parallel multiplier"),
|
||||
IOPPA("acmag", ISRC_AC_MAG, IF_REAL ,"AC Magnitude"),
|
||||
IOPAAU("acphase", ISRC_AC_PHASE, IF_REAL ,"AC Phase"),
|
||||
/* Modified to allow print @Iin[sin] A.Roldan */
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ ISRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
|||
{
|
||||
ISRCmodel *model = (ISRCmodel *) inModel;
|
||||
ISRCinstance *here;
|
||||
double m;
|
||||
|
||||
for( ; model != NULL; model = model->ISRCnextModel ) {
|
||||
|
||||
|
|
@ -22,14 +23,16 @@ ISRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
|||
for (here = model->ISRCinstances; here != NULL ;
|
||||
here=here->ISRCnextInstance) {
|
||||
|
||||
m = here->ISRCmValue;
|
||||
|
||||
*(ckt->CKTrhs + (here->ISRCposNode)) +=
|
||||
here->ISRCacReal;
|
||||
m * here->ISRCacReal;
|
||||
*(ckt->CKTrhs + (here->ISRCnegNode)) -=
|
||||
here->ISRCacReal;
|
||||
m * here->ISRCacReal;
|
||||
*(ckt->CKTirhs + (here->ISRCposNode)) +=
|
||||
here->ISRCacImag;
|
||||
m * here->ISRCacImag;
|
||||
*(ckt->CKTirhs + (here->ISRCnegNode)) -=
|
||||
here->ISRCacImag;
|
||||
m * here->ISRCacImag;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ ISRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *
|
|||
case ISRC_DC:
|
||||
value->rValue = here->ISRCdcValue;
|
||||
return (OK);
|
||||
case ISRC_M:
|
||||
value->rValue = here->ISRCmValue;
|
||||
return (OK);
|
||||
case ISRC_AC_MAG:
|
||||
value->rValue = here->ISRCacMag;
|
||||
return (OK);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ typedef struct sISRCinstance {
|
|||
double *ISRCcoeffs; /* pointer to array of coefficients */
|
||||
|
||||
double ISRCdcValue; /* DC and TRANSIENT value of source */
|
||||
double ISRCmValue; /* Parallel multiplier */
|
||||
|
||||
double ISRCacPhase; /* AC phase angle */
|
||||
double ISRCacMag; /* AC magnitude */
|
||||
|
|
@ -56,6 +57,7 @@ typedef struct sISRCinstance {
|
|||
/* gtri - end - add member to hold current source value */
|
||||
|
||||
unsigned ISRCdcGiven :1 ; /* flag to indicate dc value given */
|
||||
unsigned ISRCmGiven :1 ; /* flag to indicate multiplier given */
|
||||
unsigned ISRCacGiven :1 ; /* flag to indicate ac keyword given */
|
||||
unsigned ISRCacMGiven :1 ; /* flag to indicate ac magnitude given */
|
||||
unsigned ISRCacPGiven :1 ; /* flag to indicate ac phase given */
|
||||
|
|
@ -94,31 +96,32 @@ typedef struct sISRCmodel {
|
|||
|
||||
/* device parameters */
|
||||
#define ISRC_DC 1
|
||||
#define ISRC_AC_MAG 2
|
||||
#define ISRC_AC_PHASE 3
|
||||
#define ISRC_AC 4
|
||||
#define ISRC_PULSE 5
|
||||
#define ISRC_SINE 6
|
||||
#define ISRC_EXP 7
|
||||
#define ISRC_PWL 8
|
||||
#define ISRC_SFFM 9
|
||||
#define ISRC_NEG_NODE 10
|
||||
#define ISRC_POS_NODE 11
|
||||
#define ISRC_AC_REAL 12
|
||||
#define ISRC_AC_IMAG 13
|
||||
#define ISRC_FCN_TYPE 14
|
||||
#define ISRC_FCN_ORDER 15
|
||||
#define ISRC_FCN_COEFFS 16
|
||||
#define ISRC_POWER 17
|
||||
#define ISRC_D_F1 18
|
||||
#define ISRC_D_F2 19
|
||||
#define ISRC_VOLTS 20
|
||||
#define ISRC_M 2
|
||||
#define ISRC_AC_MAG 3
|
||||
#define ISRC_AC_PHASE 4
|
||||
#define ISRC_AC 5
|
||||
#define ISRC_PULSE 6
|
||||
#define ISRC_SINE 7
|
||||
#define ISRC_EXP 8
|
||||
#define ISRC_PWL 9
|
||||
#define ISRC_SFFM 10
|
||||
#define ISRC_NEG_NODE 11
|
||||
#define ISRC_POS_NODE 12
|
||||
#define ISRC_AC_REAL 13
|
||||
#define ISRC_AC_IMAG 14
|
||||
#define ISRC_FCN_TYPE 15
|
||||
#define ISRC_FCN_ORDER 16
|
||||
#define ISRC_FCN_COEFFS 17
|
||||
#define ISRC_POWER 18
|
||||
#define ISRC_D_F1 19
|
||||
#define ISRC_D_F2 20
|
||||
#define ISRC_VOLTS 21
|
||||
|
||||
#define ISRC_AM 21
|
||||
#define ISRC_AM 22
|
||||
/* gtri - begin - add define for current source value */
|
||||
#ifdef XSPICE
|
||||
/* needed for outputting results */
|
||||
#define ISRC_CURRENT 22
|
||||
#define ISRC_CURRENT 23
|
||||
#endif
|
||||
/* gtri - end - add define for current source value */
|
||||
#define ISRC_TRNOISE 25
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
|
|||
ISRCinstance *here;
|
||||
double value;
|
||||
double time;
|
||||
double m;
|
||||
|
||||
/* loop through all the source models */
|
||||
for( ; model != NULL; model = model->ISRCnextModel ) {
|
||||
|
|
@ -36,6 +37,8 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
|
|||
for (here = model->ISRCinstances; here != NULL ;
|
||||
here=here->ISRCnextInstance) {
|
||||
|
||||
m = here->ISRCmValue;
|
||||
|
||||
if( (ckt->CKTmode & (MODEDCOP | MODEDCTRANCURVE)) &&
|
||||
here->ISRCdcGiven ) {
|
||||
/* load using DC value */
|
||||
|
|
@ -380,14 +383,14 @@ loadDone:
|
|||
#endif
|
||||
/* gtri - end - wbk - modify for supply ramping option */
|
||||
|
||||
*(ckt->CKTrhs + (here->ISRCposNode)) += value;
|
||||
*(ckt->CKTrhs + (here->ISRCnegNode)) -= value;
|
||||
*(ckt->CKTrhs + (here->ISRCposNode)) += m * value;
|
||||
*(ckt->CKTrhs + (here->ISRCnegNode)) -= m * value;
|
||||
|
||||
/* gtri - end - wbk - modify to process srcFact, etc. for all sources */
|
||||
|
||||
#ifdef XSPICE
|
||||
/* gtri - begin - wbk - record value so it can be output if requested */
|
||||
here->ISRCcurrent = value;
|
||||
here->ISRCcurrent = m * value;
|
||||
/* gtri - end - wbk - record value so it can be output if requested */
|
||||
#endif
|
||||
} // for loop instances
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ ISRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
|||
here->ISRCdcGiven = TRUE;
|
||||
break;
|
||||
|
||||
case ISRC_M:
|
||||
here->ISRCmValue = value->rValue;
|
||||
here->ISRCmGiven = TRUE;
|
||||
break;
|
||||
|
||||
case ISRC_AC_MAG:
|
||||
here->ISRCacMag = value->rValue;
|
||||
here->ISRCacMGiven = TRUE;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ ISRCtemp(GENmodel *inModel, CKTcircuit *ckt)
|
|||
&(here->ISRCname));
|
||||
}
|
||||
}
|
||||
if(!here->ISRCmGiven)
|
||||
here->ISRCmValue = 1;
|
||||
radians = here->ISRCacPhase * M_PI / 180.0;
|
||||
here->ISRCacReal = here->ISRCacMag * cos(radians);
|
||||
here->ISRCacImag = here->ISRCacMag * sin(radians);
|
||||
|
|
|
|||
Loading…
Reference in New Issue