From 6801f77cc1cff58e87f88d7b27a571900bdb73c1 Mon Sep 17 00:00:00 2001 From: dwarning Date: Sat, 11 May 2013 22:17:03 +0200 Subject: [PATCH] devices/isrc: implement multiplier `m' for current sources --- src/spicelib/devices/isrc/isrc.c | 1 + src/spicelib/devices/isrc/isrcacld.c | 11 ++++--- src/spicelib/devices/isrc/isrcask.c | 3 ++ src/spicelib/devices/isrc/isrcdefs.h | 45 +++++++++++++++------------- src/spicelib/devices/isrc/isrcload.c | 9 ++++-- src/spicelib/devices/isrc/isrcpar.c | 5 ++++ src/spicelib/devices/isrc/isrctemp.c | 2 ++ 7 files changed, 48 insertions(+), 28 deletions(-) diff --git a/src/spicelib/devices/isrc/isrc.c b/src/spicelib/devices/isrc/isrc.c index e872642ae..c5266f34e 100644 --- a/src/spicelib/devices/isrc/isrc.c +++ b/src/spicelib/devices/isrc/isrc.c @@ -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 */ diff --git a/src/spicelib/devices/isrc/isrcacld.c b/src/spicelib/devices/isrc/isrcacld.c index 5e2ba34be..5ddbec373 100644 --- a/src/spicelib/devices/isrc/isrcacld.c +++ b/src/spicelib/devices/isrc/isrcacld.c @@ -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; } } diff --git a/src/spicelib/devices/isrc/isrcask.c b/src/spicelib/devices/isrc/isrcask.c index 3740ab331..1d7171352 100644 --- a/src/spicelib/devices/isrc/isrcask.c +++ b/src/spicelib/devices/isrc/isrcask.c @@ -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); diff --git a/src/spicelib/devices/isrc/isrcdefs.h b/src/spicelib/devices/isrc/isrcdefs.h index 53939074e..a7851a68f 100644 --- a/src/spicelib/devices/isrc/isrcdefs.h +++ b/src/spicelib/devices/isrc/isrcdefs.h @@ -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 diff --git a/src/spicelib/devices/isrc/isrcload.c b/src/spicelib/devices/isrc/isrcload.c index 04017585c..7d2ccb9e6 100644 --- a/src/spicelib/devices/isrc/isrcload.c +++ b/src/spicelib/devices/isrc/isrcload.c @@ -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 diff --git a/src/spicelib/devices/isrc/isrcpar.c b/src/spicelib/devices/isrc/isrcpar.c index 2ce4c2580..1a62f6814 100644 --- a/src/spicelib/devices/isrc/isrcpar.c +++ b/src/spicelib/devices/isrc/isrcpar.c @@ -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; diff --git a/src/spicelib/devices/isrc/isrctemp.c b/src/spicelib/devices/isrc/isrctemp.c index 0bae229ec..dbbf9de26 100644 --- a/src/spicelib/devices/isrc/isrctemp.c +++ b/src/spicelib/devices/isrc/isrctemp.c @@ -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);