From 235958d810943c6a48556be7ae1e297861c8a4ff Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Tue, 4 Dec 2007 17:34:19 +0000 Subject: [PATCH] Fixed an error in setState_UV() and similar routines that was occasionally causing numerical errors in the calculation of Jacobians. If the tolerances to these routines were set too low for calculation of Jacobians, then the dt*=1.5 logic was causing the evaluation to kick out of the routine with an incorrect deltaU value on the first iteration. This meant that the numerically derived Jacobian entry was off by a factor of 50%. --- Cantera/src/thermo/ThermoPhase.cpp | 57 +++++------------------------- 1 file changed, 9 insertions(+), 48 deletions(-) diff --git a/Cantera/src/thermo/ThermoPhase.cpp b/Cantera/src/thermo/ThermoPhase.cpp index 0932675eb..980c943f2 100644 --- a/Cantera/src/thermo/ThermoPhase.cpp +++ b/Cantera/src/thermo/ThermoPhase.cpp @@ -62,12 +62,12 @@ namespace Cantera { m_hasElementPotentials(false), m_chargeNeutralityNecessary(false) { - /* - * Call the assignment operator - */ - *this = operator=(right); + /* + * Call the assignment operator + */ + *this = operator=(right); } - + /* * operator=() * @@ -272,32 +272,14 @@ namespace Cantera { unstablePhase = true; } dt = (Htarget - Hold)/cpd; - if (dt > 0.0) { - if (!unstablePhase) { - if (Htop < Htarget) { - dt *= 1.5; - } - } else { - if (Hbot > Htarget) { - dt *= 1.5; - } - } - } else { - if (!unstablePhase) { - if (Hbot > Htarget) { - dt *= 1.5; - } - } else { - if (Htop < Htarget) { - dt *= 1.5; - } - } - } - // limit step size to 200 K + // limit step size to 210 K if (dt > 100.0) dt = 100.0; else if (dt < -100.0) dt = -100.0; + + // Calculate the new T Tnew = Told + dt; + // Limit the step size so that we are convergent // This is the step that makes it different from a // Newton's algorithm @@ -506,27 +488,6 @@ namespace Cantera { unstablePhase = true; } dt = (Starget - Sold)*Told/cpd; - if (dt > 0.0) { - if (!unstablePhase) { - if (Stop < Starget) { - dt *= 1.5; - } - } else { - if (Sbot > Starget) { - dt *= 1.5; - } - } - } else { - if (!unstablePhase) { - if (Sbot > Starget) { - dt *= 1.5; - } - } else { - if (Stop < Starget) { - dt *= 1.5; - } - } - } // limit step size to 200 K if (dt > 100.0) dt = 100.0;