MCPcopy Create free account
hub / github.com/CoolProp/CoolProp / CoolPropSolver

Method CoolPropSolver

wrappers/Modelica/src/coolpropsolver.cpp:9–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include <stdlib.h>
8
9CoolPropSolver::CoolPropSolver(const std::string& mediumName, const std::string& libraryName, const std::string& substanceName)
10 : BaseSolver(mediumName, libraryName, substanceName) {
11
12 // Fluid name can be used to pass in other parameters.
13 // The string can be composed like "Propane|enable_TTSE=1|calc_transport=0"
14 std::vector<std::string> name_options = strsplit(substanceName, '|');
15
16 // Set the defaults
17 fluidType = -1;
18 enable_TTSE = false;
19 debug_level = 0;
20 calc_transport = false;
21 extend_twophase = false;
22 twophase_derivsmoothing_xend = 0;
23 rho_smoothing_xend = 0;
24
25 if (name_options.size() > 1) {
26 for (unsigned int i = 1; i < name_options.size(); i++) {
27 // Split around the equals sign
28 std::vector<std::string> param_val = strsplit(name_options[i], '=');
29 if (param_val.size() != 2) {
30 errorMessage((char*)format("Could not parse the option [%s], must be in the form param=value", name_options[i].c_str()).c_str());
31 }
32
33 // Check each of the options in turn
34 if (!param_val[0].compare("enable_TTSE")) {
35 if (!param_val[1].compare("1") || !param_val[1].compare("true")) {
36 std::cout << "TTSE is on\n";
37 enable_TTSE = true;
38 } else if (!param_val[1].compare("0") || !param_val[1].compare("false")) {
39 std::cout << "TTSE is off\n";
40 enable_TTSE = false;
41 } else
42 errorMessage((char*)format("I don't know how to handle this option [%s]", name_options[i].c_str()).c_str());
43 //throw NotImplementedError((char*)format("I don't know how to handle this option [%s]",name_options[i].c_str()).c_str());
44 } else if (!param_val[0].compare("calc_transport")) {
45 if (!param_val[1].compare("1") || !param_val[1].compare("true"))
46 calc_transport = true;
47 else if (!param_val[1].compare("0") || !param_val[1].compare("false"))
48 calc_transport = false;
49 else
50 errorMessage((char*)format("I don't know how to handle this option [%s]", name_options[i].c_str()).c_str());
51 } else if (!param_val[0].compare("enable_EXTTP")) {
52 if (!param_val[1].compare("1") || !param_val[1].compare("true"))
53 extend_twophase = true;
54 else if (!param_val[1].compare("0") || !param_val[1].compare("false"))
55 extend_twophase = false;
56 else
57 errorMessage((char*)format("I don't know how to handle this option [%s]", name_options[i].c_str()).c_str());
58 } else if (!param_val[0].compare("twophase_derivsmoothing_xend")) {
59 twophase_derivsmoothing_xend = strtod(param_val[1].c_str(), NULL);
60 if (twophase_derivsmoothing_xend < 0 || twophase_derivsmoothing_xend > 1)
61 errorMessage(
62 (char*)format("I don't know how to handle this twophase_derivsmoothing_xend value [%d]", param_val[0].c_str()).c_str());
63 } else if (!param_val[0].compare("rho_smoothing_xend")) {
64 rho_smoothing_xend = strtod(param_val[1].c_str(), NULL);
65 if (rho_smoothing_xend < 0 || rho_smoothing_xend > 1)
66 errorMessage((char*)format("I don't know how to handle this rho_smoothing_xend value [%d]", param_val[0].c_str()).c_str());

Callers

nothing calls this directly

Calls 4

strsplitFunction · 0.85
errorMessageFunction · 0.85
formatFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected