[thermo] RedlichKwongMFTP critical property lookups#464
[thermo] RedlichKwongMFTP critical property lookups#464decaluwe wants to merge 0 commit intoCantera:masterfrom
RedlichKwongMFTP critical property lookups#464Conversation
Codecov Report
@@ Coverage Diff @@
## master #464 +/- ##
==========================================
+ Coverage 58.23% 58.28% +0.04%
==========================================
Files 386 386
Lines 42310 42393 +83
Branches 7252 7266 +14
==========================================
+ Hits 24640 24707 +67
- Misses 15488 15495 +7
- Partials 2182 2191 +9
Continue to review full report at Codecov.
|
speth
left a comment
There was a problem hiding this comment.
This looks really interesting, and will certainly make the RedlichKwong class much easier to use!
Based on the implementation, I would say that species are matched by name (identifier), not formula (composition), which does allow you to define isomers, but with no standard naming scheme. In order to expand the database and eliminate ambiguities, I think we would need to have a better identifier present, e.g. something like InChI. Not something that we need to worry about now, but worth considering for the future.
Rather than having users update this database, the other option for providing Tc/Pc instead of the a and b coefficients would be to look for this information in the species declaration as well. I think this would be worth looking at after we get a bit further with the new input file format.
data/inputs/critProperties.xml
Outdated
| @@ -0,0 +1,1150 @@ | |||
| <ctml> | |||
There was a problem hiding this comment.
Is there a reference for these values?
data/inputs/critProperties.xml
Outdated
| @@ -0,0 +1,1150 @@ | |||
| <ctml> | |||
|
|
|||
| <species name= "CCL4"> | |||
src/thermo/RedlichKwongMFTP.cpp
Outdated
| doublereal* RedlichKwongMFTP::getCoeff(const std::string& iName) | ||
| { | ||
| vector_fp vParams; | ||
| static doublereal spCoeff[2]; |
There was a problem hiding this comment.
I would recommend against using static arrays, as they introduce potential race conditions. Better to have this function return a vector<double>.
src/thermo/RedlichKwongMFTP.cpp
Outdated
| b_vec_Curr_[iSpecies]); | ||
| } | ||
| else | ||
| { |
There was a problem hiding this comment.
Prefer writing this on one line, e.g.
end block 1;
} else {
start block 2;
src/thermo/RedlichKwongMFTP.cpp
Outdated
| for (size_t isp = 0; isp < nDatabase; isp++) | ||
| { | ||
| XML_Node& acNodeDoc = doc->child(isp); | ||
| acNodeDocPtr = &acNodeDoc; |
There was a problem hiding this comment.
Doesn't look like this variable ever gets used.
src/thermo/RedlichKwongMFTP.cpp
Outdated
| P_crit = P_crit * 100000; | ||
|
|
||
| spCoeff[0] = 0.42748 * pow(GasConstant, 2) * pow(T_crit, 2.5) / P_crit; //coeff a | ||
| spCoeff[1] = 0.08664 *GasConstant * T_crit / P_crit; // coeff b |
There was a problem hiding this comment.
minor nitpick: space on both sides of the *.
src/thermo/critProperties.xml
Outdated
| @@ -0,0 +1,3 @@ | |||
| <ctml> | |||
There was a problem hiding this comment.
I think this file should be deleted (preferably, do this as a separate commit, then do an interactive rebase and squash that commit with the one that introduced the file in this location, so that it's like it never existed)
| TEST_F(RedlichKwongMFTP_Test, construct_from_cti) | ||
| { | ||
| const std::string valid_file("../data/co2_RK_example.cti"); | ||
| initializeTestPhase(valid_file); |
There was a problem hiding this comment.
I think it's fine to just write initializeTestPhase("../data/co2_RK_example.cti");
| public: | ||
| RedlichKwongMFTP_Test() { | ||
| test_phase.reset(newPhase("../data/co2_RK_example.cti")); | ||
| void initializeTestPhase(const std::string & filename) |
There was a problem hiding this comment.
Our normal style is to not have the space between the typename and the &, e.g. std::string& filename.
|
|
||
| TEST_F(RedlichKwongMFTP_Test, critPropLookup) | ||
| { | ||
| // Check to make sure that RedlichKwongMFTP is able to properly calcualte a and b |
|
Before making any more changes on this branch, I think we should address the warning regarding conflicts and rebase this PR on top of the current master. I have already done this if you want to pull the branch https://github.com/speth/cantera/tree/critProps and reset this PR to that commit. |
|
Hi Ray,
Yes, I’ve already done this on my local branch.
On the speciesName(i) call, what I’m saying is that making that change does not work. The critPropLookup test fails (this is replicated after I install, just trying to load a cti with some missing pureFluidParemeters - the critical properties are not successfully read from the xml.)
Have not been able to dig in and figure out why, but it seems odd that it would not work.
Steven
…Sent from my iPhone
On Dec 1, 2017, at 8:33 PM, Ray Speth ***@***.***> wrote:
Before making any more changes on this branch, I think we should address the warning regarding conflicts and rebase this PR on top of the current master. I have already done this if you want to pull the branch https://github.com/speth/cantera/tree/critProps and reset this PR to that commit.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
That's strange. What do you get if you use |
Changes proposed in this pull request:
-Makes it so that
Thermo::RedlichKwongMFTPinput files do not necessarily have to providepureFluidParametersfor every species. Since these can be calculated from the critical temperature and pressure for the Redlich Kwong EoS, we provide the ability to look up Tc and Pc for well-known species.-Provides a database of species with well-known critical properties. Species are currently matched by chemical formula, so isomers are currently prohibited. Can possibly add functionality to scan by species name, but this seems like it could lead to significant ambiguity. My preference is to keep this database limited to species where potential ambiguity is near zero. Database is stored in the
datafolder. Updating the database is relatively straight-foward for any end users - user simply has to lookup Tc and Pc and enter them into the database, rather than lookup Tc and Pc, calculate a and b parameters for R-K EoS, and then update the cti file.-Adds test suite coverage for this capability.