From 477f62ccfab2e71d60024969034308e37cd47947 Mon Sep 17 00:00:00 2001 From: Kevin Zheng Date: Sun, 24 May 2020 12:51:24 +0200 Subject: [PATCH] When NGSPICE performs a transient simulation with initial conditions, it prints out an "Initial Transient Solution" and plots the first timestep. This is despite the fact that the first timestep is not meaningful when initial conditions are applied. The first "real" output is available only after the second transient timestep. This patch suppresses "Initial Transient Solution" output and plotting for the first timestep. --- src/spicelib/devices/ind/indload.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/spicelib/devices/ind/indload.c b/src/spicelib/devices/ind/indload.c index f70ebbb71..807ac80a7 100644 --- a/src/spicelib/devices/ind/indload.c +++ b/src/spicelib/devices/ind/indload.c @@ -59,15 +59,24 @@ INDload(GENmodel *inModel, CKTcircuit *ckt) muthere=MUTnextInstance(muthere)) { if(!(ckt->CKTmode& (MODEDC|MODEINITPRED))) { - *(ckt->CKTstate0 + muthere->MUTind1->INDflux) += - muthere->MUTfactor * *(ckt->CKTrhsOld + - muthere->MUTind2->INDbrEq); + /* set initial conditions for mutual inductance here, if uic is set */ + if (ckt->CKTmode & MODEUIC && ckt->CKTmode & MODEINITTRAN) { + *(ckt->CKTstate0 + muthere->MUTind1->INDflux) += + muthere->MUTfactor * muthere->MUTind2->INDinitCond; - *(ckt->CKTstate0 + muthere->MUTind2->INDflux) += - muthere->MUTfactor * *(ckt->CKTrhsOld + - muthere->MUTind1->INDbrEq); + *(ckt->CKTstate0 + muthere->MUTind2->INDflux) += + muthere->MUTfactor * muthere->MUTind1->INDinitCond; + } + else { + *(ckt->CKTstate0 + muthere->MUTind1->INDflux) += + muthere->MUTfactor * *(ckt->CKTrhsOld + + muthere->MUTind2->INDbrEq); + + *(ckt->CKTstate0 + muthere->MUTind2->INDflux) += + muthere->MUTfactor * *(ckt->CKTrhsOld + + muthere->MUTind1->INDbrEq); + } } - *(muthere->MUTbr1br2Ptr) -= muthere->MUTfactor*ckt->CKTag[0]; *(muthere->MUTbr2br1Ptr) -= muthere->MUTfactor*ckt->CKTag[0]; }