Closed alexchandel closed 2 years ago
The error appears to be related to the presence of noncondensables. Removing the hydrogen results in no error, either for add_heat
or flasher.flash(zs=zs, P=pres, T=800)
. But noncondensables and inerts are necessary.
The issue is specifically in thermo's liquid phase calculations.
This probably related to #105. There is no documented way to add substances that don't participate in equilibrium (like hydrogen).
For example, removing the hot_start
option, the 323.15K case calculates the H2 fraction at 2.88144893296719e-304
. Much hotter and it probably underfllows to 0. This needs to be handled correctly, especially given #105.
I've opened #107 for the underlying liquid issue. However, the flasher also needs to be fixed, as during exception handling it divides by zero, and should not crash if the liquid phase does not exist.
This issue was present in thermo==0.2.14 chemicals==1.0.17, and likely earlier and later. But #107 and PH flashing with a hot_start
work in thermo==0.2.18 chemicals==1.0.19, although TP with hot_start
still does not (see #108).
Attempting a CEOSGas + GibbsExcessLiquid[NRTL] flash with a
hot_start
to save time results a nonsensicalValueError: math domain error
being thrown bystability_test_Michelsen
inflash_vl.py
. If nohot_start
is provided, the error does not occur.The traceback is provided below, and example code after. Note that the solver in
flash_utils.py
also malfunctions and throws an additionalZeroDivisionError: float division by zero
.The
ValueError
is similar to what I see if I callflash()
with a moderately high temperature, like#flasher.flash(zs=zs, P=pres, T=800)
in the example code provided. I suspectthermo
is calculatingdH_dT_P()
at the guess, adding ∆H/dH_dT_P() to the temperature, obtaining a high temperature (due to skipping latent heats / vaporizations at intermediate temperatures), and flashing at this temperature. Then the flash crashes because of the noncondensable hydrogen.The following self-contained example reproduces the above error.