PSS Fix: thanks to Marcel Hendrix, a possible bug has been found for division by 0

This commit is contained in:
Francesco Lannutti 2016-02-13 19:33:29 +01:00
parent 72d7bb9c8a
commit 02b7fc950e
1 changed files with 5 additions and 1 deletions

View File

@ -744,7 +744,11 @@ DCpss(CKTcircuit *ckt,
{
/* Pitagora ha sempre ragione!!! :))) */
/* pred is treated as FREQUENCY to avoid numerical overflow when derivative is close to ZERO */
pred [i] = RHS_derivative [i] / err_conv [i] ;
if ((RHS_derivative [i] != 0) && (err_conv [i] == 0)) {
pred [i] = DBL_MAX ;
} else {
pred [i] = RHS_derivative [i] / err_conv [i] ;
}
#ifdef STEPDEBUG
fprintf (stderr, "Pred is so high or so low! Diff is: %g\n", err_conv [i]) ;