-
-
Notifications
You must be signed in to change notification settings - Fork 355
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
Update handling of critical properties #1141
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1141 +/- ##
==========================================
- Coverage 73.52% 73.50% -0.02%
==========================================
Files 365 365
Lines 48242 48247 +5
==========================================
- Hits 35470 35466 -4
- Misses 12772 12781 +9
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@speth … this looks overall very good. The only thing I could see is that the current (and previous!) implementation requires repeated parsing of a large file (6000+ lines for YAML). Would it make sense to read the file once and buffer either everything or only the subset of species that are used by a thermo model (which may, however, not be known at the time this is needed … ). A middle ground would be to introduce a PengRobinson::getCoeffs(const std::vector<std::string>& iNames)
so everything can be done in one sweep if so required.
src/thermo/PengRobinson.cpp
Outdated
// If the species is not present in the database, throw an error | ||
if(isnan(spCoeff[0])) | ||
{ | ||
AnyMap data = AnyMap::fromYamlFile("critical-properties.yaml"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this isn’t an approach that was introduced here, this means that the entire file is being parsed any time coefficients are needed? Is there a more efficient way to accomplish this (e.g. by buffering the file content the first time the file is read?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't quite as bad as it looks -- AnyMap::fromYamlFile
caches the AnyMap
generated for any given input file, and only re-reads it from disk if it's been modified. Changing this is a bit of scope creep for this PR, but I think solving it (for both P-R and R-K) won't be too complicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the resulting AnyMap
is indeed cached (i.e. yaml-cpp
does not have to parse again), then this observation could be laid to rest by including a comment at the two instances where the AnyMap::fromYamlFile
is called (i.e. no other action needed).
spCoeff[1] = omega_b * GasConstant * T_crit / P_crit; // coeff b | ||
break; | ||
} | ||
AnyMap data = AnyMap::fromYamlFile("critical-properties.yaml"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only other improvement I can see is to use preferred IUPAC names (PIN’s), as the descriptive-name
choices are somewhat arbitrary and probably do not consider various isomers (e.g. octane
presumably refers to ‘isooctane’, which however is 2,2,4-trimethylpentane
). I am not necessarily suggesting to add this here, but just to prepare for this capability by using fields for iupac-name
and another one for synonyms). Down the line, this may allow for disambiguation of alternative species names a mechanism may be using.
it looks like there are several packages that support lookup, e.g. PubChemPy or ChemSpiPy … there are likely others
I chose the name |
Certainly understand, but as implemented, the somewhat arbitrary choices for |
FWIW, I think that is sort of the point of the Certainly worth waiting to see if this is in much demand, before undertaking the significant amount of work it would require. |
I think the underlying issue is that most user input files come from Chemkin-format input files where there is no canonical species name, so matching the I'd say that the bigger feature of this PR (besides freeing us from XML) is defining a home for the critical state properties in user input files, so they can be used with any real gas model without having to compute the model-specific parameters manually. I'm not as sure about how useful this particular database is, but I think it's probably at least worth keeping around. |
Because the "input" AnyMap for a species isn't a full copy (the "thermo" and "transport" child nodes are stored separately), the node metadata needs to be copied explicitly for InputFileError to work correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@speth ... thanks for updating! This looks good to me.
Changes proposed in this pull request
critical-parameters
YAML field to compute Redlich-Kwong and Peng-Robinson coefficientscritProperties.xml
withcritical-properties.yaml
. Entries in the new file are consistent with YAML species definitions.I believe this last change has the distinction of being the last place in the code where the XML format was being used without a YAML alternative. This therefore allows us to start making "noisy" deprecation warnings about CTI and XML.
If applicable, fill in the issue number this pull request is fixing
This resolves a secondary point that was raised in Cantera/enhancements#20, and further discussed in Cantera/enhancements#107.
If applicable, provide an example illustrating new features this pull request is introducing
A species entry in a YAML input file:
An entry from
critical-properties.yaml
:Checklist
scons build
&scons test
) and unit tests address code coverage