From 7fd4a22060c97ec4d1df80bc5d50a1fbc3024f53 Mon Sep 17 00:00:00 2001 From: rlar Date: Mon, 29 Jan 2018 17:53:07 +0100 Subject: [PATCH] ni/niiter.c, bug fix, CKTrhsOld is meant to return the solution when solving circuitmatrix . x = rhs in function NIiter() The result es expected to be delivered in CKTrhsOld. CKTrhs is meant to store leftover garbage when returning from NIiter() this can be seen most notably in CKTdump(), and in other iters, for example NIacIter() as a consequence the solution of the second to last iteration was used, instead of the very last iteration. This can be quite inaccurate if the second to last iteration was marked CKTnoncon by somebody. In my case this was the caused by the convlimit option in xpsice which intentionally uses incorrect values and correctly markes the results unusable with CKTnoncon. --- src/maths/ni/niiter.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/maths/ni/niiter.c b/src/maths/ni/niiter.c index 7611bb4a3..a2bec8b07 100644 --- a/src/maths/ni/niiter.c +++ b/src/maths/ni/niiter.c @@ -237,6 +237,7 @@ NIiter(CKTcircuit *ckt, int maxIter) if (ckt->CKTnoncon == 0) { ckt->CKTstat->STATnumIter += iterno; FREE(OldCKTstate0); + SWAP(double *, ckt->CKTrhs, ckt->CKTrhsOld); return(OK); } } else if (ckt->CKTmode & MODEINITJCT) {