diff --git a/Web/fluid_properties/Incompressibles.bib b/Web/fluid_properties/Incompressibles.bib index 221abb60..cf9b362f 100644 --- a/Web/fluid_properties/Incompressibles.bib +++ b/Web/fluid_properties/Incompressibles.bib @@ -136,6 +136,19 @@ Timestamp = {2014.12.17} } +@Article{Wagner2002, + Title = {The IAPWS Formulation 1995 for the Thermodynamic Properties of Ordinary Water Substance for General and Scientific Use}, + Author = {W. Wagner and A. Pruss}, + Journal = {Journal of Physical and Chemical Reference Data}, + Year = {2002}, + Pages = {387--535}, + Volume = {31}, + + Doi = {10.1063/1.1461829}, + Owner = {jowr}, + Timestamp = {2014.05.28} +} + @TechReport{Zavoico2001, Title = {{Solar Power Tower Design Basis Document}}, Author = {Alexis B. Zavoico}, diff --git a/dev/incompressible_liquids/CPIncomp/PureFluids.py b/dev/incompressible_liquids/CPIncomp/PureFluids.py index 70c72901..0946bdc0 100644 --- a/dev/incompressible_liquids/CPIncomp/PureFluids.py +++ b/dev/incompressible_liquids/CPIncomp/PureFluids.py @@ -562,3 +562,31 @@ class PNF(PureData): self.reference = "Paratherm2013" self.reshapeAll() + +class Water(PureData): + """ + This is just a fit of the full EOS from Wagner and Pruss + """ + def __init__(self): + PureData.__init__(self) + self.density.source = self.density.SOURCE_DATA + self.viscosity.source = self.viscosity.SOURCE_DATA + self.specific_heat.source = self.specific_heat.SOURCE_DATA + self.conductivity.source = self.conductivity.SOURCE_DATA + self.saturation_pressure.source = self.saturation_pressure.SOURCE_DATA + self.temperature.data = np.array([0.0000e+00, 5.1282e+00, 1.0256e+01, 1.5385e+01, 2.0513e+01, 2.5641e+01, 3.0769e+01, 3.5897e+01, 4.1026e+01, 4.6154e+01, 5.1282e+01, 5.6410e+01, 6.1538e+01, 6.6667e+01, 7.1795e+01, 7.6923e+01, 8.2051e+01, 8.7179e+01, 9.2308e+01, 9.7436e+01, 1.0256e+02, 1.0769e+02, 1.1282e+02, 1.1795e+02, 1.2308e+02, 1.2821e+02, 1.3333e+02, 1.3846e+02, 1.4359e+02, 1.4872e+02, 1.5385e+02, 1.5897e+02, 1.6410e+02, 1.6923e+02, 1.7436e+02, 1.7949e+02, 1.8462e+02, 1.8974e+02, 1.9487e+02, 2.0000e+02 ])+273.15 + self.density.data = np.array([1.0023e+03, 1.0024e+03, 1.0020e+03, 1.0013e+03, 1.0003e+03, 9.9907e+02, 9.9758e+02, 9.9587e+02, 9.9396e+02, 9.9185e+02, 9.8957e+02, 9.8713e+02, 9.8453e+02, 9.8178e+02, 9.7888e+02, 9.7585e+02, 9.7343e+02, 9.7014e+02, 9.6674e+02, 9.6321e+02, 9.5956e+02, 9.5580e+02, 9.5192e+02, 9.4793e+02, 9.4383e+02, 9.3962e+02, 9.3530e+02, 9.3086e+02, 9.2632e+02, 9.2166e+02, 9.1689e+02, 9.1200e+02, 9.0700e+02, 9.0188e+02, 8.9663e+02, 8.9127e+02, 8.8577e+02, 8.8014e+02, 8.7438e+02, 8.6848e+02 ]) + self.specific_heat.data = np.array([4.1960e+03, 4.1845e+03, 4.1768e+03, 4.1719e+03, 4.1689e+03, 4.1673e+03, 4.1668e+03, 4.1670e+03, 4.1678e+03, 4.1691e+03, 4.1707e+03, 4.1727e+03, 4.1750e+03, 4.1777e+03, 4.1807e+03, 4.1840e+03, 4.1842e+03, 4.1884e+03, 4.1930e+03, 4.1981e+03, 4.2038e+03, 4.2100e+03, 4.2168e+03, 4.2242e+03, 4.2323e+03, 4.2411e+03, 4.2507e+03, 4.2611e+03, 4.2723e+03, 4.2844e+03, 4.2974e+03, 4.3114e+03, 4.3265e+03, 4.3426e+03, 4.3600e+03, 4.3785e+03, 4.3984e+03, 4.4198e+03, 4.4427e+03, 4.4672e+03 ]) + self.conductivity.data = np.array([5.5933e-01, 5.7148e-01, 5.8247e-01, 5.9252e-01, 6.0177e-01, 6.1031e-01, 6.1823e-01, 6.2557e-01, 6.3240e-01, 6.3873e-01, 6.4460e-01, 6.5002e-01, 6.5501e-01, 6.5958e-01, 6.6376e-01, 6.6754e-01, 6.7095e-01, 6.7398e-01, 6.7665e-01, 6.7897e-01, 6.8187e-01, 6.8352e-01, 6.8484e-01, 6.8584e-01, 6.8652e-01, 6.8689e-01, 6.8697e-01, 6.8675e-01, 6.8624e-01, 6.8544e-01, 6.8437e-01, 6.8306e-01, 6.8169e-01, 6.8001e-01, 6.7802e-01, 6.7577e-01, 6.7326e-01, 6.7050e-01, 6.6749e-01, 6.6423e-01 ]) + self.viscosity.data = np.array([1.7811e-03, 1.5053e-03, 1.2921e-03, 1.1236e-03, 9.8781e-04, 8.7664e-04, 7.8435e-04, 7.0683e-04, 6.4103e-04, 5.8466e-04, 5.3599e-04, 4.9366e-04, 4.5661e-04, 4.2399e-04, 3.9511e-04, 3.6944e-04, 3.4650e-04, 3.2593e-04, 3.0741e-04, 2.9068e-04, 2.7595e-04, 2.6216e-04, 2.4957e-04, 2.3807e-04, 2.2752e-04, 2.1782e-04, 2.0888e-04, 2.0062e-04, 1.9297e-04, 1.8588e-04, 1.7928e-04, 1.7313e-04, 1.6739e-04, 1.6202e-04, 1.5698e-04, 1.5225e-04, 1.4780e-04, 1.4360e-04, 1.3963e-04, 1.3587e-04 ]) + self.saturation_pressure.data = np.array([ np.NAN, 8.8041e+02, 1.2495e+03, 1.7485e+03, 2.4147e+03, 3.2931e+03, 4.4381e+03, 5.9145e+03, 7.7984e+03, 1.0179e+04, 1.3160e+04, 1.6858e+04, 2.1410e+04, 2.6968e+04, 3.3704e+04, 4.1808e+04, 5.1493e+04, 6.2992e+04, 7.6562e+04, 9.2482e+04, 1.1106e+05, 1.3261e+05, 1.5750e+05, 1.8610e+05, 2.1882e+05, 2.5608e+05, 2.9834e+05, 3.4608e+05, 3.9979e+05, 4.6002e+05, 5.2732e+05, 6.0227e+05, 6.8548e+05, 7.7757e+05, 8.7919e+05, 9.9104e+05, 1.1138e+06, 1.2482e+06, 1.3950e+06, 1.5549e+06 ]) + self.Tmin = np.min(self.temperature.data) + self.Tmax = np.max(self.temperature.data) + self.TminPsat = np.min(self.temperature.data[~np.isnan(self.saturation_pressure.data)]) + self.name = "Water" + self.description = "Fit of the subcooled region of the full EOS from 1 bar to 100 bar" + self.reference = "Wagner2002, Transport properties from Huber et. al (2 papers)" + self.reshapeAll() + # Specific heat needs special coefficiencts + # self.specific_heat.coeffs = np.zeros((5,7)) + diff --git a/dev/incompressible_liquids/json/Water.json b/dev/incompressible_liquids/json/Water.json new file mode 100644 index 00000000..e5d0a49a --- /dev/null +++ b/dev/incompressible_liquids/json/Water.json @@ -0,0 +1,96 @@ +{ + "T_freeze": { + "coeffs": "null", + "type": "notdefined" + }, + "Tbase": 3.731500e+02, + "Tmax": 4.731500e+02, + "Tmin": 2.731500e+02, + "TminPsat": 2.782782e+02, + "conductivity": { + "coeffs": [ + [ + 6.808850e-01 + ], + [ + 3.873815e-04 + ], + [ + -6.764932e-06 + ], + [ + 1.304806e-08 + ] + ], + "type": "polynomial" + }, + "density": { + "coeffs": [ + [ + 9.615327e+02 + ], + [ + -7.059969e-01 + ], + [ + -2.541021e-03 + ], + [ + 3.442833e-06 + ] + ], + "type": "polynomial" + }, + "description": "Fit of the subcooled region of the full EOS from 1 bar to 100 bar", + "mass2input": { + "coeffs": "null", + "type": "notdefined" + }, + "mole2input": { + "coeffs": "null", + "type": "notdefined" + }, + "name": "Water", + "reference": "Wagner2002, Transport properties from Huber et. al (2 papers)", + "saturation_pressure": { + "coeffs": [ + -3.863635e+03, + -4.391760e+01, + -2.326064e+01 + ], + "type": "exponential" + }, + "specific_heat": { + "coeffs": [ + [ + 4.199132e+03 + ], + [ + 1.116817e+00 + ], + [ + 1.238871e-02 + ], + [ + 2.770690e-05 + ] + ], + "type": "polynomial" + }, + "viscosity": { + "coeffs": [ + 5.598818e+02, + -1.411882e+02, + 1.058592e+01 + ], + "type": "exponential" + }, + "volume2input": { + "coeffs": "null", + "type": "notdefined" + }, + "xbase": 0.000000e+00, + "xid": "pure", + "xmax": 1.000000e+00, + "xmin": 0.000000e+00 +} \ No newline at end of file diff --git a/dev/scripts/release.bsh b/dev/scripts/release.bsh index ccca39cf..a9ac76e4 100755 --- a/dev/scripts/release.bsh +++ b/dev/scripts/release.bsh @@ -1,4 +1,23 @@ #!/bin/bash +############################################## +# CoolProp release management +############################################## +# +# Things to remember when you make a new release: +# +# * Run the script and check the logs +# * Make a tag in your git software +# * Update the default download on sourceforge to point to the new sources +# +# In case you experience problems with permissions, login to +# sourceforge by creating a new shell with +# ssh -t username,coolprop@shell.sf.net create +# and the run +# find . -type d ! -perm 0775 -exec chmod 0775 {} \; +# find . -type f ! -perm 0664 -exec chmod 0664 {} \; +# in /home/project-web/coolprop/htdocs and /home/frs/project/coolprop/ +# to reset all permissions. +# # # Make sure that only two arguments are passed to this script - the version that # will be released and the dryrun vs. release option. @@ -9,39 +28,38 @@ if [ $# != 2 ]; then exit 1 fi # -CPVERSION="$1" -BASEDIR="$HOME/buildbot/server-master/public_html" -REPODIR="$HOME/src/CoolPropFull.git" -TMPSDIR="$HOME/src/CoolProp.sources" -BINFOLDER="binaries" -DOCFOLDER="sphinx" -SRCFOLDER="$BASEDIR/$BINFOLDER/source" -DOC4FILES="4.2.5/coolpropv425docs.zip" -DOC4FOLDER="$DOCFOLDER/v4" +# Just a small function print messages SEPARATOR="----------------------------------" -# -SFUSER="jorritw" # ibell or jorritw -# function printMessage { echo " " echo $SEPARATOR echo "$1" return 0 } -# +# Now we use the function defined above printMessage "Processing the input variables: " # +# Process the version number and set parameters accordingly CPVERSION="$1" if [[ $CPVERSION == +([0-9]).+([0-9]).+([0-9]) ]]; then echo "CPVERSION = $CPVERSION" - BINFOLDER=release + BINFOLDER="release" elif [ "$CPVERSION" == "nightly" ]; then echo "CPVERSION = $CPVERSION - which is a valid input" + BINFOLDER="binaries" else echo "CPVERSION = $CPVERSION - not valid!" exit 1 fi # +BASEDIR="$HOME/buildbot/server-master/public_html" +REPODIR="$HOME/src/CoolPropFull.git" +TMPSDIR="$HOME/src/CoolProp.sources" +SRCFOLDER="$BASEDIR/$BINFOLDER/source" +DOCFOLDER="sphinx" +DOC4FILES="4.2.5/coolpropv425docs.zip" +DOC4FOLDER="$DOCFOLDER/v4" +# if [ "$2" == "release" ]; then DRYRUN=false else @@ -72,8 +90,9 @@ else #rm -rf .git* find . -iwholename "*/.git*" -exec rm -rf {} \; cd .. - rm $SRCFOLDER/CoolProp_sources.zip - zip -r $SRCFOLDER/CoolProp_sources.zip $(basename $TMPSDIR) + mkdir -p $SRCFOLDER + rm -f $SRCFOLDER/CoolProp_sources.zip + zip -rq $SRCFOLDER/CoolProp_sources.zip $(basename $TMPSDIR) cd $(basename $TMPSDIR) popd rm -f "$BINFOLDER/README.rst.txt" diff --git a/src/AbstractState.cpp b/src/AbstractState.cpp index 09ec08fc..71cacf6d 100644 --- a/src/AbstractState.cpp +++ b/src/AbstractState.cpp @@ -121,7 +121,7 @@ bool AbstractState::clear() { this->_gibbsmolar.clear(); this->_logp.clear(); this->_logrhomolar.clear(); - + ///// Smoothing values //this->rhospline = -_HUGE; //this->dsplinedp = -_HUGE; @@ -154,6 +154,11 @@ bool AbstractState::clear() { this->_d2alphar_dDelta_dTau_lim.clear(); this->_d3alphar_dDelta2_dTau_lim.clear(); + /// Transport properties + this->_viscosity.clear(); + this->_conductivity.clear(); + this->_surface_tension.clear(); + return true; } double AbstractState::trivial_keyed_output(int key) @@ -419,7 +424,7 @@ void get_dT_drho(AbstractState &AS, parameters index, long double &dT, long doub R = AS.gas_constant(), delta = rho/rhor, tau = Tr/T; - + switch (index) { case iT: @@ -497,9 +502,9 @@ void get_dT_drho_second_derivatives(AbstractState &AS, int index, long double &d delta = rho/rhor, tau = Tr/T; - // Here we use T and rho as independent variables since derivations are already done by Thorade, 2013, + // Here we use T and rho as independent variables since derivations are already done by Thorade, 2013, // Partial derivatives of thermodynamic state propertiesfor dynamic simulation, DOI 10.1007/s12665-013-2394-z - + switch (index) { case iT: @@ -584,7 +589,7 @@ long double AbstractState::calc_first_partial_deriv(parameters Of, parameters Wr } long double AbstractState::calc_second_partial_deriv(parameters Of1, parameters Wrt1, parameters Constant1, parameters Wrt2, parameters Constant2) { - long double dOf1_dT, dOf1_drho, dWrt1_dT, dWrt1_drho, dConstant1_dT, dConstant1_drho, d2Of1_dT2, d2Of1_drhodT, + long double dOf1_dT, dOf1_drho, dWrt1_dT, dWrt1_drho, dConstant1_dT, dConstant1_drho, d2Of1_dT2, d2Of1_drhodT, d2Of1_drho2, d2Wrt1_dT2, d2Wrt1_drhodT, d2Wrt1_drho2, d2Constant1_dT2, d2Constant1_drhodT, d2Constant1_drho2, dWrt2_dT, dWrt2_drho, dConstant2_dT, dConstant2_drho, N, D, dNdrho__T, dDdrho__T, dNdT__rho, dDdT__rho, dderiv1_drho, dderiv1_dT, second; @@ -596,34 +601,34 @@ long double AbstractState::calc_second_partial_deriv(parameters Of1, parameters get_dT_drho_second_derivatives(*this, Of1, d2Of1_dT2, d2Of1_drhodT, d2Of1_drho2); get_dT_drho_second_derivatives(*this, Wrt1, d2Wrt1_dT2, d2Wrt1_drhodT, d2Wrt1_drho2); get_dT_drho_second_derivatives(*this, Constant1, d2Constant1_dT2, d2Constant1_drhodT, d2Constant1_drho2); - + // First derivatives of terms involved in the second derivative get_dT_drho(*this, Wrt2, dWrt2_dT, dWrt2_drho); get_dT_drho(*this, Constant2, dConstant2_dT, dConstant2_drho); - + // Numerator and denominator of first partial derivative term N = dOf1_dT*dConstant1_drho - dOf1_drho*dConstant1_dT; D = dWrt1_dT*dConstant1_drho - dWrt1_drho*dConstant1_dT; - + // Derivatives of the numerator and denominator of the first partial derivative term with respect to rho, T held constant // They are of similar form, with Of1 and Wrt1 swapped dNdrho__T = dOf1_dT*d2Constant1_drho2 + d2Of1_drhodT*dConstant1_drho - dOf1_drho*d2Constant1_drhodT - d2Of1_drho2*dConstant1_dT; dDdrho__T = dWrt1_dT*d2Constant1_drho2 + d2Wrt1_drhodT*dConstant1_drho - dWrt1_drho*d2Constant1_drhodT - d2Wrt1_drho2*dConstant1_dT; - + // Derivatives of the numerator and denominator of the first partial derivative term with respect to T, rho held constant // They are of similar form, with Of1 and Wrt1 swapped dNdT__rho = dOf1_dT*d2Constant1_drhodT + d2Of1_dT2*dConstant1_drho - dOf1_drho*d2Constant1_dT2 - d2Of1_drhodT*dConstant1_dT; dDdT__rho = dWrt1_dT*d2Constant1_drhodT + d2Wrt1_dT2*dConstant1_drho - dWrt1_drho*d2Constant1_dT2 - d2Wrt1_drhodT*dConstant1_dT; - + // First partial of first derivative term with respect to T dderiv1_drho = (D*dNdrho__T - N*dDdrho__T)/pow(D, 2); - + // First partial of first derivative term with respect to rho dderiv1_dT = (D*dNdT__rho - N*dDdT__rho)/pow(D, 2); // Complete second derivative second = (dderiv1_dT*dConstant2_drho - dderiv1_drho*dConstant2_dT)/(dWrt2_dT*dConstant2_drho - dWrt2_drho*dConstant2_dT); - + return second; } // // ---------------------------------------- diff --git a/src/CoolProp.cpp b/src/CoolProp.cpp index dcb8133f..de337e6a 100644 --- a/src/CoolProp.cpp +++ b/src/CoolProp.cpp @@ -77,7 +77,7 @@ void extract_backend(const std::string &fluid_string, std::string &backend, std: { std::size_t i; std::string _fluid_string = fluid_string; - // For backwards compatibility reasons, if "REFPROP-" or "REFPROP-MIX:" start + // For backwards compatibility reasons, if "REFPROP-" or "REFPROP-MIX:" start // the fluid_string, replace them with "REFPROP::" if (_fluid_string.find("REFPROP-MIX:") == 0) { @@ -177,21 +177,21 @@ std::string extract_fractions(const std::string &fluid_string, std::vector &fluid_names, - const std::vector &z, +void _PropsSI_initialize(const std::string &backend, + const std::vector &fluid_names, + const std::vector &z, shared_ptr &State){ - + if (fluid_names.empty()){throw ValueError("fluid_names cannot be empty");} - + std::vector fractions(1, 1.0); // Default to one component, unity fraction const std::vector *fractions_ptr = NULL; // Pointer to the array to be used; - + if (fluid_names.size() > 1){ // Set the pointer - we are going to use the supplied fractions; they must be provided fractions_ptr = &z; @@ -220,7 +220,7 @@ void _PropsSI_initialize(const std::string &backend, State.reset(AbstractState::factory(backend, fluid_names)); } } - + // Set the fraction for the state if (State->using_mole_fractions()){ // If a predefined mixture or a pure fluid, the fractions will already be set @@ -268,25 +268,36 @@ struct output_parameter{ }; }; -void _PropsSI_outputs(shared_ptr &State, - std::vector output_parameters, - CoolProp::input_pairs input_pair, - const std::vector &in1, +void _PropsSI_outputs(shared_ptr &State, + std::vector output_parameters, + CoolProp::input_pairs input_pair, + const std::vector &in1, const std::vector &in2, std::vector > &IO){ - + // Check the inputs if (in1.size() != in2.size()){ throw ValueError(format("lengths of in1 [%d] and in2 [%d] are not the same", in1.size(), in2.size()));} bool one_input_one_output = (in1.size() == 1 && in2.size() == 1 && output_parameters.size() == 1); - + + if (get_debug_level() > 100) + { + std::cout << format("%s (%d): input pair = %d ",__FILE__,__LINE__, input_pair) << std::endl; + std::cout << format("%s (%d): in1 = %s ",__FILE__,__LINE__, vec_to_string(in1).c_str()) << std::endl; + std::cout << format("%s (%d): in2 = %s ",__FILE__,__LINE__, vec_to_string(in2).c_str()) << std::endl; + } + // Resize the output matrix std::size_t N1 = std::max(static_cast(1), in1.size()); std::size_t N2 = std::max(static_cast(1), output_parameters.size()); IO.resize(N1, std::vector(N2, _HUGE)); - + // Throw an error if at the end, there were no successes bool success = false; - + + if (get_debug_level() > 100) + { + std::cout << format("%s (%d): Iterating over %d input value pairs.",__FILE__,__LINE__,IO.size()) << std::endl; + } // Iterate over the state variable inputs for (std::size_t i = 0; i < IO.size(); ++i){ try{ @@ -301,7 +312,7 @@ void _PropsSI_outputs(shared_ptr &State, for (std::size_t j = 0; j < IO[i].size(); ++j){ IO[i][j] = _HUGE; } continue; } - + for (std::size_t j = 0; j < IO[i].size(); ++j){ try{ output_parameter &output = output_parameters[j]; @@ -328,13 +339,13 @@ void _PropsSI_outputs(shared_ptr &State, if (success == false) { IO.clear(); throw ValueError(format("No outputs were able to be calculated"));} } -void _PropsSImulti(const std::vector &Outputs, - const std::string &Name1, +void _PropsSImulti(const std::vector &Outputs, + const std::string &Name1, const std::vector &Prop1, - const std::string &Name2, - const std::vector &Prop2, - const std::string &backend, - const std::vector &fluids, + const std::string &Name2, + const std::vector &Prop2, + const std::string &backend, + const std::vector &fluids, const std::vector &fractions, std::vector > &IO) { @@ -342,7 +353,7 @@ void _PropsSImulti(const std::vector &Outputs, CoolProp::input_pairs input_pair; std::vector output_parameters; std::vector v1, v2; - + try{ // Initialize the State class _PropsSI_initialize(backend, fluids, fractions, State); @@ -362,9 +373,9 @@ void _PropsSImulti(const std::vector &Outputs, } catch (std::exception &e){ // Input parameter parsing failed. Stop - throw ValueError(format("Input pair parsing failed for Name1: \"%s\", Name2: \"%s\"; err: %s", Name1.c_str(), Name2.c_str(), e.what())); + throw ValueError(format("Input pair parsing failed for Name1: \"%s\", Name2: \"%s\"; err: %s", Name1.c_str(), Name2.c_str(), e.what())); } - + try{ output_parameters = output_parameter::get_output_parameters(Outputs); } @@ -376,34 +387,34 @@ void _PropsSImulti(const std::vector &Outputs, // Calculate the output(s). In the case of a failure, all values will be filled with _HUGE _PropsSI_outputs(State, output_parameters, input_pair, v1, v2, IO); } - -std::vector > PropsSImulti(const std::vector &Outputs, - const std::string &Name1, + +std::vector > PropsSImulti(const std::vector &Outputs, + const std::string &Name1, const std::vector &Prop1, - const std::string &Name2, - const std::vector &Prop2, - const std::string &backend, - const std::vector &fluids, + const std::string &Name2, + const std::vector &Prop2, + const std::string &backend, + const std::vector &fluids, const std::vector &fractions) { std::vector > IO; - + #if !defined(NO_ERROR_CATCHING) try{ #endif - + // Call the subfunction that can bubble errors _PropsSImulti(Outputs, Name1, Prop1, Name2, Prop2, backend, fluids, fractions, IO); - + // Return the value(s) return IO; - + #if !defined(NO_ERROR_CATCHING) } catch(const std::exception& e){ - set_error_string(e.what()); + set_error_string(e.what()); #if defined (PROPSSI_ERROR_STDOUT) - std::cout << e.what() << std::endl; + std::cout << e.what() << std::endl; #endif if (get_debug_level() > 1){std::cout << e.what() << std::endl;} } @@ -418,10 +429,11 @@ double PropsSI(const std::string &Output, const std::string &Name1, double Prop1 #if !defined(NO_ERROR_CATCHING) try{ #endif - + // BEGIN OF TRY // Here is the real code that is inside the try block + extract_backend(Ref, backend, fluid); std::string fluid_string = fluid; if (has_fractions_in_string(fluid) || has_solution_concentration(fluid)){ @@ -431,49 +443,49 @@ double PropsSI(const std::string &Output, const std::string &Name1, double Prop1 _PropsSImulti(strsplit(Output,'&'), Name1, std::vector(1, Prop1), Name2, std::vector(1, Prop2), backend, strsplit(fluid_string, '&'), fractions, IO); if (IO.empty()){ throw ValueError(get_global_param_string("errstring").c_str()); } if (IO.size()!= 1 || IO[0].size() != 1){ throw ValueError(format("output should be 1x1; error was %s", get_global_param_string("errstring").c_str())); } - + double val = IO[0][0]; - + if (get_debug_level() > 1){ std::cout << format("_PropsSI will return %g",val) << std::endl; } return val; // END OF TRY #if !defined(NO_ERROR_CATCHING) } catch(const std::exception& e){ - set_error_string(e.what() + format(" : PropsSI(\"%s\",\"%s\",%0.10g,\"%s\",%0.10g,\"%s\")",Output.c_str(),Name1.c_str(), Prop1, Name2.c_str(), Prop2, Ref.c_str())); + set_error_string(e.what() + format(" : PropsSI(\"%s\",\"%s\",%0.10g,\"%s\",%0.10g,\"%s\")",Output.c_str(),Name1.c_str(), Prop1, Name2.c_str(), Prop2, Ref.c_str())); #if defined (PROPSSI_ERROR_STDOUT) - std::cout << e.what() << std::endl; + std::cout << e.what() << std::endl; #endif if (get_debug_level() > 1){std::cout << e.what() << std::endl;} - return _HUGE; + return _HUGE; } catch(...){ - return _HUGE; + return _HUGE; } #endif } #if defined(ENABLE_CATCH) TEST_CASE("Check inputs to PropsSI","[PropsSI]") { - SECTION("Single state, single output"){ + SECTION("Single state, single output"){ CHECK(ValidNumber(CoolProp::PropsSI("T","P",101325,"Q",0,"Water"))); }; - SECTION("Single state, single output, pure incompressible"){ + SECTION("Single state, single output, pure incompressible"){ CHECK(ValidNumber(CoolProp::PropsSI("D","P",101325,"T",300,"INCOMP::DowQ"))); }; - SECTION("Bad input pair"){ + SECTION("Bad input pair"){ CHECK(!ValidNumber(CoolProp::PropsSI("D","Q",0,"Q",0,"Water"))); }; - SECTION("Single state, single output, 40% incompressible"){ + SECTION("Single state, single output, 40% incompressible"){ CHECK(ValidNumber(CoolProp::PropsSI("D","P",101325,"T",300,"INCOMP::MEG[0.40]"))); }; - SECTION("Single state, single output, predefined CoolProp mixture"){ + SECTION("Single state, single output, predefined CoolProp mixture"){ CHECK(ValidNumber(CoolProp::PropsSI("T","Q",1,"P",3e6,"HEOS::R125[0.7]&R32[0.3]"))); }; - SECTION("Single state, single output"){ + SECTION("Single state, single output"){ CHECK(ValidNumber(CoolProp::PropsSI("T","P",101325,"Q",0,"HEOS::Water"))); }; - SECTION("Single state, single output, predefined mixture"){ + SECTION("Single state, single output, predefined mixture"){ CHECK(ValidNumber(CoolProp::PropsSI("T","P",101325,"Q",0,"R410A.mix"))); }; SECTION("Predefined mixture"){ @@ -586,7 +598,7 @@ double Props1SI(const std::string &FluidName, const std::string &Output) // They are backwards, swap std::swap(_Output, _FluidName); } - + // First input is the fluid, second input is the input parameter double val1 = PropsSI(_Output, "", 0, "", 0, _FluidName); if (!ValidNumber(val1)){ @@ -600,19 +612,19 @@ double Props1SI(const std::string &FluidName, const std::string &Output) #if defined(ENABLE_CATCH) TEST_CASE("Check inputs to Props1SI","[Props1SI],[PropsSI]") { - SECTION("Good fluid, good parameter"){ + SECTION("Good fluid, good parameter"){ CHECK(ValidNumber(CoolProp::Props1SI("Tcrit","Water"))); }; - SECTION("Good fluid, good parameter"){ + SECTION("Good fluid, good parameter"){ CHECK(ValidNumber(CoolProp::PropsSI("Tcrit","",0,"",0,"Water"))); }; - SECTION("Good fluid, good parameter, inverted"){ + SECTION("Good fluid, good parameter, inverted"){ CHECK(ValidNumber(CoolProp::Props1SI("Water","Tcrit"))); }; - SECTION("Good fluid, bad parameter"){ + SECTION("Good fluid, bad parameter"){ CHECK(!ValidNumber(CoolProp::Props1SI("Water","????????????"))); }; - SECTION("Bad fluid, good parameter"){ + SECTION("Bad fluid, good parameter"){ CHECK(!ValidNumber(CoolProp::Props1SI("?????","Tcrit"))); }; }; @@ -636,14 +648,14 @@ bool is_valid_fluid_string(std::string &input_fluid_string) } } double saturation_ancillary(const std::string &fluid_name, const std::string &output, int Q, const std::string &input, double value){ - + // Generate the state instance std::vector names(1, fluid_name); shared_ptr HEOS(new CoolProp::HelmholtzEOSMixtureBackend(names)); - + parameters iInput = get_parameter_index(input); parameters iOutput = get_parameter_index(output); - + return HEOS->saturation_ancillary(iOutput, Q, iInput, value); } void set_reference_stateS(std::string Ref, std::string reference_state) @@ -708,7 +720,7 @@ void set_reference_stateD(std::string Ref, double T, double rhomolar, double h0, shared_ptr HEOS; std::vector _comps(1, Ref); HEOS.reset(new CoolProp::HelmholtzEOSMixtureBackend(_comps)); - + HEOS->update(DmolarT_INPUTS, rhomolar, T); // Get current values for the enthalpy and entropy @@ -778,8 +790,8 @@ TEST_CASE("Check inputs to get_global_param_string","[get_global_param_string]") std::ostringstream ss3c; for (int i = 0; i INCOMP(new CoolProp::IncompressibleBackend(fluid)); - + if (!ParamName.compare("long_name")){ return INCOMP->calc_name(); } @@ -804,12 +816,12 @@ std::string get_fluid_param_string(std::string FluidName, std::string ParamName) catch(std::exception &e){ throw ValueError(format("CoolProp error: %s", e.what())); } catch(...){ throw ValueError("CoolProp error: Indeterminate error"); } } - + try{ std::vector comps(1, FluidName); shared_ptr HEOS(new CoolProp::HelmholtzEOSMixtureBackend(comps)); CoolProp::CoolPropFluid *fluid = HEOS->get_components()[0]; - + if (!ParamName.compare("aliases")){ return strjoin(fluid->aliases, ", "); } @@ -843,7 +855,7 @@ TEST_CASE("Check inputs to get_fluid_param_string", "[get_fluid_param_string]") std::ostringstream ss3c; for (int i = 0; i < num_good_inputs; ++i){ ss3c << "Test for" << good_inputs[i]; - SECTION(ss3c.str(), ""){ + SECTION(ss3c.str(), ""){ CHECK_NOTHROW(CoolProp::get_fluid_param_string("Water", good_inputs[i])); }; } @@ -885,7 +897,7 @@ std::string PhaseSI(const std::string &Name1, double Prop1, const std::string &N std::size_t Phase_int = static_cast(Phase_double); return phase_lookup_string(static_cast(Phase_int)); } - + /* std::string PhaseSI(const std::string &Name1, double Prop1, const std::string &Name2, double Prop2, const std::string &FluidName, const std::vector &z) {