Eliminates the need for redundant implementations in all the derived
classes. Also, make the return value a "const char*" to eliminate the dangerous
cast.
This function isn't actually called by CVODE (which uses its own difference
quotient method for calculating the Jacobian), so the note here isn't correct.
Since stdout may be used for writing the actual output file, direct all error
and debug messages to stderr, so that they can be shown to the user when
ctml_writer is invoked via ct2ctml_string.
ThermoPhase already provides an implementation of these methods that raises
an exception to indicate that the method is unimplemented. Therefore,
derived classes which do not implement a method do not need to do this.
Calling solve() again after a successful solution no longer automatically
triggers a Jacobian update. This enables relatively efficient sensitivity
analysis by sequentially perturbing the reaction multipliers and re-solving
the system. Since the perturbed system is close to the orignal, the solution
can be found after only a few steps, even when using the original Jacobian.
Change GeneralMatrix to allow derived classes to not implement QR
factorization. BandMatrix does not implement QR because this LAPACK
does not contain a QR algorithm for this matrix type.
The work array hasn't always been allocated, so taking its address isn't
necessarily valid. Also, dlange doesn't use the work array in the '1' norm
case anyway.
To both check and update the cached state values. Reduces
a lot of code duplication in the use of CachedValues.
I'd like to make state1, state2, and stateNum private so
that they can only be accessed with one of the validate functions,
and also add some asserts to the validate functions that do not
use all of the state variables to ensure that the unused ones are
set to their default values to prevent the case where the wrong
validate() function is called and incorrectly determines that the
cached state is valid.
First pass at making the state variables private caused a test failure
for test_problems/statmech. The m_spthermo->update() call in
IdealGasPhase::_updateThermo() throws an exception for this test right
now that gets caught in equilibrate(). When using validate() the cached
state variable is updated before the m_spthermo->update() call and subsequently
it thinks that the thermo does not need to be updated, whereas when
cached.state1 is being set after the m_spthermo->update() call it does not get
set. The current blessed output for that test is just the text of the exception
that gets caught, so I suspect the test may not work as is.
Forgot to update the cached state number in a few places in
my last commit.
Also uncovered a potential bug with m_A_Debye. m_A_Debye is only
set by A_Debye_TP() but is used by s_updatePitzer_lnMolalityActCoeff()
which could end up using an un-updated value for m_A_Debye through the
call chain:
setState_TP() -> calcDensity() -> getPartialMolarVolumes() ->
s_update_lnMolalityActCoeff() -> s_updatePitzer_lnMolalityActCoeff()
I changed both s_updatePitzer_lnMolalityActCoeff() and s_NBS_CLM_lnMolalityActCoeff()
to call A_Debye_TP() rather than using m_A_Debye directly to ensure that they
are always using an up to date value.