From 03556b22156d4ddd4c6cf5cd6a444bdea918fd36 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 20 Dec 2020 17:19:39 +0100 Subject: [PATCH] Add multiplier 'm' to the ASRC instance line. Default value is 1. A new 'reciprocm' will determine, if m is multiplied into numerator or denominator. --- src/spicelib/devices/asrc/asrc.c | 2 ++ src/spicelib/devices/asrc/asrcacld.c | 5 +++++ src/spicelib/devices/asrc/asrcask.c | 3 +++ src/spicelib/devices/asrc/asrcdefs.h | 6 ++++++ src/spicelib/devices/asrc/asrcload.c | 5 +++++ src/spicelib/devices/asrc/asrcpar.c | 8 ++++++++ src/spicelib/devices/asrc/asrcpzld.c | 5 +++++ src/spicelib/devices/asrc/asrcset.c | 4 ++++ 8 files changed, 38 insertions(+) diff --git a/src/spicelib/devices/asrc/asrc.c b/src/spicelib/devices/asrc/asrc.c index bb4ac8620..0d949d2cd 100644 --- a/src/spicelib/devices/asrc/asrc.c +++ b/src/spicelib/devices/asrc/asrc.c @@ -19,6 +19,8 @@ IFparm ASRCpTable[] = { /* parameters */ IOPU("tc1", ASRC_TC1, IF_REAL, "First order temp. coefficient"), IOPU("tc2", ASRC_TC2, IF_REAL, "Second order temp. coefficient"), IOPU("reciproctc", ASRC_RTC, IF_INTEGER, "Flag to calculate reciprocal temperature behaviour"), + IOPU("m", ASRC_M, IF_REAL, "Multiplier"), + IOPU("reciprocm", ASRC_RM, IF_INTEGER, "Flag to calculate reciprocal multiplier behaviour"), OP("i", ASRC_OUTPUTCURRENT, IF_REAL, "Current through source"), OP("v", ASRC_OUTPUTVOLTAGE, IF_REAL, "Voltage across source"), OP("pos_node", ASRC_POS_NODE, IF_INTEGER, "Positive Node"), diff --git a/src/spicelib/devices/asrc/asrcacld.c b/src/spicelib/devices/asrc/asrcacld.c index f7ddd78be..b019dfcd5 100644 --- a/src/spicelib/devices/asrc/asrcacld.c +++ b/src/spicelib/devices/asrc/asrcacld.c @@ -39,6 +39,11 @@ ASRCacLoad(GENmodel *inModel, CKTcircuit *ckt) if (here->ASRCreciproctc == 1) factor = 1 / factor; + if (here->ASRCreciprocm == 1) + factor = factor / here->ASRCm; + else + factor = factor * here->ASRCm; + /* * Get the function and its derivatives from the * field in the instance structure. The field is diff --git a/src/spicelib/devices/asrc/asrcask.c b/src/spicelib/devices/asrc/asrcask.c index 6554b77c7..7fd19e152 100644 --- a/src/spicelib/devices/asrc/asrcask.c +++ b/src/spicelib/devices/asrc/asrcask.c @@ -37,6 +37,9 @@ ASRCask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, IFvalu case ASRC_TC2: value->rValue = here->ASRCtc2; return(OK); + case ASRC_M: + value->rValue = here->ASRCm; + return(OK); case ASRC_CURRENT: value->tValue = (here->ASRCtype == ASRC_CURRENT) ? here->ASRCtree : NULL; diff --git a/src/spicelib/devices/asrc/asrcdefs.h b/src/spicelib/devices/asrc/asrcdefs.h index 83242a80f..ddf17cc63 100644 --- a/src/spicelib/devices/asrc/asrcdefs.h +++ b/src/spicelib/devices/asrc/asrcdefs.h @@ -38,7 +38,9 @@ typedef struct sASRCinstance { double ASRCdtemp; /* delta-temperature of a particular instance */ double ASRCtc1; /* first temperature coefficient of resistors */ double ASRCtc2; /* second temperature coefficient of resistors */ + double ASRCm; /* Output multiplier */ int ASRCreciproctc; /* Flag to calculate reciprocal temperature behaviour */ + int ASRCreciprocm; /* Flag to calculate reciprocal multiplier behaviour */ double **ASRCposPtr; /* pointer to pointers of the elements * in the sparce matrix */ double ASRCprev_value; /* Previous value for the convergence test */ @@ -48,7 +50,9 @@ typedef struct sASRCinstance { unsigned ASRCdtempGiven : 1; /* indicates delta-temp specified */ unsigned ASRCtc1Given : 1; /* indicates tc1 parameter specified */ unsigned ASRCtc2Given : 1; /* indicates tc2 parameter specified */ + unsigned ASRCmGiven : 1; /* indicates tc2 parameter specified */ unsigned ASRCreciproctcGiven : 1; /* indicates reciproctc flag parameter specified */ + unsigned ASRCreciprocmGiven : 1; /* indicates reciprocm flag parameter specified */ } ASRCinstance; @@ -84,6 +88,8 @@ enum { ASRC_TC1, ASRC_TC2, ASRC_RTC, + ASRC_M, + ASRC_RM, }; /* module-wide variables */ diff --git a/src/spicelib/devices/asrc/asrcload.c b/src/spicelib/devices/asrc/asrcload.c index 69d69def8..12fab1831 100644 --- a/src/spicelib/devices/asrc/asrcload.c +++ b/src/spicelib/devices/asrc/asrcload.c @@ -46,6 +46,11 @@ ASRCload(GENmodel *inModel, CKTcircuit *ckt) if (here->ASRCreciproctc == 1) factor = 1 / factor; + if (here->ASRCreciprocm == 1) + factor = factor / here->ASRCm; + else + factor = factor * here->ASRCm; + /* * Get the function and its derivatives evaluated */ diff --git a/src/spicelib/devices/asrc/asrcpar.c b/src/spicelib/devices/asrc/asrcpar.c index 76cda0f63..1f668496d 100644 --- a/src/spicelib/devices/asrc/asrcpar.c +++ b/src/spicelib/devices/asrc/asrcpar.c @@ -34,10 +34,18 @@ ASRCparam(int param, IFvalue *value, GENinstance *fast, IFvalue *select) here->ASRCtc2 = value->rValue; here->ASRCtc2Given = TRUE; break; + case ASRC_M: + here->ASRCm = value->rValue; + here->ASRCmGiven = TRUE; + break; case ASRC_RTC: here->ASRCreciproctc = value->iValue; here->ASRCreciproctcGiven = TRUE; break; + case ASRC_RM: + here->ASRCreciprocm = value->iValue; + here->ASRCreciprocmGiven = TRUE; + break; default: return(E_BADPARM); } diff --git a/src/spicelib/devices/asrc/asrcpzld.c b/src/spicelib/devices/asrc/asrcpzld.c index 48110bd9f..fd3739b31 100644 --- a/src/spicelib/devices/asrc/asrcpzld.c +++ b/src/spicelib/devices/asrc/asrcpzld.c @@ -38,6 +38,11 @@ ASRCpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) if (here->ASRCreciproctc == 1) factor = 1 / factor; + if (here->ASRCreciprocm == 1) + factor = factor / here->ASRCm; + else + factor = factor * here->ASRCm; + j = 0; /* Get the function evaluated and the derivatives too */ diff --git a/src/spicelib/devices/asrc/asrcset.c b/src/spicelib/devices/asrc/asrcset.c index a23ae21ab..3873129ea 100644 --- a/src/spicelib/devices/asrc/asrcset.c +++ b/src/spicelib/devices/asrc/asrcset.c @@ -49,6 +49,10 @@ int ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, here->ASRCtc2 = 0.0; if (!here->ASRCreciproctcGiven) here->ASRCreciproctc = 0; + if (!here->ASRCreciprocmGiven) + here->ASRCreciprocm = 0; + if (!here->ASRCmGiven) + here->ASRCm = 1.0; switch (here->ASRCtype) { case ASRC_VOLTAGE: