Continue Newton iteration until currents settle.

For each type of device, a *convTest function determines if the
current through that device is converged within tolerance,
and sets CKTnoncon if the current is not yet converged.

ASCRconvTest() erroneously subtracted old current from old,
rather than old from new, when evaluating convergence.

Also, since at least 3f5, the calling function NIconvTest assumed
that the worker functions indicated non-convergence through their
return value, so was ignoring the reports of current nonconvergence.
This commit is contained in:
Keith OHara 2026-04-06 00:01:12 +02:00 committed by Holger Vogt
parent 55189b01fe
commit 0638aaa160
3 changed files with 11 additions and 2 deletions

View File

@ -81,6 +81,15 @@ NIconvTest(CKTcircuit *ckt)
#ifdef NEWCONV
i = CKTconvTest(ckt);
/* The individual testers, called by CKTconvTest, set
* ckt->CKTnoncon and ckt->CKTtroubleElt appropriately. */
if (ckt->CKTnoncon != 0) {
ckt->CKTtroubleNode = 0;
return(1);
}
/* CKTconvTest early-returns nonzero 'i' on the first error
* in evaluating convergence (such as parameter out of range) so
* there may be untested devices that have not yet converged */
if (i)
ckt->CKTtroubleNode = 0;
return(i);

View File

@ -32,7 +32,7 @@ ASRCconvTest(GENmodel *inModel, CKTcircuit *ckt)
}
for (i = 0; i < here->ASRCtree->numVars; i++)
asrc_vals[i] = ckt->CKTrhsOld[here->ASRCvars[i]];
asrc_vals[i] = ckt->CKTrhs[here->ASRCvars[i]];
if (here->ASRCtree->IFeval(here->ASRCtree, ckt->CKTgmin, &rhs,
asrc_vals, asrc_derivs) != OK)

View File

@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in
TESTS = bugs-1.cir bugs-2.cir dollar-1.cir empty-1.cir resume-1.cir log-functions-1.cir alter-vec.cir test-noise-2.cir test-noise-3.cir ac-zero.cir asrc-tc-1.cir asrc-tc-2.cir if-elseif.cir
TESTS = bugs-1.cir bugs-2.cir dollar-1.cir empty-1.cir resume-1.cir log-functions-1.cir alter-vec.cir test-noise-2.cir test-noise-3.cir ac-zero.cir asrc-tc-1.cir asrc-tc-2.cir if-elseif.cir convergence.cir
TESTS_ENVIRONMENT = ngspice_vpath=$(srcdir) $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice