CoolProp 8.0.0
An open-source fluid property and humid air property database
Classes | Static Public Member Functions | List of all members
CoolProp::FlashRoutines Class Reference

Detailed Description

This class is a friend class of HelmholtzEOSMixtureBackend, therefore the static methods contained in it have access to the private and protected variables in the HelmholtzEOSMixtureBackend instance.

In this way the Flash routines can be kept in their own separate file and not pollute the HelmholtzEOSMixtureBackend namespace

Definition at line 29 of file FlashRoutines.h.

#include <FlashRoutines.h>

Classes

struct  HS_flash_singlephaseOptions
 
struct  HS_flash_twophaseOptions
 

Static Public Member Functions

template<class T >
static T g_RachfordRice (const std::vector< T > &z, const std::vector< T > &lnK, T beta)
 
template<class T >
static T dgdbeta_RachfordRice (const std::vector< T > &z, const std::vector< T > &lnK, T beta)
 
static void PQ_flash (HelmholtzEOSMixtureBackend &HEOS)
 
static void PQ_flash_with_guesses (HelmholtzEOSMixtureBackend &HEOS, const GuessesStructure &guess)
 
static void QT_flash_with_guesses (HelmholtzEOSMixtureBackend &HEOS, const GuessesStructure &guess)
 
static void PT_flash_with_guesses (HelmholtzEOSMixtureBackend &HEOS, const GuessesStructure &guess)
 
static void QT_flash (HelmholtzEOSMixtureBackend &HEOS)
 
static void QS_flash (HelmholtzEOSMixtureBackend &HEOS)
 
static void DQ_flash (HelmholtzEOSMixtureBackend &HEOS)
 
static void DQ_flash_with_guesses (HelmholtzEOSMixtureBackend &HEOS, const GuessesStructure &guess)
 
static void HQ_flash (HelmholtzEOSMixtureBackend &HEOS, CoolPropDbl Tguess=-1)
 
static void HQ_flash_with_guesses (HelmholtzEOSMixtureBackend &HEOS, const GuessesStructure &guess)
 
static void QS_flash_with_guesses (HelmholtzEOSMixtureBackend &HEOS, const GuessesStructure &guess)
 
static double resolve_T_via_superancillary (HelmholtzEOSMixtureBackend &HEOS, parameters key, double target_value, std::optional< double > guess_T, const char *fn_name)
 
static bool sat_superanc_path_applies (HelmholtzEOSMixtureBackend &HEOS)
 
static std::pair< double, double > alpha0_offset_total (HelmholtzEOSMixtureBackend &HEOS)
 
static void PT_Q_flash_mixtures (HelmholtzEOSMixtureBackend &HEOS, parameters other, CoolPropDbl value)
 
static void PT_flash (HelmholtzEOSMixtureBackend &HEOS)
 
static void PT_flash_mixtures (HelmholtzEOSMixtureBackend &HEOS)
 
static double T_DP_PengRobinson (HelmholtzEOSMixtureBackend &HEOS, double rhomolar, double p)
 Use Peng-Robinson to get guess for temperature for given density and pressure. More...
 
static void DP_flash (HelmholtzEOSMixtureBackend &HEOS)
 
static void solver_for_rho_given_T_oneof_HSU (HelmholtzEOSMixtureBackend &HEOS, CoolPropDbl T, CoolPropDbl value, parameters other)
 
static void DHSU_T_flash (HelmholtzEOSMixtureBackend &HEOS, parameters other)
 
static void HSU_P_flash (HelmholtzEOSMixtureBackend &HEOS, parameters other)
 
static void HSU_P_flash_singlephase_Newton (HelmholtzEOSMixtureBackend &HEOS, parameters other, CoolPropDbl T0, CoolPropDbl rhomolar0)
 
static void HSU_P_flash_singlephase_Brent (HelmholtzEOSMixtureBackend &HEOS, parameters other, CoolPropDbl value, CoolPropDbl Tmin, CoolPropDbl Tmax, phases phase)
 
static void HSU_D_flash_twophase (HelmholtzEOSMixtureBackend &HEOS, CoolPropDbl rhomolar_spec, parameters other, CoolPropDbl value)
 
static void HSU_D_flash (HelmholtzEOSMixtureBackend &HEOS, parameters other)
 
static void HS_flash (HelmholtzEOSMixtureBackend &HEOS)
 
static void HS_flash_generate_TP_singlephase_guess (HelmholtzEOSMixtureBackend &HEOS, double &T, double &p)
 
static void HS_flash_singlephase (HelmholtzEOSMixtureBackend &HEOS, CoolPropDbl hmolar_spec, CoolPropDbl smolar_spec, HS_flash_singlephaseOptions &options)
 
static void HS_flash_twophase (HelmholtzEOSMixtureBackend &HEOS, CoolPropDbl hmolar_spec, CoolPropDbl smolar_spec, HS_flash_twophaseOptions &options)
 
static bool hs_corrector_probe (HelmholtzEOSMixtureBackend &H, double T0, double rho0, double h_t, double s_t, double &T_out, double &rho_out, double Tlo_override)
 Test-only: invoke the internal HS corrector with an explicit Tlo floor. More...
 

Member Function Documentation

◆ alpha0_offset_total()

std::pair< double, double > CoolProp::FlashRoutines::alpha0_offset_total ( HelmholtzEOSMixtureBackend HEOS)
static

Compute the total (a1, a2) IdealHelmholtzEnthalpyEntropyOffset contribution for a HEOS, summing both the parse-time-immutable EnthalpyEntropyOffsetCore and the user-mutable EnthalpyEntropyOffset and applying the alpha0 prefactor. This is the value that goes into the SuperAncillary stamp and into the shift formula (Δh = R·T_red·Δa2, Δs = −R·Δa1) used to translate user-frame target values into the cache's frame at query time. See #2773. Returns (a1_total, a2_total) as a pair.

Definition at line 542 of file FlashRoutines.cpp.

◆ dgdbeta_RachfordRice()

template<class T >
static T CoolProp::FlashRoutines::dgdbeta_RachfordRice ( const std::vector< T > &  z,
const std::vector< T > &  lnK,
beta 
)
inlinestatic

Definition at line 43 of file FlashRoutines.h.

◆ DHSU_T_flash()

void CoolProp::FlashRoutines::DHSU_T_flash ( HelmholtzEOSMixtureBackend HEOS,
parameters  other 
)
static

A generic flash routine for the pairs (T,D), (T,H), (T,S), and (T,U). Similar analysis is needed

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used
otherThe index for the other input from CoolProp::parameters; allowed values are iDmolar, iHmolar, iSmolar, iUmolar

Definition at line 3802 of file FlashRoutines.cpp.

◆ DP_flash()

void CoolProp::FlashRoutines::DP_flash ( HelmholtzEOSMixtureBackend HEOS)
static

Flash for given density and pressure

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used

Definition at line 409 of file FlashRoutines.cpp.

◆ DQ_flash()

void CoolProp::FlashRoutines::DQ_flash ( HelmholtzEOSMixtureBackend HEOS)
static

Flash for given molar density and (molar) quality

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used

Definition at line 566 of file FlashRoutines.cpp.

◆ DQ_flash_with_guesses()

void CoolProp::FlashRoutines::DQ_flash_with_guesses ( HelmholtzEOSMixtureBackend HEOS,
const GuessesStructure guess 
)
static

Flash for given molar density and (molar) quality with a temperature guess used to disambiguate multiple roots on the saturation curve (see GitHub #2773). Uses the rho_sat superancillary's monotonic-interval partition: guess.T selects the sub-interval whose temperature range contains it, and TOMS748 finds the unique root inside that sub-interval.

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used
guessThe GuessesStructure; only guess.T is consulted

Definition at line 847 of file FlashRoutines.cpp.

◆ g_RachfordRice()

template<class T >
static T CoolProp::FlashRoutines::g_RachfordRice ( const std::vector< T > &  z,
const std::vector< T > &  lnK,
beta 
)
inlinestatic

Definition at line 33 of file FlashRoutines.h.

◆ HQ_flash()

void CoolProp::FlashRoutines::HQ_flash ( HelmholtzEOSMixtureBackend HEOS,
CoolPropDbl  Tguess = -1 
)
static

Flash for given molar enthalpy and (molar) quality

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used
Tguess(optional) The guess temperature in K to start from, ignored if < 0

Definition at line 604 of file FlashRoutines.cpp.

◆ HQ_flash_with_guesses()

void CoolProp::FlashRoutines::HQ_flash_with_guesses ( HelmholtzEOSMixtureBackend HEOS,
const GuessesStructure guess 
)
static

Flash for given molar enthalpy and (molar) quality with a temperature guess used to disambiguate multiple roots (see GitHub #2773). Lazily builds the h_sat superancillary on first use, enumerates candidate T-roots via TOMS748 inside each provably-monotonic Chebyshev sub-interval, picks the one closest to guess.T, then refreshes the state with a QT flash at that T.

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used
guessThe GuessesStructure; only guess.T is consulted

Definition at line 865 of file FlashRoutines.cpp.

◆ hs_corrector_probe()

bool CoolProp::FlashRoutines::hs_corrector_probe ( HelmholtzEOSMixtureBackend H,
double  T0,
double  rho0,
double  h_t,
double  s_t,
double &  T_out,
double &  rho_out,
double  Tlo_override 
)
static

Test-only: invoke the internal HS corrector with an explicit Tlo floor.

Definition at line 4811 of file FlashRoutines.cpp.

◆ HS_flash()

void CoolProp::FlashRoutines::HS_flash ( HelmholtzEOSMixtureBackend HEOS)
static

A flash routine for (H,S)

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used

Definition at line 4817 of file FlashRoutines.cpp.

◆ HS_flash_generate_TP_singlephase_guess()

void CoolProp::FlashRoutines::HS_flash_generate_TP_singlephase_guess ( HelmholtzEOSMixtureBackend HEOS,
double &  T,
double &  p 
)
static

Randomly generate a single phase set of inputs for T and p - searches entire single-phase region

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used
TThe temperature in K
pThe pressure in Pa

Definition at line 4292 of file FlashRoutines.cpp.

◆ HS_flash_singlephase()

void CoolProp::FlashRoutines::HS_flash_singlephase ( HelmholtzEOSMixtureBackend HEOS,
CoolPropDbl  hmolar_spec,
CoolPropDbl  smolar_spec,
HS_flash_singlephaseOptions options 
)
static

Definition at line 4239 of file FlashRoutines.cpp.

◆ HS_flash_twophase()

void CoolProp::FlashRoutines::HS_flash_twophase ( HelmholtzEOSMixtureBackend HEOS,
CoolPropDbl  hmolar_spec,
CoolPropDbl  smolar_spec,
HS_flash_twophaseOptions options 
)
static

Definition at line 4205 of file FlashRoutines.cpp.

◆ HSU_D_flash()

void CoolProp::FlashRoutines::HSU_D_flash ( HelmholtzEOSMixtureBackend HEOS,
parameters  other 
)
static

A generic flash routine for the pairs (D,P), (D,H), (D,S), and (D,U). Similar analysis is needed

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used
otherThe index for the other input from CoolProp::parameters; allowed values are iP, iHmolar, iSmolar, iUmolar

Something homogeneous to avoid flash calls

TODO: separate TL and TV for ppure

Definition at line 1710 of file FlashRoutines.cpp.

◆ HSU_D_flash_twophase()

void CoolProp::FlashRoutines::HSU_D_flash_twophase ( HelmholtzEOSMixtureBackend HEOS,
CoolPropDbl  rhomolar_spec,
parameters  other,
CoolPropDbl  value 
)
static

A generic flash routine for the pairs (D,H), (D,S), and (D,U) for twophase state. Similar analysis is needed

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used
rhomolar_specThe specified molar density [mol/m^3]
otherThe index for the other input from CoolProp::parameters; allowed values are iP, iHmolar, iSmolar, iUmolar
valueThe value of the other input

Definition at line 1671 of file FlashRoutines.cpp.

◆ HSU_P_flash()

void CoolProp::FlashRoutines::HSU_P_flash ( HelmholtzEOSMixtureBackend HEOS,
parameters  other 
)
static

A generic flash routine for the pairs (P,H), (P,S), and (P,U). Similar analysis is needed

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used
otherThe index for the other input from CoolProp::parameters; allowed values are iHmolar, iSmolar, iUmolar

Definition at line 3329 of file FlashRoutines.cpp.

◆ HSU_P_flash_singlephase_Brent()

void CoolProp::FlashRoutines::HSU_P_flash_singlephase_Brent ( HelmholtzEOSMixtureBackend HEOS,
parameters  other,
CoolPropDbl  value,
CoolPropDbl  Tmin,
CoolPropDbl  Tmax,
phases  phase 
)
static

The single-phase flash routine for the pairs (P,H), (P,S), and (P,U). Similar analysis is needed

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used
otherThe index for the other input from CoolProp::parameters; allowed values are iHmolar, iSmolar, iUmolar
valueThe value of the other input
TminThe lower temperature limit [K]
TmaxThe higher temperature limit [K]
phaseThe phase of the fluid that we should get back

Definition at line 2802 of file FlashRoutines.cpp.

◆ HSU_P_flash_singlephase_Newton()

void CoolProp::FlashRoutines::HSU_P_flash_singlephase_Newton ( HelmholtzEOSMixtureBackend HEOS,
parameters  other,
CoolPropDbl  T0,
CoolPropDbl  rhomolar0 
)
static

The single-phase flash routine for the pairs (P,H), (P,S), and (P,U). Similar analysis is needed

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used
otherThe index for the other input from CoolProp::parameters; allowed values are iHmolar, iSmolar, iUmolar
T0The initial guess value for the temperature [K]
rhomolar0The initial guess value for the density [mol/m^3]

Definition at line 2712 of file FlashRoutines.cpp.

◆ PQ_flash()

void CoolProp::FlashRoutines::PQ_flash ( HelmholtzEOSMixtureBackend HEOS)
static

Flash for given pressure and (molar) quality

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used

Definition at line 1157 of file FlashRoutines.cpp.

◆ PQ_flash_with_guesses()

void CoolProp::FlashRoutines::PQ_flash_with_guesses ( HelmholtzEOSMixtureBackend HEOS,
const GuessesStructure guess 
)
static

Flash for given pressure and (molar) quality with guess values provided

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used
guessThe GuessesStructure to be used

Definition at line 1369 of file FlashRoutines.cpp.

◆ PT_flash()

void CoolProp::FlashRoutines::PT_flash ( HelmholtzEOSMixtureBackend HEOS)
static

Flash for given pressure and temperature

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used

Definition at line 298 of file FlashRoutines.cpp.

◆ PT_flash_mixtures()

void CoolProp::FlashRoutines::PT_flash_mixtures ( HelmholtzEOSMixtureBackend HEOS)
static

Flash for given pressure and temperature for mixtures

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used

Definition at line 24 of file FlashRoutines.cpp.

◆ PT_flash_with_guesses()

void CoolProp::FlashRoutines::PT_flash_with_guesses ( HelmholtzEOSMixtureBackend HEOS,
const GuessesStructure guess 
)
static

Flash for given pressure and temperature with guess values provided for molar density

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used
guessThe GuessesStructure to be used

Definition at line 1429 of file FlashRoutines.cpp.

◆ PT_Q_flash_mixtures()

void CoolProp::FlashRoutines::PT_Q_flash_mixtures ( HelmholtzEOSMixtureBackend HEOS,
parameters  other,
CoolPropDbl  value 
)
static

Flash for mixture given temperature or pressure and (molar) quality

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used
otherThe parameter that is imposed, either iT or iP
valueThe value for the imposed parameter

Definition at line 1454 of file FlashRoutines.cpp.

◆ QS_flash()

void CoolProp::FlashRoutines::QS_flash ( HelmholtzEOSMixtureBackend HEOS)
static

Flash for given molar entropy and (molar) quality

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used

Definition at line 637 of file FlashRoutines.cpp.

◆ QS_flash_with_guesses()

void CoolProp::FlashRoutines::QS_flash_with_guesses ( HelmholtzEOSMixtureBackend HEOS,
const GuessesStructure guess 
)
static

Flash for given molar entropy and (molar) quality with a temperature guess used to disambiguate multiple roots (see GitHub #2773). Lazily builds the s_sat superancillary on first use; otherwise mirrors HQ_flash_with_guesses.

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used
guessThe GuessesStructure; only guess.T is consulted

Definition at line 877 of file FlashRoutines.cpp.

◆ QT_flash()

void CoolProp::FlashRoutines::QT_flash ( HelmholtzEOSMixtureBackend HEOS)
static

Flash for given temperature and (molar) quality

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used

Definition at line 888 of file FlashRoutines.cpp.

◆ QT_flash_with_guesses()

void CoolProp::FlashRoutines::QT_flash_with_guesses ( HelmholtzEOSMixtureBackend HEOS,
const GuessesStructure guess 
)
static

Flash for given temperature and (molar) quality with guess values provided

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used
guessThe GuessesStructure to be used

Definition at line 1396 of file FlashRoutines.cpp.

◆ resolve_T_via_superancillary()

double CoolProp::FlashRoutines::resolve_T_via_superancillary ( HelmholtzEOSMixtureBackend HEOS,
parameters  key,
double  target_value,
std::optional< double >  guess_T,
const char *  fn_name 
)
static

Unified internal helper for both the no-guess default flashes (DQ_flash, HQ_flash, QS_flash) and the *_flash_with_guesses paths when the fluid has a superancillary (#2773). Validates inputs, looks up the saturation superancillary for property key (one of iDmolar, iHmolar, iSmolar), and returns the disambiguated T-root.

If guess_T is set, picks the monotonic sub-interval whose temperature range contains guess_T (with tie-break by midpoint distance for boundary cases) and TOMS748-solves there. If guess_T is std::nullopt, enumerates every root, deduplicates by |T_i - T_j| < 1e-6 K (extrema produce near-duplicate roots in adjacent intervals), and either returns the single root, throws MultipleSolutionsError if more remain, or throws OutOfRangeError if none.

Refuses pseudo-pure fluids (caloric superancillaries are not built for them; see #2773 review). Member of FlashRoutines for friend access to HelmholtzEOSMixtureBackend's protected state. fn_name is used only in error messages.

Definition at line 712 of file FlashRoutines.cpp.

◆ sat_superanc_path_applies()

bool CoolProp::FlashRoutines::sat_superanc_path_applies ( HelmholtzEOSMixtureBackend HEOS)
static

Returns true if the strict-mode superancillary path applies for the current state: pure-fluid (not pseudo-pure), superancillary present, Q exactly 0 or 1. Used by DQ_flash, HQ_flash, QS_flash to decide whether to route through the branch-detecting superancillary path or fall back to the legacy solver.

Definition at line 558 of file FlashRoutines.cpp.

◆ solver_for_rho_given_T_oneof_HSU()

void CoolProp::FlashRoutines::solver_for_rho_given_T_oneof_HSU ( HelmholtzEOSMixtureBackend HEOS,
CoolPropDbl  T,
CoolPropDbl  value,
parameters  other 
)
static

The flash routine for T given and one of H,S,U

Parameters
HEOSThe HelmholtzEOSMixtureBackend to be used
TThe temperature
valueThe value for the other variable
otherThe index for the other input from CoolProp::parameters; allowed values are iDmolar, iHmolar, iSmolar, iUmolar

Definition at line 3609 of file FlashRoutines.cpp.

◆ T_DP_PengRobinson()

double CoolProp::FlashRoutines::T_DP_PengRobinson ( HelmholtzEOSMixtureBackend HEOS,
double  rhomolar,
double  p 
)
static

Use Peng-Robinson to get guess for temperature for given density and pressure.

Definition at line 385 of file FlashRoutines.cpp.


The documentation for this class was generated from the following files: