46 double cp0_R, h0_RT, s0_R, p;
48 if (T0 < m_sub->Tcrit()) {
49 m_sub->Set(tpx::PropertyPair::TX, T0, 1.0);
52 p = 0.001*
m_sub->Pcrit();
55 m_sub->Set(tpx::PropertyPair::TP, T0, p);
61 debuglog(
"PureFluidPhase::initThermo: initialized phase "
68 phaseNode[
"pure-fluid-name"] =
m_sub->name();
73 eosdata.
_require(
"model",
"PureFluid");
74 m_subflag = atoi(eosdata[
"fluid_type"].c_str());
76 throw CanteraError(
"PureFluidPhase::setParametersFromXML",
77 "missing or negative substance flag");
83 return {
"TD",
"UV",
"DP",
"HP",
"SP",
"SV",
84 "ST",
"TV",
"PV",
"UP",
"VH",
"TH",
"SH",
"TPQ"};
89 return {
"TP",
"TQ",
"PQ"};
95 return "supercritical";
96 }
else if (
m_sub->TwoPhase() == 1) {
97 return "liquid-gas-mix";
107 return m_sub->Tmin();
112 return m_sub->Tmax();
159 Set(tpx::PropertyPair::TV, T,
m_sub->v());
165 Set(tpx::PropertyPair::TV,
m_sub->Temp(), 1.0/rho);
175 return m_sub->isothermalCompressibility();
180 return m_sub->thermalExpansionCoeff();
257 double plow = 1.0E-8;
258 Set(tpx::PropertyPair::TP, t, plow);
260 Set(tpx::PropertyPair::TP, t, psave);
269 double plow = 1.0E-8;
270 Set(tpx::PropertyPair::TP, t, plow);
272 grt[0] += log(pref/plow);
273 Set(tpx::PropertyPair::TP, t, psave);
287 double plow = 1.0E-8;
288 Set(tpx::PropertyPair::TP, t, plow);
290 er[0] -= log(pref/plow);
291 Set(tpx::PropertyPair::TP, t, psave);
296 return m_sub->Tcrit();
301 return m_sub->Pcrit();
306 return 1.0/
m_sub->Vcrit();
311 return m_sub->Tsat(p);
321 Set(tpx::PropertyPair::HP, h, p);
327 Set(tpx::PropertyPair::UV, u, v);
333 Set(tpx::PropertyPair::SV, s, v);
339 Set(tpx::PropertyPair::SP, s, p);
345 Set(tpx::PropertyPair::ST, s, t);
351 Set(tpx::PropertyPair::TV, t, v);
357 Set(tpx::PropertyPair::PV, p, v);
363 Set(tpx::PropertyPair::UP, u, p);
369 Set(tpx::PropertyPair::VH, v, h);
375 Set(tpx::PropertyPair::TH, t, h);
381 Set(tpx::PropertyPair::SH, s, h);
387 Set(tpx::PropertyPair::TV, t,
m_sub->v());
398 Set(tpx::PropertyPair::TX, t, x);
405 Set(tpx::PropertyPair::PX, p, x);
412 fmt::memory_buffer b;
416 string blank_leader = fmt::format(
"{:{}}",
"", name_width);
418 string one_property = fmt::format(
"{{:>{}}} {{:<.5g}} {{}}\n", name_width);
420 string two_prop_header =
"{} {:^15} {:^15}\n";
421 string kg_kmol_header = fmt::format(
422 two_prop_header, blank_leader,
"1 kg",
"1 kmol"
424 string two_prop_sep = fmt::format(
425 "{} {:-^15} {:-^15}\n", blank_leader,
"",
""
427 string two_property = fmt::format(
428 "{{:>{}}} {{:15.5g}} {{:15.5g}} {{}}\n", name_width
432 fmt_append(b,
"\n {}:\n",
name());
435 fmt_append(b, one_property,
"temperature",
temperature(),
"K");
436 fmt_append(b, one_property,
"pressure",
pressure(),
"Pa");
437 fmt_append(b, one_property,
"density",
density(),
"kg/m^3");
438 fmt_append(b, one_property,
440 fmt_append(b,
"{:>{}} {:<.5g}\n",
442 fmt_append(b,
"{:>{}} {}\n",
447 fmt_append(b, kg_kmol_header);
448 fmt_append(b, two_prop_sep);
449 fmt_append(b, two_property,
451 fmt_append(b, two_property,
453 fmt_append(b, two_property,
455 fmt_append(b, two_property,
457 fmt_append(b, two_property,
459 fmt_append(b, two_property,
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 std::string &key) const
Returns true if the map contains an item named key.
Base class for exceptions thrown by Cantera classes.
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.
double molarDensity() const
Molar density (kmol/m^3).
std::string name() const
Return the name of the phase.
virtual void setDensity(const double density_)
Set the internally stored density (kg/m^3) of the phase.
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
void setState_TR(doublereal t, doublereal rho)
Set the internally stored temperature (K) and density (kg/m^3)
virtual double density() const
Density (kg/m^3).
doublereal temperature() const
Temperature (K).
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.
virtual void setState_PV(double p, double v, double tol=1e-9)
Set the pressure (Pa) and specific volume (m^3/kg).
void Set(tpx::PropertyPair::type n, double x, double y) const
Main call to the tpx level to set the state of the system.
virtual void setState_HP(double h, double p, double tol=1e-9)
Set the internally stored specific enthalpy (J/kg) and pressure (Pa) of the phase.
virtual void setState_UV(double u, double v, double tol=1e-9)
Set the specific internal energy (J/kg) and specific volume (m^3/kg).
virtual void setState_VH(double v, double h, double tol=1e-9)
Set the specific volume (m^3/kg) and the specific enthalpy (J/kg)
virtual void getGibbs_RT_ref(doublereal *grt) const
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
std::string m_tpx_name
Name for this substance used by the TPX package.
virtual void getParameters(AnyMap &phaseNode) const
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
virtual void getActivities(doublereal *a) const
Get the array of non-dimensional activities at the current solution temperature, pressure,...
virtual std::string report(bool show_thermo=true, doublereal threshold=1e-14) const
returns a summary of the state of the phase as a string
virtual void getGibbs_RT(doublereal *grt) const
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
virtual void getPartialMolarIntEnergies(doublereal *ubar) const
Return an array of partial molar internal energies for the species in the mixture.
virtual void setState_UP(double u, double p, double tol=1e-9)
Set the specific internal energy (J/kg) and pressure (Pa).
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
virtual doublereal critPressure() const
Critical pressure (Pa).
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
virtual doublereal vaporFraction() const
Return the fraction of vapor at the current conditions.
virtual void setState_SH(double s, double h, double tol=1e-9)
Set the specific entropy (J/kg/K) and the specific enthalpy (J/kg)
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
virtual void getPartialMolarCp(doublereal *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.
PureFluidPhase()
Empty Base Constructor.
virtual doublereal satTemperature(doublereal p) const
Return the saturation temperature given the pressure.
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
virtual std::vector< std::string > partialStates() const
Return a vector of settable partial property sets within a phase.
virtual void setPressure(doublereal p)
sets the thermodynamic pressure (Pa).
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
virtual doublereal critTemperature() const
Critical temperature (K).
virtual double minTemp(size_t k=npos) const
Minimum temperature for which the thermodynamic data for the species or phase are valid.
virtual void setState_SP(double s, double p, double tol=1e-9)
Set the specific entropy (J/kg/K) and pressure (Pa).
virtual void getEntropy_R_ref(doublereal *er) const
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
virtual void setState_Tsat(doublereal t, doublereal x)
Set the state to a saturated system at a particular temperature.
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
virtual Units standardConcentrationUnits() const
Returns the units of the "standard concentration" for this phase.
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
doublereal m_mw
Molecular weight of the substance (kg kmol-1)
virtual void setDensity(const double rho)
Set the internally stored density (kg/m^3) of the phase.
std::unique_ptr< tpx::Substance > m_sub
Pointer to the underlying tpx object Substance that does the work.
void setSubstance(const std::string &name)
Set the name of the TPX substance to use for the equation of state.
virtual void getStandardChemPotentials(doublereal *mu) const
virtual void setState_Psat(doublereal p, doublereal x)
Set the state to a saturated system at a particular pressure.
virtual double maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
virtual doublereal satPressure(doublereal t)
Return the saturation pressure given the temperature.
virtual std::vector< std::string > fullStates() const
Return a vector containing full states defining a phase.
virtual void setTemperature(const double T)
Set the internally stored temperature of the phase (K).
tpx::Substance & TPX_Substance()
Returns a reference to the substance object.
virtual void getGibbs_ref(doublereal *g) const
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
virtual doublereal critDensity() const
Critical density (kg/m3).
virtual std::string phaseOfMatter() const
String indicating the mechanical phase of the matter in this Phase.
int m_subflag
Int indicating the type of the fluid.
virtual void setState_TV(double t, double v, double tol=1e-9)
Set the temperature (K) and specific volume (m^3/kg).
virtual void setState_SV(double s, double v, double tol=1e-9)
Set the specific entropy (J/kg/K) and specific volume (m^3/kg).
virtual doublereal intEnergy_mole() const
Molar internal energy. Units: J/kmol.
bool m_verbose
flag to turn on some printing.
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
virtual void setState_ST(double s, double t, double tol=1e-9)
Set the specific entropy (J/kg/K) and temperature (K).
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
virtual void setState_TH(double t, double h, double tol=1e-9)
Set the temperature (K) and the specific enthalpy (J/kg)
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
doublereal entropy_mass() const
Specific entropy. Units: J/kg/K.
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
doublereal gibbs_mass() const
Specific Gibbs function. Units: J/kg.
doublereal cp_mass() const
Specific heat at constant pressure. Units: J/kg/K.
virtual doublereal refPressure() const
Returns the reference pressure in Pa.
doublereal cv_mass() const
Specific heat at constant volume. Units: J/kg/K.
doublereal intEnergy_mass() const
Specific internal energy. Units: J/kg.
MultiSpeciesThermo m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
doublereal enthalpy_mass() const
Specific enthalpy. Units: J/kg.
AnyMap m_input
Data supplied via setParameters.
virtual void getParameters(int &n, doublereal *const c) const
Get the equation of state parameters in a vector.
A representation of the units associated with a dimensional quantity.
Class XML_Node is a tree-based representation of the contents of an XML file.
void _require(const std::string &a, const std::string &v) const
Require that the current XML node has an attribute named by the first argument, a,...
This file contains definitions for utility functions and text for modules, inputfiles,...
Namespace for the Cantera kernel.
void debuglog(const std::string &msg, int loglevel)
Write a message to the log only if loglevel > 0.
const double GasConstant
Universal Gas Constant [J/kmol/K].
Contains declarations for string manipulation functions within Cantera.
Classes providing support for XML data files.