-
-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Matlab species thermo properties consistent and useful #522
Comments
Hi Ray, I've been thinking about your third bullet, some more: The complex part is that there are two relevant "standard states:"
So the two are distinct and necessarily so. The situation is easily confused because of the simplicity of the ideal gas EoS, where no "standard phase state" is actually required. One can calculate all thermodynamic properties quite readily, directly from the reference species properties, and mixture rules do not require any complex mathematics. So it's very easy (and quite common) to use the two terms synonymously. That said, do we need both (or either) "standard state" and "reference species property" calculations featured in the codebase? You can't really avoid having the reference data loaded and stored as such, but I'm somewhat skeptical that we need the standard state data explicitly calculated or stored.
As I'm typing this, an additional confusion just reared its ugly head: the The form of where C_k_o are the
But obviously, it would be nice to get some clarity, here. I just don't yet know what that should be. I'm leaning toward just having the "reference" state being the only one referenced in the code, which seems to be your preference, as well. I'm just still a little wary that this may have unintended consequences or cause other unanticipated confusions. |
A status update for the "experimental" Matlab toolbox: The |
For the sake of consistency, this issue would be resolved by providing the same interface for MATLAB as for Python, correct? In the case of MATLAB's The distinctions of the corresponding docstrings aren't necessarily clear to me with cantera/include/cantera/thermo/ThermoPhase.h Lines 944 to 951 in 9d0e54a
vs. cantera/include/cantera/thermo/ThermoPhase.h Lines 866 to 872 in 9d0e54a
with experimental MATLAB cantera/interfaces/matlab_experimental/Base/ThermoPhase.m Lines 122 to 133 in 9d0e54a
and Python cantera/interfaces/cython/cantera/thermo.pyx Lines 1664 to 1668 in 9d0e54a
The legacy MATLAB toolbox stated
which indicates some copy-pasta issue in the new toolbox docstring. Overall, is this just about one using a reference pressure while the other isn't? I.e. MATLAB references data that are typically provided in textbook appendices (e.g. Appendix A, Glassman 3rd ed)? What is the relationship to what is calculated here? Is this what MATLAB uses? cantera/include/cantera/thermo/SpeciesThermoInterpType.h Lines 191 to 205 in 9d0e54a
The other properties mentioned on top would be Given that we have a new experimental MATLAB toolbox, there's a window of opportunity to make things consistent. PS: one alternative would be to switch the Python API to the MATLAB convention by dropping the PPS: this is code from (now removed) void PDSS_IdealGas::setTemperature(double temp)
{
m_temp = temp;
m_spthermo->updatePropertiesTemp(temp, &m_cp0_R, &m_h0_RT, &m_s0_R);
m_g0_RT = m_h0_RT - m_s0_R;
m_V0 = GasConstant * m_temp / m_p0;
m_hss_RT = m_h0_RT;
m_cpss_R = m_cp0_R;
m_sss_R = m_s0_R - log(m_pres/m_p0);
m_gss_RT = m_hss_RT - m_sss_R;
m_Vss = GasConstant * m_temp / m_pres;
} |
Alright. Some further digging cleared things up (especially in conjunction with @decaluwe's comments). With definitions cantera/include/cantera/thermo/PDSS.h Lines 457 to 467 in 9d0e54a
and, similarly cantera/include/cantera/thermo/VPStandardStateTP.h Lines 259 to 261 in 9d0e54a
and cantera/include/cantera/thermo/VPStandardStateTP.h Lines 278 to 280 in 9d0e54a
as well as cantera/src/thermo/VPStandardStateTP.cpp Lines 46 to 50 in 9d0e54a
and cantera/src/thermo/VPStandardStateTP.cpp Lines 99 to 103 in 9d0e54a
everything follows quite nicely. Re-reading @decaluwe's comments, I tend to agree that it may not make sense to provide an API for standard-state quantities, which I believe (?) I read from
and
The crux is that PS: here's further context (sorry if I am documenting this here as I am reading up to this) cantera/include/cantera/thermo/ThermoPhase.h Lines 178 to 200 in 9d0e54a
In conclusion, I'd be in favor to not expose the first two levels (reference state and standard state) at advanced APIs, i.e. deprecate |
I'm 👍 on leaving the "reference state" properties out of the high-level APIs (and perhaps, they should even be The "standard state" properties are not as important as the "partial molar" ones, but I think there are some cases where they can be useful to look at. Of course, this runs into the perpetual issue of Cantera's definition of "standard state" being different from the ones generally used in thermodynamics textbooks. The other source of variability in here that doesn't really help is the mix of dimensional versus nondimensional quantities, for example providing nondimensional reference state but dimensional partial molar properties. Likewise, here, I think it would be best to regard the nondimensional properties as implementation details. It's probably not worth immediately removing such accessors, but at least we can avoid increasing the proliferation of these functions. |
The documentation for the Matlab function
enthalpies_RT
says it returns the "standard-state" species enthalpies. However, it ultimately calls the C++ methodThermoPhase::getEnthalpy_RT_ref
, which returns what Cantera calls the "reference state" enthalpies. This represents the confluence of several problems:The same issue applies for
gibbs_RT
,entropies_R
, andCp_R
, except that for these, the documentation doesn't even say that the values returned are for the reference state.The text was updated successfully, but these errors were encountered: