Skip to content
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

Deprecate redundant ThermoPhase classes #787

Merged
merged 2 commits into from
Apr 5, 2020

Conversation

speth
Copy link
Member

@speth speth commented Jan 4, 2020

  • There is a clear use-case for this code change
  • The commit message has a short title & references relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage

Changes proposed in this pull request

  • Deprecate the "gas" mode of IdealSolnGasVPSS - this mode duplicates the more widely-used IdealGasPhase class.
  • Deprecate FixedChemPotSSTP - this class can be easily replaced using the StoichSubstance class with a ConstCpPoly species thermo object.

@codecov
Copy link

codecov bot commented Jan 4, 2020

Codecov Report

Merging #787 into master will decrease coverage by 0.02%.
The diff coverage is 87.09%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #787      +/-   ##
==========================================
- Coverage   71.45%   71.43%   -0.03%     
==========================================
  Files         372      372              
  Lines       43522    43547      +25     
==========================================
+ Hits        31098    31106       +8     
- Misses      12424    12441      +17     
Impacted Files Coverage Δ
src/thermo/FixedChemPotSSTP.cpp 55.00% <50.00%> (-11.97%) ⬇️
include/cantera/thermo/IdealSolnGasVPSS.h 91.66% <100.00%> (+2.77%) ⬆️
test/thermo/phaseConstructors.cpp 100.00% <100.00%> (ø)
test/thermo/thermoFromYaml.cpp 100.00% <100.00%> (ø)
..._problems/VCSnonideal/LatticeSolid_LiSi/latsol.cpp 93.18% <100.00%> (+0.49%) ⬆️
test_problems/VPsilane_test/silane_equil.cpp 69.23% <100.00%> (+2.56%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3a9f637...d2608d9. Read the comment docs.

importPhase(xmlphase, this);
}

FixedChemPotSSTP::FixedChemPotSSTP(const std::string& Ename, doublereal val) :
chemPot_(0.0)
{
warn_deprecated("classFixedChemPotSSTP", "To be removed after Cantera 2.5. "
"Use class StoichSubstance with a Mu0Poly (piecewise-Gibbs) species "
"thermo model");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this deprecated message different from the others?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a copy paste error, but still incorrect. I had initially thought that Mu0Poly was the species thermo model that could be used here, but the constant-cp model is actually the one that has the same behavior as this class.

@decaluwe
Copy link
Member

decaluwe commented Apr 4, 2020

Hi @speth - sorry for the time it took me to look at this. I feel like we discussed this at the steering committee meeting, and from what I remember these classes are indeed largely redundant.

The specific changes all look good to me.

  • I noticed one place where the deprecation message was different from the others, possibly a copy-paste error? Noted above.
  • I largely ignored close examination of the test results, but did notice that the internal energy values, for example, differed between the old and new implementations. Not sure whether this might matter for a user, but I suppose a FixedChemPotential model is not discriminating based on internal energy, anyway.
  • Out of curiosity, what does make_deprecation_warnings_fatal do?

This model can easily be replaced with StoichSustance using ConstCpPoly for the
species thermo.

The changed values in the LiSi regression tests suggest that there are some
implementation errors in the FixedChemPotSSTP class which will be automatically
resolved by eliminating it.
@speth speth force-pushed the deprecate-redundant-thermo branch from 9ba7926 to d2608d9 Compare April 4, 2020 19:00
@speth
Copy link
Member Author

speth commented Apr 4, 2020

The internal energy values change because the FixedChemPotSSTP class didn't actually set the density, leaving it at the nonsense default value of 0.001 kg/m^3. The StoichSubstance class in contrast actually uses the specified density value. For both classes, the enthalpy is the same but since the internal energy is calculated as u = h - p/rho, it has to change.

make_deprecation_warnings_fatal changes deprecation warnings into exceptions. The purpose of using this is so that use of deprecated methods in the test suite causes the test to fail, rather than generating warnings that might never be noticed.

@speth speth requested a review from decaluwe April 4, 2020 19:01
Copy link
Member

@decaluwe decaluwe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. A few general questions, but I'm guessing there are no real issues, here.

  1. So a general question: am I correct that VPSS stands for "variable pressure standard state" (i.e. the standard state depends on both temperature and pressure? If so,

    a. This seems coincidentally relevant to issue IdealGasPhase getStandardChemPotentials #841 that I added yesterday (i.e. this PR provides insight on that issue, not vice-versa), and

    b. I wonder if there is any reason a user would want to have this as a separate option? The actual phase behavior between IdealGasPhase and the gas option for IdealSolnGasVPSS would be exactly the same, it seems; is there any benefit to the user to having the standard state be pressure sensitive? Would they ever want to interrogate that property? My guess:

    • No.
    • Even if so, the benefit and degree of interest in this capability would be so minimal that this PR is still the right move.
  2. Now that I'm thinking about this a little more, are the solid and liquid options here also redundant? It seems like they might duplicate IdealSolidSolution? Just a hunch. Side note: I'll also note that there's no real reason to have the Solid as part of this latter class's name. I've found it just as useful for liquid solutions. But I digress...

Assuming the answers to the above are what I think they are, this looks like it's ready to go.

Thanks!

@speth
Copy link
Member Author

speth commented Apr 5, 2020

So a general question: am I correct that VPSS stands for "variable pressure standard state"

Yes. I think this name is a bit of a misnomer, however, compared to what the class actually does.

a. This seems coincidentally relevant to issue #841 that I added yesterday (i.e. this PR provides insight on that issue, not vice-versa), and

Let's deal with that elsewhere.

b. I wonder if there is any reason a user would want to have this as a separate option? The actual phase behavior between IdealGasPhase and the gas option for IdealSolnGasVPSS would be exactly the same, it seems; is there any benefit to the user to having the standard state be pressure sensitive? Would they ever want to interrogate that property?

Well, as far as I can tell, both IdealGasPhase and IdealSolnGasVPSS return the same values (to within rounding error) even for the standard state properties, such as getGibbs_RT. So I'm not sure that there is an observable difference between these classes.

2. Now that I'm thinking about this a little more, are the solid and liquid options here also redundant? It seems like they might duplicate IdealSolidSolution? Just a hunch. Side note: I'll also note that there's no real reason to have the Solid as part of this latter class's name. I've found it just as useful for liquid solutions.

The IdealSolidSolution class isn't a full replacement for IdealSolnGasVPSS in "soln" mode because you can't use the PDSS_SSVol (density as a function of temperature) species thermo model with IdealSolidSolution. So what I was thinking is that longer term, it might make sense to rename IdealSolnGasVPSS to IdealCondensed and deprecate IdealSolidSolution in favor of that.

@speth speth merged commit 15b9b33 into Cantera:master Apr 5, 2020
@bryanwweber
Copy link
Member

It seems like this PR reverted to SUNDIALS 5.0.0. Was that intentional?

@speth
Copy link
Member Author

speth commented Apr 5, 2020

No, obviously not. Fix pushed directly to master (5ae37ad).

@speth speth deleted the deprecate-redundant-thermo branch April 5, 2020 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants