Fixed a crash when SPARSE is used

This commit is contained in:
Francesco Lannutti 2020-10-22 00:58:11 +02:00 committed by Holger Vogt
parent 30ee07b4c2
commit caf1ee7c47
1 changed files with 17 additions and 5 deletions

View File

@ -114,7 +114,9 @@ NIiter(CKTcircuit *ckt, int maxIter)
startTime = SPfrontEnd->IFseconds();
#ifdef KLU
ckt->CKTmatrix->SMPkluMatrix->KLUloadDiagGmin = 1 ;
if (ckt->CKTkluMODE) {
ckt->CKTmatrix->SMPkluMatrix->KLUloadDiagGmin = 1 ;
}
#endif
error = SMPreorder(ckt->CKTmatrix, ckt->CKTpivotAbsTol,
@ -146,7 +148,9 @@ NIiter(CKTcircuit *ckt, int maxIter)
startTime = SPfrontEnd->IFseconds();
#ifdef KLU
ckt->CKTmatrix->SMPkluMatrix->KLUloadDiagGmin = 1 ;
if (ckt->CKTkluMODE) {
ckt->CKTmatrix->SMPkluMatrix->KLUloadDiagGmin = 1 ;
}
#endif
error = SMPluFac(ckt->CKTmatrix, ckt->CKTpivotAbsTol,
@ -155,7 +159,7 @@ NIiter(CKTcircuit *ckt, int maxIter)
SPfrontEnd->IFseconds() - startTime;
#ifdef KLU
if (error == E_SINGULAR) {
if ((ckt->CKTkluMODE) && (error == E_SINGULAR)) {
/* Francesco Lannutti - 25 Aug 2020
* If the matrix is numerically singular during ReFactorization, take the same matrix and factor it from scratch in the same iteration.
@ -183,9 +187,17 @@ NIiter(CKTcircuit *ckt, int maxIter)
return(error);
}
} else if (error) {
SMPgetError(ckt->CKTmatrix, &i, &j);
SPfrontEnd->IFerrorf (ERR_WARNING, "singular matrix: check nodes %s and %s\n", NODENAME(ckt, i), NODENAME(ckt, j));
if (!(ckt->CKTkluMODE) && (error == E_SINGULAR)) {
/* Francesco Lannutti - 25 Aug 2020
* If the matrix is numerically singular during ReFactorization, factor it from scratch at the next iteration.
* This is the original SPICE3F5 code and uses SPARSE.
*/
ckt->CKTniState |= NISHOULDREORDER;
DEBUGMSG(" forced reordering....\n");
continue;
}
/* CKTload(ckt); */
/* SMPprint(ckt->CKTmatrix, stdout); */
/* seems to be singular - pass the bad news up */