8 #ifndef REFPROPMIXTUREBACKEND_H_ 9 #define REFPROPMIXTUREBACKEND_H_ 11 #include "AbstractState.h" 12 #include "DataStructures.h" 21 std::string cached_component_string;
25 bool _mole_fractions_set;
27 static std::size_t instance_counter;
28 static bool _REFPROP_supported;
29 std::vector<CoolPropDbl> mole_fractions_long_double;
30 std::vector<double> mole_fractions, mass_fractions;
31 std::vector<double> mole_fractions_liq, mole_fractions_vap;
51 void construct(
const std::vector<std::string>& fluid_names);
54 return get_backend_string(REFPROP_BACKEND_MIX);
58 static std::string version();
84 bool using_mole_fractions() {
87 bool using_mass_fractions() {
90 bool using_volu_fractions() {
101 if (this->Ncomp > 1) {
102 throw NotImplementedError(
"The REFPROP backend does not implement calc_phase function for mixtures.");
145 void check_loaded_fluid(
void);
177 return mole_fractions_long_double;
180 const std::vector<CoolPropDbl> calc_mass_fractions();
189 return PhaseEnvelope;
192 std::vector<CoolPropDbl> calc_mole_fractions_liquid(
void) {
193 return std::vector<CoolPropDbl>(mole_fractions_liq.begin(), mole_fractions_liq.begin() + this->Ncomp);
195 std::vector<CoolPropDbl> calc_mole_fractions_vapor(
void) {
196 return std::vector<CoolPropDbl>(mole_fractions_vap.begin(), mole_fractions_vap.begin() + this->Ncomp);
218 CoolPropDbl calc_melting_line(
int param,
int given, CoolPropDbl value);
220 double calc_melt_Tmax();
223 void calc_reducing_state(
void);
226 CoolPropDbl calc_p_min(
void) {
241 CoolPropDbl calc_saturated_vapor_keyed_output(
parameters key);
244 void calc_ideal_curve(
const std::string& type, std::vector<double>& T, std::vector<double>&
p);
333 bool force_load_REFPROP();
334 bool force_unload_REFPROP();
335 void REFPROP_SETREF(
char hrf[3],
int ixflag,
double x0[1],
double& h0,
double& s0,
double& T0,
double& p0,
int& ierr,
char herr[255],
int l1,
int l2);
double T(void)
Return the temperature in K.
Definition: AbstractState.h:1048
phases imposed_phase_index
If the phase is imposed, the imposed phase index.
Definition: AbstractState.h:84
CoolPropDbl calc_dBvirial_dT(void)
Calc the temperature derivative of the second virial coefficient.
Definition: REFPROPMixtureBackend.cpp:917
static bool REFPROP_supported(void)
Returns true if REFPROP is supported on this platform.
Definition: REFPROPMixtureBackend.cpp:199
double gas_constant(void)
Return the mole-fraction weighted gas constant in J/mol/K.
Definition: AbstractState.cpp:691
CoolPropDbl calc_Ttriple(void)
Using this backend, get the triple point temperature in K.
Definition: REFPROPMixtureBackend.cpp:820
void calc_ideal_curve(const std::string &type, std::vector< double > &T, std::vector< double > &p)
Calculate an ideal curve.
Definition: REFPROPMixtureBackend.cpp:2102
CoolPropDbl calc_molar_mass(void)
Using this backend, calculate the molar mass in kg/mol.
Definition: REFPROPMixtureBackend.cpp:905
double get_binary_interaction_double(const std::string &CAS1, const std::string &CAS2, const std::string ¶meter)
Get binary mixture double value.
Definition: REFPROPMixtureBackend.cpp:517
CoolPropDbl calc_d2alphar_dDelta2(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:273
CoolPropDbl calc_viscosity(void)
Get the viscosity [Pa-s] (based on the temperature and density in the state class) ...
Definition: REFPROPMixtureBackend.cpp:1010
CoolPropDbl calc_rhomolar_reducing(void)
Using this backend, get the reducing point molar density in mol/m^3.
Definition: REFPROPMixtureBackend.cpp:800
CoolPropDbl calc_p_triple(void)
Using this backend, get the triple point pressure in Pa.
Definition: REFPROPMixtureBackend.cpp:852
CoolPropDbl calc_dalphar_dDelta(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:265
CoolPropDbl calc_p_critical(void)
Using this backend, get the critical point pressure in Pa.
Definition: REFPROPMixtureBackend.cpp:766
CoolPropDbl calc_pmax(void)
Calculate the maximum pressure.
Definition: REFPROPMixtureBackend.cpp:740
CoolPropDbl calc_fugacity(std::size_t i)
Using this backend, calculate the fugacity in Pa.
Definition: REFPROPMixtureBackend.cpp:1062
void update(CoolProp::input_pairs, double value1, double value2)
Updating function for REFPROP.
Definition: REFPROPMixtureBackend.cpp:1227
CoolPropDbl calc_dalpha0_dTau(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:307
phases
These are constants for the phases of the fluid.
Definition: DataStructures.h:176
CoolPropDbl calc_d3alpha0_dDelta_dTau2(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:325
CoolPropDbl calc_T_critical(void)
Using this backend, get the critical point temperature in K.
Definition: REFPROPMixtureBackend.cpp:755
std::vector< std::string > calc_fluid_names()
Using this backend, get a vector of fluid names.
Definition: REFPROPMixtureBackend.h:60
void calc_specify_phase(phases phase_index)
Specify the phase - this phase will always be used in calculations.
Definition: REFPROPMixtureBackend.h:115
void set_binary_interaction_string(const std::size_t i, const std::size_t j, const std::string ¶meter, const std::string &value)
Set binary mixture string value.
Definition: REFPROPMixtureBackend.cpp:549
CoolPropDbl call_phixdll(int itau, int idelta)
Call the PHIXdll function in the dll.
Definition: REFPROPMixtureBackend.cpp:1976
void calc_unspecify_phase()
Unspecify the phase - the phase is no longer imposed, different solvers can do as they like...
Definition: REFPROPMixtureBackend.h:121
double Tmax(void)
Get the maximum temperature in K.
Definition: AbstractState.cpp:556
void construct(const std::vector< std::string > &fluid_names)
A function to actually do the initialization to allow it to be called in derived classes.
Definition: REFPROPMixtureBackend.cpp:167
CoolPropDbl calc_cpmolar_idealgas(void)
Using this backend, calculate the ideal gas molar constant-pressure specific heat in J/mol/K...
Definition: REFPROPMixtureBackend.cpp:1187
CoolPropDbl calc_Tmin(void)
Calculate the minimum temperature.
Definition: REFPROPMixtureBackend.cpp:750
CoolPropDbl calc_d2alpha0_dTau2(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:316
CoolPropDbl calc_conductivity(void)
Get the thermal conductivity [W/m/K] (based on the temperature and density in the state class) ...
Definition: REFPROPMixtureBackend.cpp:1026
CoolPropDbl calc_dalpha0_dDelta(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:304
The mother of all state classes.
Definition: AbstractState.h:78
CoolPropDbl calc_Cvirial(void)
Calc the C virial coefficient.
Definition: REFPROPMixtureBackend.cpp:922
CoolPropDbl calc_surface_tension(void)
Get the surface tension [N/m] (based on the temperature in the state class). Invalid for temperatures...
Definition: REFPROPMixtureBackend.cpp:1031
CoolPropDbl calc_d2alphar_dTau2(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:281
CoolPropDbl calc_gas_constant(void)
Using this backend, calculate the universal gas constant in J/mol/K.
Definition: REFPROPMixtureBackend.cpp:899
bool has_melting_line()
Return true if the fluid has a melting line - default is false, but can be re-implemented by derived ...
Definition: REFPROPMixtureBackend.cpp:966
void set_mass_fractions(const std::vector< CoolPropDbl > &mass_fractions)
Set the mass fractions.
Definition: REFPROPMixtureBackend.cpp:685
CoolPropDbl calc_d3alpha0_dTau3(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:328
A data structure to hold the data for a phase envelope.
Definition: PhaseEnvelope.h:36
void limits(double &Tmin, double &Tmax, double &rhomolarmax, double &pmax)
A wrapper function to calculate the limits for the EOS.
Definition: REFPROPMixtureBackend.cpp:709
CoolPropDbl calc_d3alpha0_dDelta2_dTau(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:322
CoolPropDbl calc_d3alphar_dDelta_dTau2(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:293
std::string calc_name()
Calculate the name of the fluid.
Definition: REFPROPMixtureBackend.h:95
CoolPropDbl calc_fugacity_coefficient(std::size_t i)
Using this backend, calculate the fugacity coefficient (dimensionless)
Definition: REFPROPMixtureBackend.cpp:1046
CoolPropDbl calc_d3alphar_dTau3(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:297
CoolPropDbl calc_compressibility_factor(void)
Using this backend, calculate the compressibility factor Z .
Definition: REFPROPMixtureBackend.h:184
void set_binary_interaction_double(const std::string &CAS1, const std::string &CAS2, const std::string ¶meter, const double value)
Set binary mixture floating point parameter.
Definition: REFPROPMixtureBackend.cpp:511
std::string fluid_param_string(const std::string &ParamName)
Return a string from the backend for the mixture/fluid - backend dependent - could be CAS #...
Definition: REFPROPMixtureBackend.cpp:455
input_pairs
These are input pairs that can be used for the update function (in each pair, input keys are sorted a...
Definition: DataStructures.h:274
void set_mole_fractions(const std::vector< CoolPropDbl > &mole_fractions)
Set the mole fractions.
Definition: REFPROPMixtureBackend.cpp:672
CoolPropDbl calc_Bvirial(void)
Calc the B virial coefficient.
Definition: REFPROPMixtureBackend.cpp:912
Definition: Exceptions.h:45
CoolPropDbl calc_acentric_factor(void)
Using this backend, calculate the acentric factor.
Definition: REFPROPMixtureBackend.cpp:806
CoolPropDbl calc_d2alpha0_dDelta2(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:310
CoolPropDbl calc_rhomolar_critical(void)
Using this backend, get the critical point molar density in mol/m^3.
Definition: REFPROPMixtureBackend.cpp:777
Definition: REFPROPMixtureBackend.h:18
std::vector< std::string > fluid_names(void)
Return a vector of strings of the fluid names that are in use.
Definition: AbstractState.cpp:173
double tau(void)
Return the reciprocal of the reduced temperature ( )
Definition: AbstractState.cpp:545
void calc_excess_properties()
Calculate excess properties.
Definition: REFPROPMixtureBackend.cpp:1995
CoolPropDbl calc_chemical_potential(std::size_t i)
Using this backend, calculate the chemical potential in J/mol.
Definition: REFPROPMixtureBackend.cpp:1077
CoolPropDbl calc_d3alphar_dDelta2_dTau(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:289
CoolPropDbl calc_d2alpha0_dDelta_dTau(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:313
const std::vector< CoolPropDbl > & get_mole_fractions()
Get the mole fractions of the fluid.
Definition: REFPROPMixtureBackend.h:176
CoolPropDbl calc_d3alphar_dDelta3(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:285
void calc_phase_envelope(const std::string &type)
Using this backend, construct the phase envelope, the variable type describes the type of phase envel...
Definition: REFPROPMixtureBackend.cpp:1093
double p(void)
Return the pressure in Pa.
Definition: AbstractState.h:1060
void update_with_guesses(CoolProp::input_pairs, double value1, double value2, const GuessesStructure &guesses)
Update the state, while providing guess values.
Definition: REFPROPMixtureBackend.cpp:1865
double Tmin(void)
Get the minimum temperature in K.
Definition: AbstractState.cpp:553
CoolPropDbl call_phi0dll(int itau, int idelta)
Call the PHI0dll function in the dll.
Definition: REFPROPMixtureBackend.cpp:1985
CoolPropDbl calc_alphar(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:261
phases _phase
The key for the phase from CoolProp::phases enum.
Definition: AbstractState.h:83
double _rhomolar
Bulk values.
Definition: AbstractState.h:108
CoolPropDbl calc_d2alphar_dDelta_dTau(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:277
This simple class holds the values for guesses for use in some solvers that have the ability to use g...
Definition: AbstractState.h:33
REFPROPMixtureBackend(const std::vector< std::string > &fluid_names)
The instantiator.
Definition: REFPROPMixtureBackend.h:46
std::string backend_name(void)
Get a string representation of the backend - for instance "HelmholtzEOSMixtureBackend" for the core m...
Definition: REFPROPMixtureBackend.h:53
CoolPropDbl calc_dipole_moment(void)
Using this backend, calculate the dipole moment in C-m (1 D = 3.33564e-30 C-m)
Definition: REFPROPMixtureBackend.cpp:869
std::string get_binary_interaction_string(const std::string &CAS1, const std::string &CAS2, const std::string ¶meter)
Get binary mixture string value.
Definition: REFPROPMixtureBackend.cpp:522
CoolPropDbl calc_d3alpha0_dDelta3(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:319
CoolPropDbl calc_saturated_liquid_keyed_output(parameters key)
Calculate the saturation properties.
Definition: REFPROPMixtureBackend.cpp:2065
CoolPropDbl calc_dalphar_dTau(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:269
CoolPropDbl calc_alpha0(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: REFPROPMixtureBackend.h:301
CoolPropDbl calc_Tmax(void)
Calculate the maximum temperature.
Definition: REFPROPMixtureBackend.cpp:745
phases calc_phase(void)
Using this backend, calculate the phase.
Definition: REFPROPMixtureBackend.h:100
void check_status()
Check if the mole fractions have been set, etc.
Definition: REFPROPMixtureBackend.cpp:703
This file contains flash routines in which the state is unknown, and a solver of some kind must be us...
Definition: AbstractState.h:19
CoolPropDbl calc_PIP(void)
Using this backend, calculate the phase identification parameter (PIP)
Definition: REFPROPMixtureBackend.cpp:995
parameters
Define some constants that will be used throughout These are constants for the input and output para...
Definition: DataStructures.h:64
double pmax(void)
Get the maximum pressure in Pa.
Definition: AbstractState.cpp:562
void calc_true_critical_point(double &T, double &rho)
Calculate the "true" critical point where dp/drho|T and d2p/drho2|T are zero.
Definition: REFPROPMixtureBackend.cpp:2037
void set_REFPROP_fluids(const std::vector< std::string > &fluid_names)
Set the fluids in REFPROP DLL by calling the SETUPdll function.
Definition: REFPROPMixtureBackend.cpp:282
CoolPropDbl calc_smolar_residual(void)
Calculate the residual entropy in J/mol/K (should be a uniquely negative quantity) ...
Definition: REFPROPMixtureBackend.h:256
CoolPropDbl calc_T_reducing(void)
Using this backend, get the reducing point temperature in K.
Definition: REFPROPMixtureBackend.cpp:794
int match_CAS(const std::string &CAS)
Find the index (1-based for FORTRAN) of the fluid with the given CAS number.
Definition: REFPROPMixtureBackend.cpp:497