Skip to content

[Input] Make accessing input file data outside of phase node easier#869

Merged
speth merged 1 commit intoCantera:masterfrom
speth:extend-set-parameters
Jun 19, 2020
Merged

[Input] Make accessing input file data outside of phase node easier#869
speth merged 1 commit intoCantera:masterfrom
speth:extend-set-parameters

Conversation

@speth
Copy link
Copy Markdown
Member

@speth speth commented Jun 19, 2020

Some phase types utilize information in the input file that is contained outside the phase definition (e.g. phase definitions for nested phases). This change to ThermoPhase::setParameters makes it easier for those phases to have access to the full input
file definition without re-reading and reparsing the YAML file.

While I had originally thought that these cases were only in some of the dustier corners of Cantera, this also comes up in the new PlasmaPhase type being introduced in #700, so I think it's worth having a cleaner interface for this capability.

  • 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
  • The pull request is ready for review

Some phase types utilize information in the input file that is
contained outside the phase definition (e.g. phase definitions
for nested phases). This change to ThermoPhase::setParameters
makes it easier for those phases to have access to the full input
file definition without re-reading and reparsing the YAML file.
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 19, 2020

Codecov Report

Merging #869 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #869      +/-   ##
==========================================
- Coverage   71.57%   71.56%   -0.01%     
==========================================
  Files         372      372              
  Lines       44503    44494       -9     
==========================================
- Hits        31851    31843       -8     
+ Misses      12652    12651       -1     
Impacted Files Coverage Δ
include/cantera/thermo/IonsFromNeutralVPSSTP.h 100.00% <ø> (ø)
include/cantera/thermo/LatticeSolidPhase.h 48.38% <ø> (ø)
include/cantera/thermo/ThermoPhase.h 28.28% <ø> (ø)
src/thermo/IonsFromNeutralVPSSTP.cpp 43.28% <100.00%> (-0.06%) ⬇️
src/thermo/LatticeSolidPhase.cpp 78.60% <100.00%> (+0.37%) ⬆️
src/thermo/ThermoFactory.cpp 83.90% <100.00%> (ø)
src/thermo/ThermoPhase.cpp 69.37% <100.00%> (ø)
src/base/AnyMap.cpp 83.84% <0.00%> (-0.44%) ⬇️

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 8a591b4...9bffefb. Read the comment docs.

Copy link
Copy Markdown
Member

@bryanwweber bryanwweber left a comment

Choose a reason for hiding this comment

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

Small improvement here, otherwise seems like a good generalization.


//! Set equation of state parameters from an AnyMap phase description
void setParameters(const AnyMap& phaseNode);
//! Set equation of state parameters from an AnyMap phase description.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can this link to the AnyMap docs?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think Doxygen should do this automatically. See for example the docs for ThermoPhase::setState which contains automatically generated links to several classes:

//! Set the state using an AnyMap containing any combination of properties
//! supported by the thermodynamic model
/*!
* Accepted keys are:
* * `X` (mole fractions)
* * `Y` (mass fractions)
* * `T` or `temperature`
* * `P` or `pressure` [Pa]
* * `H` or `enthalpy` [J/kg]
* * `U` or `internal-energy` [J/kg]
* * `S` or `entropy` [J/kg/K]
* * `V` or `specific-volume` [m^3/kg]
* * `D` or `density` [kg/m^3]
*
* Composition can be specified as either an AnyMap of species names to
* values or as a composition string. All other values can be given as
* floating point values in Cantera's default units, or as strings with the
* units specified, which will be converted using the Units class.
*
* If no thermodynamic property pair is given, or only one of temperature or
* pressure is given, then 298.15 K and 101325 Pa will be used as necessary
* to fully set the state.
*/
virtual void setState(const AnyMap& state);

(and one spurious one to namespace Cantera.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great, I didn't know that Doxygen will autolink arbitrary words that it finds in the code. Guess you'd better not name a method with a common word 😂

@decaluwe
Copy link
Copy Markdown
Member

decaluwe commented Jun 19, 2020

Thanks, @speth. I looked over the code changes and don't have too much input, but agree that this looks really useful.

One quasi-related question: could this generalization be useful when importing/initializing interface reactions, where access to phase properties is useful but a little convoluted (at least last time I looked at it, admittedly before yaml serialization)?

@speth speth merged commit 3193c5f into Cantera:master Jun 19, 2020
@speth speth mentioned this pull request Jun 19, 2020
@speth
Copy link
Copy Markdown
Member Author

speth commented Jun 19, 2020

@decaluwe, I don't think there's an obvious parallel with interface reactions, although there have been some changes with the way those are handled since introducing the YAML format. Namely, we now have made explicit the requirement that you have to have a Kinetics object (and its associated ThermoPhase objects) in order to create a Reaction object from an input file, since you can't figure out what the units of the rate constant are without knowing what the units of the standard concentration are for each species in the reaction, and that information is carried by the ThermoPhase.

@speth speth deleted the extend-set-parameters branch July 23, 2024 15:38
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