Remove the XSPICE dependency of the phase parameter for the

independent voltage source.
This commit is contained in:
Holger Vogt 2020-12-07 14:39:52 +01:00
parent 52f3bd7900
commit cbf4305ff8
2 changed files with 5 additions and 47 deletions

View File

@ -54,12 +54,10 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
double time = 0.;
double basetime = 0;
/* gtri - begin - wbk - add PHASE parameter */
#ifdef XSPICE
double PHASE;
double phase;
double deltat;
#endif
TD = here->VSRCfunctionOrder > 2
? here->VSRCcoeffs[2] : 0.0;
TR = here->VSRCfunctionOrder > 3
@ -74,15 +72,13 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
PER = here->VSRCfunctionOrder > 6
&& here->VSRCcoeffs[6] != 0.0
? here->VSRCcoeffs[6] : ckt->CKTfinalTime;
#ifdef XSPICE
PHASE = here->VSRCfunctionOrder > 7
? here->VSRCcoeffs[7] : 0.0;
#endif
/* offset time by delay */
time = ckt->CKTtime - TD;
tshift = TD;
#ifdef XSPICE
/* normalize phase to 0 - 360° */
/* normalize phase to cycles */
phase = PHASE / 360.0;
@ -92,8 +88,6 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
deltat -= PER;
time += deltat;
tshift = TD - deltat;
#endif
/* gtri - end - wbk - add PHASE parameter */
if(time >= PER) {
/* repeating signal - figure out where we are */

View File

@ -69,11 +69,10 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
case PULSE: {
double V1, V2, TD, TR, TF, PW, PER;
double basetime = 0;
#ifdef XSPICE
double PHASE;
double phase;
double deltat;
#endif
V1 = here->VSRCcoeffs[0];
V2 = here->VSRCcoeffs[1];
TD = here->VSRCfunctionOrder > 2
@ -94,8 +93,6 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
/* shift time by delay time TD */
time -= TD;
#ifdef XSPICE
/* gtri - begin - wbk - add PHASE parameter */
PHASE = here->VSRCfunctionOrder > 7
? here->VSRCcoeffs[7] : 0.0;
@ -107,8 +104,7 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
deltat -= PER;
/* shift time by pase (neg. for pos. phase value) */
time += deltat;
/* gtri - end - wbk - add PHASE parameter */
#endif
if(time > PER) {
/* repeating signal - figure out where we are */
/* in period */
@ -130,8 +126,6 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
case SINE: {
double VO, VA, FREQ, TD, THETA;
/* gtri - begin - wbk - add PHASE parameter */
#ifdef XSPICE
double PHASE;
double phase;
@ -140,7 +134,7 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
/* compute phase in radians */
phase = PHASE * M_PI / 180.0;
#endif
VO = here->VSRCcoeffs[0];
VA = here->VSRCcoeffs[1];
FREQ = here->VSRCfunctionOrder > 2
@ -153,18 +147,10 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
time -= TD;
if (time <= 0) {
#ifdef XSPICE
value = VO + VA * sin(phase);
} else {
value = VO + VA * sin(FREQ*time * 2.0 * M_PI + phase) *
exp(-time*THETA);
#else
value = VO;
} else {
value = VO + VA * sin(FREQ * time * 2.0 * M_PI) *
exp(-time*THETA);
#endif
/* gtri - end - wbk - add PHASE parameter */
}
}
break;
@ -201,8 +187,6 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
case SFFM: {
double VO, VA, FC, MDI, FS;
/* gtri - begin - wbk - add PHASE parameters */
#ifdef XSPICE
double PHASEC, PHASES;
double phasec;
double phases;
@ -215,7 +199,6 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
/* compute phases in radians */
phasec = PHASEC * M_PI / 180.0;
phases = PHASES * M_PI / 180.0;
#endif
VO = here->VSRCcoeffs[0];
VA = here->VSRCcoeffs[1];
@ -228,26 +211,16 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
&& here->VSRCcoeffs[4]
? here->VSRCcoeffs[4] : (1/ckt->CKTfinalTime);
#ifdef XSPICE
/* compute waveform value */
value = VO + VA *
sin((2.0 * M_PI * FC * time + phasec) +
MDI * sin(2.0 * M_PI * FS * time + phases));
#else
value = VO + VA *
sin((2.0 * M_PI * FC * time) +
MDI * sin(2.0 * M_PI * FS * time));
#endif
/* gtri - end - wbk - add PHASE parameters */
}
break;
case AM: {
double VA, FC, MF, VO, TD;
/* gtri - begin - wbk - add PHASE parameters */
#ifdef XSPICE
double PHASEC, PHASES;
double phasec;
double phases;
@ -260,7 +233,6 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
/* compute phases in radians */
phasec = PHASEC * M_PI / 180.0;
phases = PHASES * M_PI / 180.0;
#endif
VA = here->VSRCcoeffs[0];
VO = here->VSRCcoeffs[1];
@ -277,18 +249,10 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
if (time <= 0) {
value = 0;
} else {
#ifdef XSPICE
/* compute waveform value */
value = VA * (VO + sin(2.0 * M_PI * MF * time + phases )) *
sin(2.0 * M_PI * FC * time + phases);
#else
value = VA * (VO + sin(2.0 * M_PI * MF * time)) *
sin(2.0 * M_PI * FC * time);
#endif
}
/* gtri - end - wbk - add PHASE parameters */
}
break;