From 4f2e0f15810d29963923aa3b149429bebcd88aa7 Mon Sep 17 00:00:00 2001 From: Francesco Lannutti Date: Sun, 14 Feb 2016 01:09:10 +0100 Subject: [PATCH] Reverting back the previous commit, but also avoided to push a NaN in the predicted frequency --- examples/pss/hartley_osc_pss.cir | 2 +- examples/pss/ring_osc_pss.cir | 2 +- src/spicelib/analysis/dcpss.c | 15 ++++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/pss/hartley_osc_pss.cir b/examples/pss/hartley_osc_pss.cir index bd1eef3df..4e52cbced 100644 --- a/examples/pss/hartley_osc_pss.cir +++ b/examples/pss/hartley_osc_pss.cir @@ -18,4 +18,4 @@ l2 0 4 500m r2 4 2 100 *.tran 300n 50m -.pss 50 200e-3 2 1024 11 10 5e-3 uic +.pss 50 2 2 1024 11 10 5e-3 uic diff --git a/examples/pss/ring_osc_pss.cir b/examples/pss/ring_osc_pss.cir index f961088e3..4fe14e814 100644 --- a/examples/pss/ring_osc_pss.cir +++ b/examples/pss/ring_osc_pss.cir @@ -26,4 +26,4 @@ mn4 bout inv3 gnd_ana gnd_ana nch w=10u l=0.18u *.tran 0.005n 100n *.plot tran v(4) -.pss 624e6 500n 1 1024 10 5 5e-3 uic +.pss 624e6 500n 1 1024 10 20 5e-3 uic diff --git a/src/spicelib/analysis/dcpss.c b/src/spicelib/analysis/dcpss.c index 9f5add4f9..d61f4204d 100644 --- a/src/spicelib/analysis/dcpss.c +++ b/src/spicelib/analysis/dcpss.c @@ -647,7 +647,7 @@ DCpss(CKTcircuit *ckt, RHS_copy_der [i] = ckt->CKTrhsOld [i + 1] ; #ifdef STEPDEBUG - fprintf (stderr, "Pred is so high or so low! Diff is: %g\n", err_conv [i]) ; + fprintf (stderr, "Pred is so high or so low! Diff is: %-.9g\tat node: %d\n", err_conv [i], i) ; #endif } @@ -744,17 +744,18 @@ DCpss(CKTcircuit *ckt, { /* Pitagora ha sempre ragione!!! :))) */ /* pred is treated as FREQUENCY to avoid numerical overflow when derivative is close to ZERO */ - if ((RHS_derivative [i] != 0) && (err_conv [i] == 0)) { - pred [i] = DBL_MAX ; - } else { + if (fabs (err_conv [i]) != 0) + { pred [i] = RHS_derivative [i] / err_conv [i] ; + } else { + pred [i] = 1.0e6 * ckt->CKTguessedFreq ; } #ifdef STEPDEBUG - fprintf (stderr, "Pred is so high or so low! Diff is: %g\n", err_conv [i]) ; + fprintf (stderr, "Pred is so high or so low! Diff is: %-.9g\tat node: %d\n", err_conv [i], i) ; #endif - if ((fabs (pred [i]) > 1.0e6 * ckt->CKTguessedFreq) || (err_conv [i] == 0)) + if (fabs (pred [i]) > 1.0e6 * ckt->CKTguessedFreq) { if (pred [i] > 0) pred [i] = 1.0e6 * ckt->CKTguessedFreq ; @@ -864,7 +865,7 @@ DCpss(CKTcircuit *ckt, // err_conv_ref / dynamic_test, predsum) ; //#endif - /* Take the mean value of time prediction trough the dynamic test variable - predsum becomes TIME */ + /* Take the mean value of time prediction through the dynamic test variable - predsum becomes TIME */ predsum = 1 / (predsum * dynamic_test) ; /* Store the predsum history as absolute value */