47 double cp0_R, h0_RT, s0_R, p;
49 if (T0 < m_sub->Tcrit()) {
50 m_sub->Set(tpx::PropertyPair::TX, T0, 1.0);
53 p = 0.001*
m_sub->Pcrit();
56 m_sub->Set(tpx::PropertyPair::TP, T0, p);
62 debuglog(
"PureFluidPhase::initThermo: initialized phase "
68 eosdata.
_require(
"model",
"PureFluid");
69 m_subflag = atoi(eosdata[
"fluid_type"].c_str());
71 throw CanteraError(
"PureFluidPhase::setParametersFromXML",
72 "missing or negative substance flag");
78 return {
"TD",
"UV",
"DP",
"HP",
"SP",
"SV",
79 "ST",
"TV",
"PV",
"UP",
"VH",
"TH",
"SH",
"TPQ"};
84 return {
"TP",
"TQ",
"PQ"};
90 return "supercritical";
91 }
else if (
m_sub->TwoPhase() == 1) {
92 return "liquid-gas-mix";
102 return m_sub->Tmin();
107 return m_sub->Tmax();
154 Set(tpx::PropertyPair::TV, T,
m_sub->v());
160 Set(tpx::PropertyPair::TV,
m_sub->Temp(), 1.0/rho);
170 return m_sub->isothermalCompressibility();
175 return m_sub->thermalExpansionCoeff();
252 double plow = 1.0E-8;
253 Set(tpx::PropertyPair::TP, t, plow);
255 Set(tpx::PropertyPair::TP, t, psave);
264 double plow = 1.0E-8;
265 Set(tpx::PropertyPair::TP, t, plow);
267 grt[0] += log(pref/plow);
268 Set(tpx::PropertyPair::TP, t, psave);
282 double plow = 1.0E-8;
283 Set(tpx::PropertyPair::TP, t, plow);
285 er[0] -= log(pref/plow);
286 Set(tpx::PropertyPair::TP, t, psave);
291 return m_sub->Tcrit();
296 return m_sub->Pcrit();
301 return 1.0/
m_sub->Vcrit();
306 return m_sub->Tsat(p);
316 Set(tpx::PropertyPair::HP, h, p);
322 Set(tpx::PropertyPair::UV, u, v);
328 Set(tpx::PropertyPair::SV, s, v);
334 Set(tpx::PropertyPair::SP, s, p);
340 Set(tpx::PropertyPair::ST, s, t);
346 Set(tpx::PropertyPair::TV, t, v);
352 Set(tpx::PropertyPair::PV, p, v);
358 Set(tpx::PropertyPair::UP, u, p);
364 Set(tpx::PropertyPair::VH, v, h);
370 Set(tpx::PropertyPair::TH, t, h);
376 Set(tpx::PropertyPair::SH, s, h);
382 Set(tpx::PropertyPair::TV, t,
m_sub->v());
393 Set(tpx::PropertyPair::TX, t, x);
400 Set(tpx::PropertyPair::PX, p, x);
407 fmt::memory_buffer b;
411 string blank_leader = fmt::format(
"{:{}}",
"", name_width);
413 string one_property =
"{:>{}} {:<.5g} {}\n";
415 string two_prop_header =
"{} {:^15} {:^15}\n";
416 string kg_kmol_header = fmt::format(
417 two_prop_header, blank_leader,
"1 kg",
"1 kmol"
419 string Y_X_header = fmt::format(
420 two_prop_header, blank_leader,
"mass frac. Y",
"mole frac. X"
422 string two_prop_sep = fmt::format(
423 "{} {:-^15} {:-^15}\n", blank_leader,
"",
""
425 string two_property =
"{:>{}} {:15.5g} {:15.5g} {}\n";
427 string three_prop_header = fmt::format(
428 "{} {:^15} {:^15} {:^15}\n", blank_leader,
"mass frac. Y",
429 "mole frac. X",
"chem. pot. / RT"
431 string three_prop_sep = fmt::format(
432 "{} {:-^15} {:-^15} {:-^15}\n", blank_leader,
"",
"",
""
434 string three_property =
"{:>{}} {:15.5g} {:15.5g} {:15.5g}\n";
437 format_to(b,
"\n {}:\n",
name());
440 format_to(b, one_property,
"temperature", name_width,
temperature(),
"K");
441 format_to(b, one_property,
"pressure", name_width,
pressure(),
"Pa");
442 format_to(b, one_property,
"density", name_width,
density(),
"kg/m^3");
443 format_to(b, one_property,
"mean mol. weight", name_width,
meanMolecularWeight(),
"kg/kmol");
444 format_to(b,
"{:>{}} {:<.5g}\n",
"vapor fraction", name_width,
vaporFraction());
445 format_to(b,
"{:>{}} {}\n",
"phase of matter", name_width,
phaseOfMatter());
449 format_to(b, kg_kmol_header);
450 format_to(b, two_prop_sep);
455 format_to(b, two_property,
"heat capacity c_p", name_width,
cp_mass(),
cp_mole(),
"J/K");
456 format_to(b, two_property,
"heat capacity c_v", name_width,
cv_mass(),
cv_mole(),
"J/K");
Header for a ThermoPhase class for a pure fluid phase consisting of gas, liquid, mixed-gas-liquid and...
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
Like update_one, but without applying offsets to the output pointers.
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).
void setMolecularWeight(const int k, const double mw)
Set the molecular weight of a single species to a given value.
virtual void setTemperature(const doublereal temp)
Set the internally stored temperature of the phase (K).
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 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.
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,...
const double GasConstant
Universal Gas Constant [J/kmol/K].
Namespace for the Cantera kernel.
Contains declarations for string manipulation functions within Cantera.
Classes providing support for XML data files.