Files
CoolProp/include/CoolPropFluid.h
Ian Bell 4542f9d093 Merge into release (#1057)
* Bump revision on msgpack-c

* Remove warnings when using Julia 0.4 realease

Some change in Julia 0.4 have occurred since the last update of this wrapper.
This update should now ensure better behaviour with Julia 0.4 which is now in release state.
https://raw.githubusercontent.com/JuliaLang/julia/0ff703b40afddf9b705bd6a06d3a59cb4c089ea5/NEWS.md

* Added PT flash for cubic EOS

* Added PQ and QT inputs for pure fluids with cubic backend

* Added derivation for relationship between saturation pressure and acentric factor

* Fixed T_critical and p_critical for pure fluids with cubic backends

* Bump revision for msgpack-c; everything should work now

* Correct get_parameter_information_string, fixes #974

Put the catch in a more useful way and solves the call to CoolProp::get_parameter_information.

* Relax convergence criterion for TS inputs; closes #956

* Update the updating of the TPD state class

* Fix initial delta value in critical point search routine

* Make CMake+Python integration work on OSX (finally)

* Fix some bugs with cubics and critical point evaluation

* Added conda builds again to please #905 and #956

* Added conda to the release cycle with directory cleaning. Should solve the problems discussed in #956, #905 and #707, but we have to wait for the next nightly build to see if it really works. Remember that the upload token on the server expires in June and uploads will fail silently.

* Added cppformat as external library, see #952 and #907. Does https://github.com/CoolProp/CoolProp/blob/master/dev/codelite/coolprop.project need updating?

* Add ability to get/set kij for cubics by overloading set/set_binary_interaction_double

* Pull in the correct include path for linking with other applications (PDSim, etc.)

* Don't package _JSON.h binary files when distributing CoolProp

* Fixed the docker docs

* Moved the binstar upload into a loop, if a single upload fails, we continue with the next one as mentioned in #905

* Update critical point evaluation routines and remove some double-calculations of critical matrices

* Move search radii into the cpp file

* Bump revision for Eigen to fix annoying warnings in MSVC9 2008

* Added info about Props1SI and other options to docs; closes #970

* Bump number of fluids

* Update CoolProp.jl

Other update due to `Julia 0.4` changes
+ added `CoolProp` functions

* Just a minor fix of the docker docs

* Also add the msgpack headers to CoolProp installation - more annoying than you would imagine...

* Break up tools headers into pieces that make more sense, allowing for potentially smaller binaries and faster compilation

* Fix some header issues

* Update DBL_EPSILON

* Fix _HUGE and accumulate errors

* Add missing fstream include

* One more try with header refactor

* Add header to get thread_local for ftw

* Added the cahced saturation densities to the keyed outputs for REFPROP and Helmholtz, see #977

* Add 'G' as alias for mass-based Gibbs energy

* Eliminated some more warnings regarding missing return values

* Fixed the white-space issues in the header files

* Add IWYU integration to main module; see #983

* Fix order of getting/setting parameters

* Fix order of parameter getting/setting for real this time

* For REFPROP, get/set BIP for mixture with indices

* Fix some edge cases in critical point calculation

* Switch back to the PDF generator for the fitting reports

* Massive improvements to stability of flash routines.  Nitrogen now has 0 failures.

* Added Syltherm800 for @adesideri

* Fixes #990 Javascript works again.

* Clarified the docs for #990

* Fix R123ze(E) reference; closes #992

* Some help with #986

* Added the generated cubic header to the ignore files

* Add example showing how to get REFPROP version

* Added two headers that might help with #995

* More sensible error message when using inappropriate version of REFPROP for phase envelope construction

* Add comment about MinGW generator for Android build

* Add example for calling DLL from C; closes #993

* Maybe this fixes multiple papers in the same category from #987

* Introducing limits for build logs to save disk space

* Clean up Android docs

* Kill min and max macros to close #995

* Bump REFPROP header file revision

* Small updates to docs

closes #996
closes #997

* Significant improvements to phase envelope construction

Thanks to the critical point evaluation routines

* Also add the configuration key

* Refactor phase envelope packaging with msgpack to remove external msgpack-c include

Also, don't package msgpack or rapidjson with CoolProp.  Doesn't seem necessary now

* Refine the phase envelopes in the liquid side based on difference in pressure

Closes #998

* Allow ability to adjust the fineness of the refinement of the phase envelope from the high-level

* Improvement in stability of refinement of phase envelopes

* Cubics library should use all uppercase names for matching

* Got QT inputs working for cubic mixtures

Also implemented the explicit solution for p from Wilson

* Progress with PQ inputs for cubics; some bugs remain still

* Still not obvious why SRK PQ fails.... Updated tests for derivatives of fugacity_coefficient

* Mostly a false alarm.  Seems PQ works ok, not at very low pressure though

* Implement 95% of the BIP setting/getting

See #1000

* Fix journal abbreviations; closes #999

* Update mixtures setting/getting BIP docs

* Where possible, remove include paths

Can't do so for Eigen.

closes #994

* Fix include for msgpack-c; see #994

* Fix path for IF97 in HumidAirProp.cpp

* Move error string into solver class; see #985

* Add docs for explicit solution for p from T for Wilson K-factor relationship

* Fix include paths for OSX; see #994

* First attempt at adding python 3.5 wheels; see #1002

* Upgrade cython as part of python build

* Fix typo in coolprop cp 3.5 build in buildbot

* Install cython into the appropriate environment this time

* Fix order of initialization for solver wrapper class

* Wrap all configuration variables into enumerations and a python module

* Added docs for new config strings

* Upgrade cython for sphinx builder

* Fix configuration sample in docs

* Fix constant in Chung method for estimation of e/k and sigma

* Added the Python 3.5 docs for #1002

* Added Python 3.5 to the Linux slaves, this won't work until CoolProp/Dockerfiles#1 is resolved

* Removed unused variables

* Better deal with inputs for tabular backends that are two-phase

* Fix stupid bug with tabular backends trying to evaluate pure_saturation tables when two-phase in first_partial_deriv

* Rename cubics schema file

* Cubics now are validated and new cubic fluids can be added

Lots of changes:
* Cubics are validated against schema
* Schema can be returned as string
* Added preliminary docs for cubics
* Cubic fluids can be added programmatically

* Add cair_sat to DLL/SO; closes #1005

* Add link to cubics page to main dos page

* Actually commit the docs for the cubic EOS this time.

* Fix Android docs formatting

* Add Ar alias for Argon; closes #1007

* Once more addressing #979 thanks to @shrx .

* I am constantly running out of disk space on the Windows machine.

* Add chemical potential as abstract state method

For example:

```
auto fluids = strsplit("Methane&Ethane", '&');
auto x = { 0.6,0.4 };

shared_ptr<CoolProp::AbstractState> RP(CoolProp::AbstractState::factory("HEOS", fluids));
RP->set_mole_fractions(x);
RP->update(PT_INPUTS, 101325, 300);
auto mu1 = RP->chemical_potential(0);

RP.reset(CoolProp::AbstractState::factory("REFPROP", fluids));
RP->set_mole_fractions(x);
RP->update(PT_INPUTS, 101325, 300);
auto mu2 = RP->chemical_potential(0);
```

* Abbreviate JCT properly

* Removed the cython upgrades to get more errors from the builders

* Update references; closes #1011

* Give access to dalphar_ddelta_consttau and dalphar_ddtau_constdelta in high-level api; closes #1010

* Implement stability analysis based on TPD analysis; partly working

* The Windows builder has been upgraded to 4 cores

* Typo in master.cfg

* It is more difficult than I though to have parallel builds

* Add ability to use GERG in REFPROP; closes #923

* Give access to alphar in high-level API; closes #1012

* Add a few more spaces

* And remove the condition on the additional spaces

* Allow beta to be outside (0,1) in stability analysis in first SS part

* Add REFPROP version output to the examples

* Fix typo in use of GERG in docs

* Secant behaves properly now when y1 approx. y2; closes #1015

* target_link_libraries

* clear molar mass in clear function; closes #1021

* Fix docs for tangent_plane_distance; closes #1019

* Typo in TPD fix; see #1019

* Make the gas constant an adjustable parameter and update to CODATA 2014 value

* Skip volume translation for cubics; closes #1018

* Fix typo in R_u update

* Fix copying of kij in cubic backend get_copy function

* Disable some optional checks in specialized low-level update functions

* Finish stability calculations for critical point calculations!

* Remove check of eigenvalues of L* matrix to determine stability (or not)

* Add access to h_Ice, s_Ice, etc. through HAProps_Aux; closes #1017

* Add script to do mingw static library building for python; closes #1016

* Use cmake to build sphinx docs on OSX

* Pad fluid string all the way to 10k characters

* Run R example with Rscript rather than R

* Fix call to Rscript

* Add Rscript to CMake test as well

* Update the Rscript calling stuff

* Fix Rscript calling in example_generator.py

* Fix typo in debugging printing for stability calcs

* Add some info to the Help section

* Describe how to make coolprop static library a clean cmake dependency; closes #1014

* Fix typo in CMake integration

* Fix call to Rscript in CMakeLists.txt?

* Another try with Rscript

* Yet another try with R

* Add new OSX slave for OSX 10.10+

* Try to fix the install path for OSX

* python static library builds should be release builds

* Another try with MATLAB on OSX 10.10

* Another attempt with MATLAB path

* Allow MATLAB tests to be disabled

* Add link to binaries for MATLAB for OSX 10.10; see #1013

* Add coefficients from JCED paper; closes #854

* Fix interaction parameters for new mixtures

* Fix docs for new BIP from JCED paper

* Fix REFPROP version for older version of REFPROP.

* Add updated docs for cubics (WIP)

* Small modifications to finish (?) critical point calculations

* Small bug fixes

* Guard against multiple definitions of "_CRT_SECURE_NO_WARNINGS" macro on Windows

* More macro definitions

* Refactor HMX.BNC path handling for REFPROP

Closes #1028
See #1023

* Add pass-throughs for testing derivatives; closes #1030

* Fix(?) issues with loading multiple predefined mixtures in REFPROP; see #1023

* Fix failures for PQ at triple-point pressure; closes #1009

* Switch python 3.5 windows builds to use vc14 cmake compiler; see #1002

* Remove static library linkage when building pythonn 3.5 wheels; see #1002

* Updates to docs for cubics and VLE tolerances

closes #1024
closes #1025

* Fixes STRING conflict between Mathcad library and cppformat

The Mathcad library header, mcadincl.h, defines a STRING constant.  This
should be MC_STRING, as STRING is too dangerous and conflicts with
STRING enumeration value in format.h from external/cppformat.

* Move a lot of mixture derivatives to the new formulation; see #1032

* First attempt at fixing logo size in cloud theme. See #1029

* Another try at resizing logo for firefox; see #1029

* a quick fix that might work with #1029

* forgot the match the aspect ratio, see #1029

* Disabled the conda builds again, closes #1033

* Removed scipy references or changed them to be imported locally, fixes #1036

* Circumvent Cython issues from #1039, not sure this is a fix

* Changed the string handling to tackle #979

* manylinux builds for 64-bit linux wheels are up-and-running

Run the ./build_images.sh script, builds docker image, and uses docker image to build the linux wheels

* Small logo instead of big one; see #1029

* Fixed #1040 thanks to the comments by @LORENZOTOCCI

* Pushing the new viscosities to the JSON files, getting ready for an intermediate nightly release

* Removed the conda builds from the docs, they are abandoned for now

* Make the logo smaller

* Disable the python linux builds in preparation of changeover to manylinux1 builds

* More changes for manylinux

* manylinux wheels fully working now

* Copy cppformat to the appropriate location

* Fix typo in OSX build flags

* Fixed Minor MSVC Compiler Warnings (#1041)

* Fixed Minor Warnings from MSVC

Minor type mis-matches, etc.

* Replace int(...) with static_cast<int>(...)

* First attempt at #1044

* Fix PT inputs along critical isobar and critical isotherm; closes #1034

* Add REFPROP version to REFPROP comparison script; closes #1026

* Added a number of new predefined mixtures; see #719

* Tidy up sphinx docs; closes #1029

* Moved more mixture derivatives tests to use new format; see #1032

* Fixed typo in fugacity wrapper function; see #1032

* Add acentric factor for Air; closes #1001

* Fixed units in RP1485 validation tables

* Disable image resizing

Could be done by setting DPI in savefig

* Copy PlatformDetermination.h into the top of CoolPropLib.h; see #946

* Try to resize the font a little bit in the sphinx output

* Mathcad Wrapper Updates for CoolProp 5.x and 6 (#1047)


Minor type mis-matches, etc.



* Update CMakeLists.txt for both Mathcad Prime and Mathad 15

Copied original MATHCAD module and modified for a PRIME module and a
MATHCAD15 module.

* Updated Mathcad Wrapper for version 5 & 6

Changes to CoolPropMathad.cpp:
* Uses PropsSI(), Props1SI(), and HAPropsSI()
* One source for both Prime and Mathcad 15
* Replaced Mathcad error #defines with enumerated values
* Replaced STRING const with MC_STRING enum
* Uses LP* and LPC* types from MCADINCL.h instead of * const
* Implemented get_global_param_string & get_fluid_param_string
* Cleaned up comments
GENERAL:
* Removed batch files (they don't work anymore)
* Updated README.rst in both directories with compile instruct.
* Removed cpp file from Prime directory (no longer needed)
* Removed MCADINCL headers (better to use from install directory)

* Fixed Typo on Props1SI function name

* Add function documentation XML file for Mathcad 15

Puts the functions in the Insert Function panel off the main menu of
Mathcad

* Modify Mathcad 15 README.rst

* Update Prime README.rst

* Update Prime README.rst (again)

* Fixed CmakeLists path and updated README files.

More robust CMake file and updated README info for clarity.

* Fixed RST syntax in README

* Update install commands for cmake, update doc index

* Commit the RST files for MathCAD15 and Prime

* Add MathCAD builders to buildbot

* Finished conversion of derivatives to new formulation; closes #1032

* Fix MathCAD build?

* Fix REFPROP comparison string

* Another try at MathCAD buildbot

* Add apply_simple_mixing_rule to AbstractState; fix bug with SatL and SatV and setting interaction parameters

closes #1048
closes #1049

* One more go for MathCAD+buildbot

* Touch the time-stamped file for expensive builds only after success

* Yet another try with MathCAD

* Align Tmax with REFPROP values (#1053)

* Remove non-operative gitignore rule.

This rule matches the /dev/fluids folder and all its
contents, but those were already in the repo, so the
rule is not in effect.

* Align Tmax with REFPROP values. Fixes #257.

I used the list given in #257.
DME, C12, Neon, SF6 values went down.
R11, R123, R152A had two occurences in EOS, I changed both.

* Added "set_reference_state" wrapper for Mathcad and Updated Example Worksheets (#1056)


- Added Mathcad wrapper for set_reference_stateS(), designated
set_reference_state in Mathcad.
- Added to the funcdoc interface (CoolProp_EN.xml)
- Tidy up some formatting in the README files

* Updated Mathcad 15 and Prime Example Sheets + PDFs of Each

@ibell I know we don't like binaries in the rep, but I feel these are
critical.  They are updates to the Mathcad worksheets that were already
there and PDF versions for anyone who doesn't have Mathcad (i.e.
@ibell).  The files are only about 250 KB each or 1MB total.  I don't
expect we'll need to add to them or add more.  We might consider how to
put these out with the DLL binaries as well.  They are the only
documentation on how to use the wrappers correctly.

* Fixed CMakeList.txt confict and modified M15 worksheet from .xmcd to .xmcdz (compressed file type)

* Install the smaller compressed worksheet for MathCAD 15; see #1056

* Add rho*sr scaling methodology for viscosity from Bell paper in Purdue conference

closes #816
closes #665

* Add reference to Purdue paper

* Prep for version 6 release

* Added contributors
2016-05-10 22:20:22 -06:00

506 lines
23 KiB
C++

/*
* CoolPropFluid.h
*
* Created on: 20 Dec 2013
* Author: jowr
*/
#ifndef COOLPROPFLUID_H_
#define COOLPROPFLUID_H_
#include "DataStructures.h"
#include "Helmholtz.h"
#include "Solvers.h"
#include <numeric>
#include <string>
#include <vector>
#include <map>
#include <cassert>
#include <iterator>
#include "Eigen/Core"
#include "PolyMath.h"
#include "Ancillaries.h"
namespace CoolProp {
struct BibTeXKeysStruct
{
std::string EOS,
CP0,
VISCOSITY,
CONDUCTIVITY,
ECS_LENNARD_JONES,
ECS_FITS,
SURFACE_TENSION;
};
struct EnvironmentalFactorsStruct
{
double GWP20, GWP100, GWP500, ODP, HH, PH, FH;
std::string ASHRAE34;
};
struct CriticalRegionSplines{
double T_min, T_max, rhomolar_min, rhomolar_max;
std::vector<double> cL, cV;
bool enabled;
CriticalRegionSplines() : T_min(_HUGE), T_max(_HUGE), rhomolar_min(_HUGE), rhomolar_max(_HUGE), enabled(false) {};
const void get_densities(double T, double rho_min, double rho_crit, double rho_max, double &rhoL, double &rhoV) const
{
int Nsoln = -1, Ngood = 0;
double rho1 =0, rho2 = 0, rho3 = 0;
// -----------
// Liquid part
// -----------
Ngood = 0;
solve_cubic(cL[0], cL[1], cL[2], cL[3]-T, Nsoln, rho1, rho2, rho3);
if (Nsoln == 1 && rho1 < rho_max && rho1 > rho_crit){
rhoL = rho1;
}
else{
if (rho1 < rho_max && rho1 > rho_crit){ Ngood++; rhoL = rho1; }
if (rho2 < rho_max && rho2 > rho_crit){ Ngood++; rhoL = rho2; }
if (Nsoln > 2 && rho3 < rho_max && rho3 > rho_crit){ Ngood++; rhoL = rho3; }
if (Ngood > 1){ throw ValueError(format("More than one liquid solution found for critical spline for T=%0.12g",T));};
if (Ngood < 1){ throw ValueError(format("No liquid solution found for critical spline for T=%0.12g",T));};
}
// ----------
// Vapor part
// ----------
Ngood = 0; Nsoln = 0;
solve_cubic(cV[0], cV[1], cV[2], cV[3]-T, Nsoln, rho1, rho2, rho3);
if (Nsoln == 1 && rho1 > rho_min && rho1 < rho_crit){
rhoV = rho1;
}
else{
if (rho1 > rho_min && rho1 < rho_crit){ Ngood++; rhoV = rho1; }
if (rho2 > rho_min && rho2 < rho_crit){ Ngood++; rhoV = rho2; }
if (Nsoln > 2 && rho3 > rho_min && rho3 < rho_crit){ Ngood++; rhoV = rho3; }
if (Ngood > 1){ throw ValueError(format("More than one vapor solution found for critical spline for T=%0.12g",T));};
if (Ngood < 1){ throw ValueError(format("No vapor solution found for critical spline for T=%0.12g",T));};
}
};
};
/// A set of limits for the eos parameters
struct EOSLimits
{
double Tmin, Tmax, rhomax, pmax;
};
struct ConductivityECSVariables{
std::string reference_fluid;
CoolPropDbl psi_rhomolar_reducing, f_int_T_reducing;
std::vector<CoolPropDbl> psi_a, psi_t, f_int_a, f_int_t;
};
struct ConductivityDiluteEta0AndPolyData{
std::vector<CoolPropDbl> A, t;
};
struct ConductivityDiluteRatioPolynomialsData{
CoolPropDbl T_reducing, p_reducing;
std::vector<CoolPropDbl> A, B, n, m;
};
struct ConductivityDiluteVariables
{
enum ConductivityDiluteEnum {CONDUCTIVITY_DILUTE_RATIO_POLYNOMIALS,
CONDUCTIVITY_DILUTE_ETA0_AND_POLY,
CONDUCTIVITY_DILUTE_CO2,
CONDUCTIVITY_DILUTE_ETHANE,
CONDUCTIVITY_DILUTE_NONE,
CONDUCTIVITY_DILUTE_NOT_SET
};
int type;
ConductivityDiluteRatioPolynomialsData ratio_polynomials;
ConductivityDiluteEta0AndPolyData eta0_and_poly;
ConductivityDiluteVariables(){type = CONDUCTIVITY_DILUTE_NOT_SET;}
};
struct ConductivityResidualPolynomialAndExponentialData{
CoolPropDbl T_reducing, rhomass_reducing;
std::vector<CoolPropDbl> A, t, d, gamma, l;
};
struct ConductivityResidualPolynomialData{
CoolPropDbl T_reducing, rhomass_reducing;
std::vector<CoolPropDbl> B, t, d;
};
struct ConductivityResidualVariables
{
enum ConductivityResidualEnum {CONDUCTIVITY_RESIDUAL_POLYNOMIAL,
CONDUCTIVITY_RESIDUAL_POLYNOMIAL_AND_EXPONENTIAL,
CONDUCTIVITY_RESIDUAL_R123,
CONDUCTIVITY_RESIDUAL_CO2,
CONDUCTIVITY_RESIDUAL_NOT_SET
};
int type;
ConductivityResidualPolynomialData polynomials;
ConductivityResidualPolynomialAndExponentialData polynomial_and_exponential;
ConductivityResidualVariables(){type = CONDUCTIVITY_RESIDUAL_NOT_SET;}
};
struct ConductivityCriticalSimplifiedOlchowySengersData{
CoolPropDbl k, R0, gamma, nu, GAMMA, zeta0, qD, T_reducing, p_reducing, T_ref;
ConductivityCriticalSimplifiedOlchowySengersData():
// Universal constants - can still be adjusted if need be
k(1.3806488e-23), //[J/K]
R0(1.03), //[-]
gamma(1.239), //[-]
nu(0.63), //[-]
// Suggested default values - can be over-written
GAMMA(0.0496), //[-]
zeta0(1.94e-10), //[m]
qD(2e9), //[m]
// Set to invalid number, can be provided in the JSON file
// T_ref default is 1.5*Tc
T_reducing(_HUGE),p_reducing(_HUGE),T_ref(_HUGE){}
};
struct ConductivityCriticalVariables
{
enum ConductivityResidualEnum {CONDUCTIVITY_CRITICAL_SIMPLIFIED_OLCHOWY_SENGERS,
CONDUCTIVITY_CRITICAL_R123,
CONDUCTIVITY_CRITICAL_AMMONIA,
CONDUCTIVITY_CRITICAL_NONE,
CONDUCTIVITY_CRITICAL_CARBONDIOXIDE_SCALABRIN_JPCRD_2006,
CONDUCTIVITY_CRITICAL_NOT_SET
};
int type;
ConductivityCriticalSimplifiedOlchowySengersData Olchowy_Sengers;
ConductivityCriticalVariables(){type = CONDUCTIVITY_CRITICAL_NOT_SET; }
};
/// Variables for the dilute gas part
struct ViscosityDiluteGasCollisionIntegralData
{
CoolPropDbl molar_mass, C;
std::vector<CoolPropDbl> a, t;
};
struct ViscosityDiluteCollisionIntegralPowersOfTstarData
{
CoolPropDbl T_reducing, ///< Reducing temperature [K[
C; ///< Leading constant
std::vector<CoolPropDbl> a, t;
};
struct ViscosityDiluteGasPowersOfT
{
std::vector<CoolPropDbl> a, t;
};
struct ViscosityDiluteGasPowersOfTr
{
std::vector<CoolPropDbl> a, t;
CoolPropDbl T_reducing;
};
struct ViscosityDiluteVariables
{
enum ViscosityDiluteType {VISCOSITY_DILUTE_COLLISION_INTEGRAL, ///< Use \ref TransportRoutines::viscosity_dilute_collision_integral
VISCOSITY_DILUTE_COLLISION_INTEGRAL_POWERS_OF_TSTAR, ///< Use \ref TransportRoutines::viscosity_dilute_collision_integral_powers_of_T
VISCOSITY_DILUTE_KINETIC_THEORY, ///< Use \ref TransportRoutines::viscosity_dilute_kinetic_theory
VISCOSITY_DILUTE_ETHANE, ///< Use \ref TransportRoutines::viscosity_dilute_ethane
VISCOSITY_DILUTE_CYCLOHEXANE, ///< Use \ref TransportRoutines::viscosity_dilute_cyclohexane
VISCOSITY_DILUTE_POWERS_OF_T, ///< Use \ref TransportRoutines::viscosity_dilute_powers_of_T
VISCOSITY_DILUTE_POWERS_OF_TR, ///< Use \ref TransportRoutines::viscosity_dilute_powers_of_Tr
VISCOSITY_DILUTE_NOT_SET
};
ViscosityDiluteType type;
ViscosityDiluteGasCollisionIntegralData collision_integral; ///< Data for \ref TransportRoutines::viscosity_dilute_collision_integral
ViscosityDiluteCollisionIntegralPowersOfTstarData collision_integral_powers_of_Tstar; ///< Data for \ref TransportRoutines::viscosity_dilute_collision_integral_powers_of_T
ViscosityDiluteGasPowersOfT powers_of_T; ///< Data for \ref TransportRoutines::viscosity_dilute_powers_of_T
ViscosityDiluteGasPowersOfTr powers_of_Tr; ///< Data for \ref TransportRoutines::viscosity_dilute_powers_of_Tr
ViscosityDiluteVariables(){type = VISCOSITY_DILUTE_NOT_SET;}
};
struct ViscosityRainWaterFriendData
{
std::vector<CoolPropDbl> b, t;
};
struct ViscosityInitialDensityEmpiricalData
{
std::vector<CoolPropDbl> n, d, t;
CoolPropDbl T_reducing, rhomolar_reducing;
};
struct ViscosityInitialDensityVariables
{
enum ViscosityInitialDensityEnum {VISCOSITY_INITIAL_DENSITY_RAINWATER_FRIEND, ///< Use \ref TransportRoutines::viscosity_initial_density_dependence_Rainwater_Friend
VISCOSITY_INITIAL_DENSITY_EMPIRICAL, ///< Use \ref TransportRoutines::viscosity_initial_density_dependence_empirical
VISCOSITY_INITIAL_DENSITY_NOT_SET
};
ViscosityInitialDensityEnum type;
ViscosityRainWaterFriendData rainwater_friend; ///< Data for \ref TransportRoutines::viscosity_initial_density_dependence_Rainwater_Friend
ViscosityInitialDensityEmpiricalData empirical; ///< Data for \ref TransportRoutines::viscosity_initial_density_dependence_empirical
ViscosityInitialDensityVariables(){type = VISCOSITY_INITIAL_DENSITY_NOT_SET;}
};
struct ViscosityModifiedBatschinskiHildebrandData
{
std::vector<CoolPropDbl> a,d1,d2,t1,t2,f,g,h,p,q,gamma, l;
CoolPropDbl T_reduce, rhomolar_reduce;
};
struct ViscosityFrictionTheoryData
{
std::vector<CoolPropDbl> Aa, Aaa, Aaaa, Ar, Arr, Adrdr, Arrr, Ai, Aii, AdrAdr;
int Na, Naa, Naaa, Nr, Nrr, Nrrr, Nii;
CoolPropDbl c1, c2, T_reduce, rhomolar_reduce;
};
struct ViscosityHigherOrderVariables
{
enum ViscosityHigherOrderEnum {VISCOSITY_HIGHER_ORDER_BATSCHINKI_HILDEBRAND, ///< Use \ref TransportRoutines::viscosity_higher_order_modified_Batschinski_Hildebrand
VISCOSITY_HIGHER_ORDER_HYDROGEN, ///< Use \ref TransportRoutines::viscosity_hydrogen_higher_order_hardcoded
VISCOSITY_HIGHER_ORDER_HEXANE, ///< Use \ref TransportRoutines::viscosity_hexane_higher_order_hardcoded
VISCOSITY_HIGHER_ORDER_HEPTANE, ///< Use \ref TransportRoutines::viscosity_heptane_higher_order_hardcoded
VISCOSITY_HIGHER_ORDER_ETHANE, ///< Use \ref TransportRoutines::viscosity_ethane_higher_order_hardcoded
VISCOSITY_HIGHER_ORDER_BENZENE, ///< Use \ref TransportRoutines::viscosity_benzene_higher_order_hardcoded
VISCOSITY_HIGHER_ORDER_TOLUENE, ///< Use \ref TransportRoutines::viscosity_toluene_higher_order_hardcoded
VISCOSITY_HIGHER_ORDER_FRICTION_THEORY, ///< Use \ref TransportRoutines::viscosity_higher_order_friction_theory
VISCOSITY_HIGHER_ORDER_NOT_SET
};
ViscosityHigherOrderEnum type;
ViscosityModifiedBatschinskiHildebrandData modified_Batschinski_Hildebrand; ///< Data for \ref TransportRoutines::viscosity_higher_order_modified_Batschinski_Hildebrand
ViscosityFrictionTheoryData friction_theory; ///< Data for \ref TransportRoutines::viscosity_higher_order_friction_theory
ViscosityHigherOrderVariables(){type = VISCOSITY_HIGHER_ORDER_NOT_SET;};
};
struct ViscosityRhoSrVariables{
std::vector<double> c_liq, c_vap;
double C, x_crossover, rhosr_critical;
};
struct ViscosityECSVariables{
std::string reference_fluid;
CoolPropDbl psi_rhomolar_reducing;
std::vector<CoolPropDbl> psi_a, psi_t;
};
struct ViscosityChungData{
CoolPropDbl rhomolar_critical, acentric, T_critical, molar_mass, dipole_moment_D;
};
class TransportPropertyData
{
public:
enum ViscosityHardcodedEnum {VISCOSITY_HARDCODED_WATER, ///< Use \ref TransportRoutines::viscosity_water_hardcoded
VISCOSITY_HARDCODED_HEAVYWATER, ///< Use \ref TransportRoutines::viscosity_heavywater_hardcoded
VISCOSITY_HARDCODED_HELIUM, ///< Use \ref TransportRoutines::viscosity_helium_hardcoded
VISCOSITY_HARDCODED_R23, ///< Use \ref TransportRoutines::viscosity_R23_hardcoded
VISCOSITY_HARDCODED_METHANOL, ///< Use \ref TransportRoutines::viscosity_methanol_hardcoded
VISCOSITY_NOT_HARDCODED
};
enum ConductivityHardcodedEnum {
CONDUCTIVITY_HARDCODED_WATER, ///< Use \ref TransportRoutines::conductivity_hardcoded_water
CONDUCTIVITY_HARDCODED_HEAVYWATER, ///< Use \ref TransportRoutines::conductivity_hardcoded_heavywater
CONDUCTIVITY_HARDCODED_R23, ///< Use \ref TransportRoutines::conductivity_hardcoded_R23
CONDUCTIVITY_HARDCODED_HELIUM, ///< Use \ref TransportRoutines::conductivity_hardcoded_helium
CONDUCTIVITY_HARDCODED_METHANE, ///< Use \ref TransportRoutines::conductivity_hardcoded_methane
CONDUCTIVITY_NOT_HARDCODED
};
ViscosityDiluteVariables viscosity_dilute;
ViscosityInitialDensityVariables viscosity_initial;
ViscosityHigherOrderVariables viscosity_higher_order;
ViscosityECSVariables viscosity_ecs;
ViscosityRhoSrVariables viscosity_rhosr;
ViscosityChungData viscosity_Chung;
ConductivityDiluteVariables conductivity_dilute;
ConductivityResidualVariables conductivity_residual;
ConductivityCriticalVariables conductivity_critical;
ConductivityECSVariables conductivity_ecs;
std::string BibTeX_viscosity, ///< The BibTeX key for the viscosity model
BibTeX_conductivity; ///< The BibTeX key for the conductivity model
bool viscosity_using_ECS; ///< A flag for whether to use extended corresponding states for viscosity. False for no
bool conductivity_using_ECS; ///< A flag for whether to use extended corresponding states for conductivity. False for no
bool viscosity_using_Chung; ///< A flag for whether to use Chung model. False for no
bool viscosity_using_rhosr; ///< A flag for whether to use rho*sr CS model of Bell. False for no
bool viscosity_model_provided; ///< A flag for whether viscosity model is provided. False for no
bool conductivity_model_provided; ///< A flag for whether thermal conductivity model is provided. False for no
CoolPropDbl sigma_eta, ///< The Lennard-Jones 12-6 \f$ \sigma \f$ parameter
epsilon_over_k; ///< The Lennard-Jones 12-6 \f$ \varepsilon/k \f$ parameter
ViscosityHardcodedEnum hardcoded_viscosity; ///< Hardcoded flags for the viscosity
ConductivityHardcodedEnum hardcoded_conductivity; ///< Hardcoded flags for the conductivity
TransportPropertyData():viscosity_using_ECS(false),
conductivity_using_ECS(false),
viscosity_using_Chung(false),
viscosity_using_rhosr(false),
viscosity_model_provided(false),
conductivity_model_provided(false),
sigma_eta(_HUGE),epsilon_over_k(_HUGE),
hardcoded_viscosity(VISCOSITY_NOT_HARDCODED),
hardcoded_conductivity(CONDUCTIVITY_NOT_HARDCODED){}
};
struct Ancillaries
{
SaturationAncillaryFunction pL, pV, rhoL, rhoV, hL, hLV, sL, sLV;
MeltingLineVariables melting_line;
SurfaceTensionCorrelation surface_tension;
};
/// The core class for an equation of state
/**
This class holds the absolute minimum information to evaluate the equation
of state. This includes the reducing state, limits on the equation of state,
the coefficients for the Helmholtz derivative terms.
It does NOT include derived parameters like specific heat, enthalpy, etc.
*/
class EquationOfState{
public:
EquationOfState(){};
~EquationOfState(){};
SimpleState reduce, ///< Reducing state used for the EOS (usually, but not always, the critical point)
sat_min_liquid, ///< The saturated liquid state at the minimum saturation temperature
sat_min_vapor, ///< The saturated vapor state at the minimum saturation temperature
hs_anchor, ///< A fixed anchor state at Tc*1.1 and rhoc*0.9 used as a reference state for enthalpy and entropy ancillary curves
max_sat_T, ///< The state at the maximum saturation temperature for pseudo-pure
max_sat_p; ///< The state at the maximum saturation pressure for pseudo-pure
EOSLimits limits; ///< Limits on the EOS
double R_u, ///< The universal gas constant used for this EOS (usually, but not always, 8.314472 J/mol/K)
molar_mass, ///< The molar mass in kg/mol (note NOT kg/kmol)
acentric, ///< The acentric factor \f$ \omega = -log_{10}\left(\frac{p_s(T/T_c=0.7)}{p_c}\right)-1\f$
Ttriple, ///< Triple point temperature (K)
ptriple; ///< Triple point pressure (Pa)
bool pseudo_pure; ///< Is a pseudo-pure fluid (true) or pure fluid (false)
ResidualHelmholtzContainer alphar; ///< The residual Helmholtz energy
IdealHelmholtzContainer alpha0; ///< The ideal Helmholtz energy
std::string BibTeX_EOS, ///< The bibtex key for the equation of state
BibTeX_CP0; ///< The bibtex key for the ideal gas specific heat correlation
CriticalRegionSplines critical_region_splines; ///< A cubic spline in the form T = f(rho) for saturated liquid and saturated vapor curves in the near-critical region
/// Validate the EOS that was just constructed
void validate()
{
assert(R_u < 9 && R_u > 8);
assert(molar_mass > 0.001 && molar_mass < 1);
};
CoolPropDbl baser(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alphar.base(tau, delta);
};
// First partials
CoolPropDbl dalphar_dDelta(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alphar.dDelta(tau, delta);
};
CoolPropDbl dalphar_dTau(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alphar.dTau(tau, delta);
};
// Second partials
CoolPropDbl d2alphar_dDelta2(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alphar.dDelta2(tau, delta);
};
CoolPropDbl d2alphar_dDelta_dTau(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alphar.dDelta_dTau(tau, delta);
};
CoolPropDbl d2alphar_dTau2(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alphar.dTau2(tau, delta);
};
// Third partials
CoolPropDbl d3alphar_dDelta3(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alphar.dDelta3(tau, delta);
};
CoolPropDbl d3alphar_dDelta2_dTau(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alphar.dDelta2_dTau(tau, delta);
};
CoolPropDbl d3alphar_dDelta_dTau2(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alphar.dDelta_dTau2(tau, delta);
};
CoolPropDbl d3alphar_dTau3(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alphar.dTau3(tau, delta);
};
CoolPropDbl base0(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alpha0.base(tau, delta);
};
// First partials
CoolPropDbl dalpha0_dDelta(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alpha0.dDelta(tau, delta);
};
CoolPropDbl dalpha0_dTau(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alpha0.dTau(tau, delta);
};
// Second partials
CoolPropDbl d2alpha0_dDelta2(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alpha0.dDelta2(tau, delta);
};
CoolPropDbl d2alpha0_dDelta_dTau(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alpha0.dDelta_dTau(tau, delta);
};
CoolPropDbl d2alpha0_dTau2(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alpha0.dTau2(tau, delta);
};
// Third partials
CoolPropDbl d3alpha0_dDelta3(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alpha0.dDelta3(tau, delta);
};
CoolPropDbl d3alpha0_dDelta2_dTau(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alpha0.dDelta2_dTau(tau, delta);
};
CoolPropDbl d3alpha0_dDelta_dTau2(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alpha0.dDelta_dTau2(tau, delta);
};
CoolPropDbl d3alpha0_dTau3(const CoolPropDbl &tau, const CoolPropDbl &delta)
{
return alpha0.dTau3(tau, delta);
};
};
/// A thermophysical property provider for critical and reducing values as well as derivatives of Helmholtz energy
/**
This fluid instance is populated using an entry from a JSON file
*/
class CoolPropFluid {
protected:
// Transport property data
std::string ECSReferenceFluid; ///< A string that gives the name of the fluids that should be used for the ECS method for transport properties
double ECS_qd; ///< The critical qd parameter for the Olchowy-Sengers cross-over term
public:
CoolPropFluid():ECS_qd(-_HUGE){};
~CoolPropFluid(){};
const EquationOfState &EOS() const {return EOSVector[0];} ///< Get a reference to the equation of state
EquationOfState &EOS() {return EOSVector[0];} ///< Get a reference to the equation of state
std::vector<EquationOfState> EOSVector; ///< The equations of state that could be used for this fluid
std::string name; ///< The name of the fluid
std::string REFPROPname; ///< The REFPROP-compliant name if REFPROP-"name" is not a compatible fluid name. If not included, "name" is assumed to be a valid name for REFPROP
std::string CAS; ///< The CAS number of the fluid
std::string formula; ///< The chemical formula, in LaTeX form
std::vector <std::string> aliases; ///< A vector of aliases of names for the fluid
BibTeXKeysStruct BibTeXKeys; ///< The BibTeX keys associated
EnvironmentalFactorsStruct environment; ///< The environmental variables for global warming potential, ODP, etc.
Ancillaries ancillaries; ///< The set of ancillary equations for dewpoint, bubblepoint, surface tension, etc.
TransportPropertyData transport;
SimpleState crit, ///< The state at the critical point
triple_liquid, ///< The saturated liquid state at the triple point temperature
triple_vapor; ///< The saturated vapor state at the triple point temperature
double gas_constant(){ return EOS().R_u; };
double molar_mass(){ return EOS().molar_mass; };
};
} /* namespace CoolProp */
#endif /* COOLPROPFLUID_H_ */