Skip to content

Commit

Permalink
WRspice: fix startup transient in TJM.
Browse files Browse the repository at this point in the history
  • Loading branch information
wrcad committed Jul 19, 2022
1 parent 615bed9 commit 9fc0b26
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions wrspice/devlib/tjm/tjmload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ TJMdev::load(sGENinstance *in_inst, sCKT *ckt)
#ifdef NEWJJDC

if (ckt->CKTmode & MODEDC) {
if (ckt->CKTmode & MODEUIC)
return (OK);

ts.ts_vj = *(ckt->CKTrhsOld + inst->TJMposNode) -
*(ckt->CKTrhsOld + inst->TJMnegNode);

Expand Down Expand Up @@ -319,6 +322,7 @@ TJMdev::load(sGENinstance *in_inst, sCKT *ckt)
inst->TJMdelVdelT = ckt->find_ceq(inst->TJMvoltage);

inst->tjm_init(ts.ts_phi);
inst->tjm_newstep(ckt);

ts.ts_dcrt = 0;
ts.ts_crt = inst->TJMcriti;
Expand Down Expand Up @@ -411,15 +415,6 @@ sTJMinstance::tjm_load(sCKT *ckt, tjmstuff &ts)
{
*(ckt->CKTstate0 + TJMvoltage) = ts.ts_vj;
*(ckt->CKTstate0 + TJMphase) = ts.ts_phi;
if (ckt->CKTmode & MODEDC) {
tjm_cp = ts.ts_crt*sin(ts.ts_phi);
*(ckt->CKTstate0 + TJMcrti)= tjm_cp;
*(ckt->CKTstate0 + TJMqpi) = 0.0;
}
else {
*(ckt->CKTstate0 + TJMcrti)= tjm_cp;
*(ckt->CKTstate0 + TJMqpi) = tjm_cqp + (tjm_gcrit + TJMg0)*ts.ts_vj;
}

double crhs, gqt;
if (ckt->CKTmode & MODEDC) {
Expand All @@ -432,6 +427,15 @@ sTJMinstance::tjm_load(sCKT *ckt, tjmstuff &ts)
crhs = tjm_cp + tjm_cqp + TJMdelVdelT*TJMcap;
gqt = tjm_gcrit + TJMg0 + ckt->CKTag[0]*TJMcap;
}
if (ckt->CKTmode & MODEDC) {
tjm_cp = ts.ts_crt*sin(ts.ts_phi);
*(ckt->CKTstate0 + TJMcrti)= tjm_cp;
*(ckt->CKTstate0 + TJMqpi) = 0.0;
}
else {
*(ckt->CKTstate0 + TJMcrti)= tjm_cp;
*(ckt->CKTstate0 + TJMqpi) = tjm_cqp + (tjm_gcrit + TJMg0)*ts.ts_vj;
}

// load matrix, rhs vector
if (TJMphsNode > 0)
Expand Down

0 comments on commit 9fc0b26

Please sign in to comment.