32 double cp0_R, h0_RT, s0_R, p;
34 if (T0 < m_sub->Tcrit()) {
35 m_sub->Set(tpx::PropertyPair::TX, T0, 1.0);
38 p = 0.001*
m_sub->Pcrit();
41 m_sub->Set(tpx::PropertyPair::TP, T0, p);
47 debuglog(
"PureFluidPhase::initThermo: initialized phase "
54 phaseNode[
"pure-fluid-name"] =
m_sub->name();
59 return {
"TD",
"UV",
"DP",
"HP",
"SP",
"SV",
60 "ST",
"TV",
"PV",
"UP",
"VH",
"TH",
"SH",
"TPQ"};
65 return {
"TP",
"TQ",
"PQ"};
71 return "supercritical";
72 }
else if (
m_sub->TwoPhase() == 1) {
73 return "liquid-gas-mix";
135 Set(tpx::PropertyPair::TV, T,
m_sub->v());
141 Set(tpx::PropertyPair::TV,
m_sub->Temp(), 1.0/rho);
151 return m_sub->isothermalCompressibility();
156 return m_sub->thermalExpansionCoeff();
233 double plow = 1.0E-8;
234 Set(tpx::PropertyPair::TP, t, plow);
236 Set(tpx::PropertyPair::TV, t, 1 / rhoSave);
245 double plow = 1.0E-8;
246 Set(tpx::PropertyPair::TP, t, plow);
248 grt[0] += log(pref/plow);
249 Set(tpx::PropertyPair::TV, t, 1 / rhoSave);
263 double plow = 1.0E-8;
264 Set(tpx::PropertyPair::TP, t, plow);
266 er[0] -= log(pref/plow);
267 Set(tpx::PropertyPair::TV, t, 1 / rhoSave);
272 return m_sub->Tcrit();
277 return m_sub->Pcrit();
282 return 1.0/
m_sub->Vcrit();
287 return m_sub->Tsat(p);
297 Set(tpx::PropertyPair::HP, h, p);
303 Set(tpx::PropertyPair::UV, u, v);
309 Set(tpx::PropertyPair::SV, s, v);
315 Set(tpx::PropertyPair::SP, s, p);
321 Set(tpx::PropertyPair::ST, s, t);
327 Set(tpx::PropertyPair::TV, t, v);
333 Set(tpx::PropertyPair::PV, p, v);
339 Set(tpx::PropertyPair::UP, u, p);
345 Set(tpx::PropertyPair::VH, v, h);
351 Set(tpx::PropertyPair::TH, t, h);
357 Set(tpx::PropertyPair::SH, s, h);
363 Set(tpx::PropertyPair::TV, t,
m_sub->v());
374 Set(tpx::PropertyPair::TX, t, x);
381 Set(tpx::PropertyPair::PX, p, x);
388 fmt::memory_buffer b;
392 string blank_leader = fmt::format(
"{:{}}",
"", name_width);
394 string one_property = fmt::format(
"{{:>{}}} {{:<.5g}} {{}}\n", name_width);
396 constexpr auto two_prop_header =
"{} {:^15} {:^15}\n";
397 string kg_kmol_header = fmt::format(
398 two_prop_header, blank_leader,
"1 kg",
"1 kmol"
400 string two_prop_sep = fmt::format(
401 "{} {:-^15} {:-^15}\n", blank_leader,
"",
""
403 string two_property = fmt::format(
404 "{{:>{}}} {{:15.5g}} {{:15.5g}} {{}}\n", name_width
Header for a ThermoPhase class for a pure fluid phase consisting of gas, liquid, mixed-gas-liquid and...
A map of string keys to values whose type can vary at runtime.
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
virtual void update_single(size_t k, double T, double *cp_R, double *h_RT, double *s_R) const
Get reference-state properties for a single species.
virtual double molarDensity() const
Molar density (kmol/m^3).
void setState_TD(double t, double rho)
Set the internally stored temperature (K) and density (kg/m^3)
double temperature() const
Temperature (K).
double meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
virtual void setDensity(const double density_)
Set the internally stored density (kg/m^3) of the phase.
virtual double density() const
Density (kg/m^3).
virtual void setTemperature(double temp)
Set the internally stored temperature of the phase (K).
void setMolecularWeight(const int k, const double mw)
Set the molecular weight of a single species to a given value.
string name() const
Return the name of the phase.
void Set(tpx::PropertyPair::type n, double x, double y) const
Main call to the tpx level to set the state of the system.
double enthalpy_mole() const override
Molar enthalpy. Units: J/kmol.
double thermalExpansionCoeff() const override
Return the volumetric thermal expansion coefficient. Units: 1/K.
void getPartialMolarEnthalpies(double *hbar) const override
Returns an array of partial molar enthalpies for the species in the mixture.
double pressure() const override
Return the thermodynamic pressure (Pa).
vector< string > partialStates() const override
Return a vector of settable partial property sets within a phase.
double critPressure() const override
Critical pressure (Pa).
string m_tpx_name
Name for this substance used by the TPX package.
double critDensity() const override
Critical density (kg/m3).
void getEntropy_R(double *sr) const override
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
void setState_SH(double s, double h, double tol=1e-9) override
Set the specific entropy (J/kg/K) and the specific enthalpy (J/kg)
void getGibbs_ref(double *g) const override
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
void getStandardChemPotentials(double *mu) const override
Get the array of chemical potentials at unit activity for the species at their standard states at the...
double critTemperature() const override
Critical temperature (K).
void getActivities(double *a) const override
Get the array of non-dimensional activities at the current solution temperature, pressure,...
void getParameters(AnyMap &phaseNode) const override
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
void initThermo() override
Initialize the ThermoPhase object after all species have been set up.
vector< string > fullStates() const override
Return a vector containing full states defining a phase.
void getActivityConcentrations(double *c) const override
This method returns an array of generalized concentrations.
void setState_HP(double h, double p, double tol=1e-9) override
Set the internally stored specific enthalpy (J/kg) and pressure (Pa) of the phase.
void setPressure(double p) override
sets the thermodynamic pressure (Pa).
unique_ptr< tpx::Substance > m_sub
Pointer to the underlying tpx object Substance that does the work.
void getPartialMolarVolumes(double *vbar) const override
Return an array of partial molar volumes for the species in the mixture.
void setState_PV(double p, double v, double tol=1e-9) override
Set the pressure (Pa) and specific volume (m^3/kg).
void setState_VH(double v, double h, double tol=1e-9) override
Set the specific volume (m^3/kg) and the specific enthalpy (J/kg)
double vaporFraction() const override
Return the fraction of vapor at the current conditions.
void setState_TH(double t, double h, double tol=1e-9) override
Set the temperature (K) and the specific enthalpy (J/kg)
double cv_mole() const override
Molar heat capacity at constant volume. Units: J/kmol/K.
void setTemperature(const double T) override
Set the internally stored temperature of the phase (K).
void setSubstance(const string &name)
Set the name of the TPX substance to use for the equation of state.
void getEnthalpy_RT(double *hrt) const override
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
void getEntropy_R_ref(double *er) const override
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
double minTemp(size_t k=npos) const override
Minimum temperature for which the thermodynamic data for the species or phase are valid.
double isothermalCompressibility() const override
Returns the isothermal compressibility. Units: 1/Pa.
void getGibbs_RT(double *grt) const override
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
double intEnergy_mole() const override
Molar internal energy. Units: J/kmol.
void setState_Tsat(double t, double x) override
Set the state to a saturated system at a particular temperature.
double entropy_mole() const override
Molar entropy. Units: J/kmol/K.
void getPartialMolarIntEnergies(double *ubar) const override
Return an array of partial molar internal energies for the species in the mixture.
double cp_mole() const override
Molar heat capacity at constant pressure. Units: J/kmol/K.
void setState_SV(double s, double v, double tol=1e-9) override
Set the specific entropy (J/kg/K) and specific volume (m^3/kg).
Units standardConcentrationUnits() const override
Returns the units of the "standard concentration" for this phase.
void getPartialMolarCp(double *cpbar) const override
Return an array of partial molar heat capacities for the species in the mixture.
double gibbs_mole() const override
Molar Gibbs function. Units: J/kmol.
double standardConcentration(size_t k=0) const override
Return the standard concentration for the kth species.
double satTemperature(double p) const override
Return the saturation temperature given the pressure.
double m_mw
Molecular weight of the substance (kg kmol-1)
tpx::Substance & TPX_Substance()
Returns a reference to the substance object.
void setState_TV(double t, double v, double tol=1e-9) override
Set the temperature (K) and specific volume (m^3/kg).
void setState_UV(double u, double v, double tol=1e-9) override
Set the specific internal energy (J/kg) and specific volume (m^3/kg).
void getGibbs_RT_ref(double *grt) const override
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
void setState_Psat(double p, double x) override
Set the state to a saturated system at a particular pressure.
void setState_UP(double u, double p, double tol=1e-9) override
Set the specific internal energy (J/kg) and pressure (Pa).
void setState_SP(double s, double p, double tol=1e-9) override
Set the specific entropy (J/kg/K) and pressure (Pa).
void setState_ST(double s, double t, double tol=1e-9) override
Set the specific entropy (J/kg/K) and temperature (K).
void getPartialMolarEntropies(double *sbar) const override
Returns an array of partial molar entropies of the species in the solution.
bool m_verbose
flag to turn on some printing.
double maxTemp(size_t k=npos) const override
Maximum temperature for which the thermodynamic data for the species are valid.
string phaseOfMatter() const override
String indicating the mechanical phase of the matter in this Phase.
void getEnthalpy_RT_ref(double *hrt) const override
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
double satPressure(double t) override
Return the saturation pressure given the temperature.
void setDensity(const double rho) override
Set the internally stored density (kg/m^3) of the phase.
string report(bool show_thermo=true, double threshold=1e-14) const override
returns a summary of the state of the phase as a string
virtual void getParameters(AnyMap &phaseNode) const
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
double RT() const
Return the Gas Constant multiplied by the current temperature.
double gibbs_mass() const
Specific Gibbs function. Units: J/kg.
double cv_mass() const
Specific heat at constant volume. Units: J/kg/K.
double entropy_mass() const
Specific entropy. Units: J/kg/K.
double cp_mass() const
Specific heat at constant pressure. Units: J/kg/K.
double intEnergy_mass() const
Specific internal energy. Units: J/kg.
MultiSpeciesThermo m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
virtual double refPressure() const
Returns the reference pressure in Pa.
AnyMap m_input
Data supplied via setParameters.
double enthalpy_mass() const
Specific enthalpy. Units: J/kg.
A representation of the units associated with a dimensional quantity.
Base class from which all pure substances are derived.
void fmt_append(fmt::memory_buffer &b, const std::string &tmpl, Args... args)
Versions 6.2.0 and 6.2.1 of fmtlib do not include this define before they include windows....
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
void debuglog(const string &msg, int loglevel)
Write a message to the log only if loglevel > 0.
const double GasConstant
Universal Gas Constant [J/kmol/K].
Namespace for the Cantera kernel.
Contains declarations for string manipulation functions within Cantera.