From 5dbb25f66768f44148520f9fbfca7218f010d08c Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 7 Jan 2024 11:59:33 +0100 Subject: [PATCH] Set new default values. Restructure the code a bit. Two parameters for AM are required (offset and amplitude). Even if this sounds needless, changing it would require a major effort. --- src/spicelib/devices/isrc/isrcload.c | 24 +++++++++++------------- src/spicelib/devices/vsrc/vsrcload.c | 21 ++++++++++----------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/spicelib/devices/isrc/isrcload.c b/src/spicelib/devices/isrc/isrcload.c index 832c84598..a3267d0c5 100644 --- a/src/spicelib/devices/isrc/isrcload.c +++ b/src/spicelib/devices/isrc/isrcload.c @@ -240,30 +240,28 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt) case AM: { double VO, VA, FM, MD, FC, TD, PHASEM, PHASEC; - double phasec; - double phasem; - - PHASEC = here->ISRCfunctionOrder > 6 - ? here->ISRCcoeffs[6] : 0.0; - PHASEM = here->ISRCfunctionOrder > 7 - ? here->ISRCcoeffs[7] : 0.0; - - /* compute phases in radians */ - phasec = PHASEC * M_PI / 180.0; - phasem = PHASEM * M_PI / 180.0; + double phasec, phasem; VO = here->ISRCcoeffs[0]; VA = here->ISRCcoeffs[1]; FM = here->ISRCfunctionOrder > 2 && here->ISRCcoeffs[2] - ? here->ISRCcoeffs[2] : (1/ckt->CKTfinalTime); + ? here->ISRCcoeffs[2] : (5. / ckt->CKTfinalTime); MD = here->ISRCfunctionOrder > 3 ? here->ISRCcoeffs[3] : 0.5; FC = here->ISRCfunctionOrder > 4 - ? here->ISRCcoeffs[4] : 0.0; + ? here->ISRCcoeffs[4] : (500. / ckt->CKTfinalTime); TD = here->ISRCfunctionOrder > 5 && here->ISRCcoeffs[5] ? here->ISRCcoeffs[5] : 0.0; + PHASEC = here->ISRCfunctionOrder > 6 + ? here->ISRCcoeffs[6] : 0.0; + PHASEM = here->ISRCfunctionOrder > 7 + ? here->ISRCcoeffs[7] : 0.0; + + /* compute phases in radians */ + phasec = PHASEC * M_PI / 180.0; + phasem = PHASEM * M_PI / 180.0; /* limit the modulation depth */ if (MD > 1) diff --git a/src/spicelib/devices/vsrc/vsrcload.c b/src/spicelib/devices/vsrc/vsrcload.c index ed172652d..f7821b39a 100644 --- a/src/spicelib/devices/vsrc/vsrcload.c +++ b/src/spicelib/devices/vsrc/vsrcload.c @@ -265,27 +265,26 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt) double phasec; double phasem; - PHASEM = here->VSRCfunctionOrder > 6 - ? here->VSRCcoeffs[6] : 0.0; - PHASEC = here->VSRCfunctionOrder > 7 - ? here->VSRCcoeffs[7] : 0.0; - - /* compute phases in radians */ - phasec = PHASEC * M_PI / 180.0; - phasem = PHASEM * M_PI / 180.0; - VO = here->VSRCcoeffs[0]; VA = here->VSRCcoeffs[1]; FM = here->VSRCfunctionOrder > 2 && here->VSRCcoeffs[2] - ? here->VSRCcoeffs[2] : (1/ckt->CKTfinalTime); + ? here->VSRCcoeffs[2] : (5. / ckt->CKTfinalTime); MD = here->VSRCfunctionOrder > 3 ? here->VSRCcoeffs[3] : 0.5; FC = here->VSRCfunctionOrder > 4 - ? here->VSRCcoeffs[4] : 0.0; + ? here->VSRCcoeffs[4] : (500. / ckt->CKTfinalTime); TD = here->VSRCfunctionOrder > 5 && here->VSRCcoeffs[5] ? here->VSRCcoeffs[5] : 0.0; + PHASEM = here->VSRCfunctionOrder > 6 + ? here->VSRCcoeffs[6] : 0.0; + PHASEC = here->VSRCfunctionOrder > 7 + ? here->VSRCcoeffs[7] : 0.0; + + /* compute phases in radians */ + phasec = PHASEC * M_PI / 180.0; + phasem = PHASEM * M_PI / 180.0; /* limit the modulation depth */ if (MD > 1)