From 9df5a4c2d0f53984a1954ecb529a983b05e19134 Mon Sep 17 00:00:00 2001 From: Francesco Lannutti Date: Sat, 8 Sep 2012 21:43:39 -0700 Subject: [PATCH] Corrected a possible bug that probably comes from SPICE Berkeley in NIiter. It can affect convergence during dynamic gmin stepping algorithm --- ChangeLog | 9 +++++++++ src/maths/KLU/klusmp.c | 9 ++++++++- src/maths/ni/niiter.c | 19 +++++++++++++++++-- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1941b3d72..dc80b3a1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5423,6 +5423,15 @@ Removed the PARALLEL_ARCH macro Removed the Combine algorithm from Sparse and Analyses +2012-09-08 Francesco Lannutti + * src/maths/KLU/klusmp.c + * src/maths/ni/niiter.c + Corrected a possible bug that + probably comes from SPICE + Berkeley in NIiter. It can + affect convergence during + dynamic gmin stepping algorithm + 2012-08-25 Francesco Lannutti * src/maths/KLU/klusmp.c * src/spicelib/analysis/cktsetup.c diff --git a/src/maths/KLU/klusmp.c b/src/maths/KLU/klusmp.c index 4db0125d3..07fa4d287 100644 --- a/src/maths/KLU/klusmp.c +++ b/src/maths/KLU/klusmp.c @@ -232,7 +232,14 @@ SMPluFac (SMPmatrix *Matrix, double PivTol, double Gmin) LoadGmin_CSC (Matrix->CKTdiag_CSC, Matrix->CKTkluN, Gmin) ; ret = klu_refactor (Matrix->CKTkluAp, Matrix->CKTkluAi, Matrix->CKTkluAx, Matrix->CKTkluSymbolic, Matrix->CKTkluNumeric, Matrix->CKTkluCommon) ; - return (!ret) ; + if (ret == 1) + return 0 ; + else if (ret == 0) + return (E_SINGULAR) ; + else { + fprintf (stderr, "KLU Error in re-factor!") ; + return 1 ; + } } else { spSetReal (Matrix->SPmatrix) ; LoadGmin (Matrix, Gmin) ; diff --git a/src/maths/ni/niiter.c b/src/maths/ni/niiter.c index 4d6c83e08..38ba8d4f1 100644 --- a/src/maths/ni/niiter.c +++ b/src/maths/ni/niiter.c @@ -25,6 +25,10 @@ Modified: 2001 AlansFixes int NIiter(CKTcircuit *ckt, int maxIter) { + /* Francesco Lannutti - NEED TO PIVOT Fix */ + int SMPreorderFromSMPluFac ; + SMPreorderFromSMPluFac = 0 ; + int iterno; int ipass; int error; @@ -78,10 +82,17 @@ NIiter(CKTcircuit *ckt, int maxIter) #else /* NEWPRED */ if(1) { /* } */ #endif /* NEWPRED */ - error = CKTload(ckt); + + /* Francesco Lannutti - NEED TO PIVOT Fix */ + error = 0 ; + if (!SMPreorderFromSMPluFac) + { + error = CKTload (ckt) ; + iterno++ ; + } + /*printf("loaded, noncon is %d\n",ckt->CKTnoncon);*/ /*fflush(stdout);*/ - iterno++; if(error) { ckt->CKTstat->STATnumIter += iterno; #ifdef STEPDEBUG @@ -143,6 +154,10 @@ NIiter(CKTcircuit *ckt, int maxIter) SPfrontEnd->IFseconds() - startTime; if(error) { if( error == E_SINGULAR ) { + + /* Francesco Lannutti - NEED TO PIVOT Fix */ + SMPreorderFromSMPluFac = 1 ; +fprintf (stderr, "CIAO\n") ; ckt->CKTniState |= NISHOULDREORDER; DEBUGMSG(" forced reordering....\n"); continue;