ThermoPhase.cpp Source File#
ThermoPhase.cpp
Go to the documentation of this file.
Chemical equilibrium.
Headers for the MultiPhase object that is used to set up multiphase equilibrium problems (see Chemica...
Pure Virtual Base class for individual species reference state thermodynamic managers and text for th...
Declaration for class Cantera::Species.
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
Definition AnyMap.cpp:1423
double convert(const string &key, const string &units) const
Convert the item stored by the given key to the units specified in units.
Definition AnyMap.cpp:1535
void setFlowStyle(bool flow=true)
Use "flow" style when outputting this AnyMap to YAML.
Definition AnyMap.cpp:1726
static AnyMap fromYamlFile(const string &name, const string &parent_name="")
Create an AnyMap from a YAML file.
Definition AnyMap.cpp:1771
void update(const AnyMap &other, bool keepExisting=true)
Add items from other to this AnyMap.
Definition AnyMap.cpp:1438
static bool addOrderingRules(const string &objectType, const vector< vector< string > > &specs)
Add global rules for setting the order of elements when outputting AnyMap objects to YAML.
Definition AnyMap.cpp:1730
string keys_str() const
Return a string listing the keys in this AnyMap, for use in error messages, for example.
Definition AnyMap.cpp:1447
Base class for exceptions thrown by Cantera classes.
Definition ctexceptions.h:66
Class ChemEquil implements a chemical equilibrium solver for single-phase solutions.
Definition ChemEquil.h:79
int equilibrate(ThermoPhase &s, const char *XY, int loglevel=0)
Equilibrate a phase, holding the elemental composition fixed at the initial value found within the Th...
Definition ChemEquil.cpp:293
string canonicalize(const string &name)
Get the canonical name registered for a type.
Definition FactoryBase.h:94
A species thermodynamic property manager for a phase.
Definition MultiSpeciesThermo.h:47
bool ready(size_t nSpecies)
Check if data for all species (0 through nSpecies-1) has been installed.
Definition MultiSpeciesThermo.cpp:203
virtual void install_STIT(size_t index, shared_ptr< SpeciesThermoInterpType > stit)
Install a new species thermodynamic property parameterization for one species.
Definition MultiSpeciesThermo.cpp:21
virtual void modifySpecies(size_t index, shared_ptr< SpeciesThermoInterpType > spec)
Modify the species thermodynamic property parameterization for a species.
Definition MultiSpeciesThermo.cpp:53
virtual void resetHf298(const size_t k)
Restore the original heat of formation of one or more species.
Definition MultiSpeciesThermo.cpp:195
An error indicating that an unimplemented function has been called.
Definition ctexceptions.h:195
double massFraction(size_t k) const
Return the mass fraction of a single species.
Definition Phase.cpp:455
virtual bool addSpecies(shared_ptr< Species > spec)
Add a Species to this Phase.
Definition Phase.cpp:701
virtual void setMoleFractions(const double *const x)
Set the mole fractions to the specified values.
Definition Phase.cpp:289
void assertCompressible(const string &setter) const
Ensure that phase is compressible.
Definition Phase.h:802
void restoreState(const vector< double > &state)
Restore a state saved on a previous call to saveState.
Definition Phase.cpp:260
virtual void setMassFractions_NoNorm(const double *const y)
Set the mass fractions to the specified values without normalizing.
Definition Phase.cpp:355
virtual map< string, size_t > nativeState() const
Return a map of properties defining the native state of a substance.
Definition Phase.cpp:167
virtual void modifySpecies(size_t k, shared_ptr< Species > spec)
Modify the thermodynamic data associated with a species.
Definition Phase.cpp:805
void setState_TD(double t, double rho)
Set the internally stored temperature (K) and density (kg/m^3)
Definition Phase.cpp:377
virtual void setPressure(double p)
Set the internally stored pressure (Pa) at constant temperature and composition.
Definition Phase.h:616
void moleFractionsToMassFractions(const double *X, double *Y) const
Converts a mixture composition from mass fractions to mole fractions.
Definition Phase.cpp:938
void saveState(vector< double > &state) const
Save the current internal state of the phase.
Definition Phase.cpp:236
size_t elementIndex(const string &name) const
Return the index of element named 'name'.
Definition Phase.cpp:55
void setMassFractionsByName(const Composition &yMap)
Set the species mass fractions by name.
Definition Phase.cpp:366
virtual void setDensity(const double density_)
Set the internally stored density (kg/m^3) of the phase.
Definition Phase.cpp:586
vector< double > getCompositionFromMap(const Composition &comp) const
Converts a Composition to a vector with entries for each species Species that are not specified are s...
Definition Phase.cpp:909
void getMoleFractions(double *const x) const
Get the species mole fraction vector.
Definition Phase.cpp:434
void setMoleFractionsByName(const Composition &xMap)
Set the species mole fractions by name.
Definition Phase.cpp:330
const double * massFractions() const
Return a const pointer to the mass fraction array.
Definition Phase.h:442
const vector< double > & molecularWeights() const
Return a const reference to the internal vector of molecular weights.
Definition Phase.cpp:395
double moleFraction(size_t k) const
Return the mole fraction of a single species.
Definition Phase.cpp:439
const vector< string > & elementNames() const
Return a read-only reference to the vector of element names.
Definition Phase.cpp:65
double nAtoms(size_t k, size_t m) const
Number of atoms of element m in species k.
Definition Phase.cpp:103
virtual void setTemperature(double temp)
Set the internally stored temperature of the phase (K).
Definition Phase.h:623
virtual void setMassFractions(const double *const y)
Set the mass fractions to the specified values and normalize them.
Definition Phase.cpp:341
const vector< string > & speciesNames() const
Return a const reference to the vector of species names.
Definition Phase.cpp:148
virtual void invalidateCache()
Invalidate any cached values which are normally updated only when a change in state is detected.
Definition Phase.cpp:890
double charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
Definition Phase.h:538
static ThermoFactory * factory()
Static function that creates a static instance of the factory.
Definition ThermoFactory.cpp:103
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.
Definition ThermoPhase.cpp:134
double electricPotential() const
Returns the electric potential of this phase (V).
Definition ThermoPhase.h:621
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).
Definition ThermoPhase.cpp:139
virtual double cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
Definition ThermoPhase.h:545
double equivalenceRatio() const
Compute the equivalence ratio for the current mixture from available oxygen and required oxygen.
Definition ThermoPhase.cpp:782
virtual void setParameters(const AnyMap &phaseNode, const AnyMap &rootNode=AnyMap())
Set equation of state parameters from an AnyMap phase description.
Definition ThermoPhase.cpp:1084
virtual void getParameters(AnyMap &phaseNode) const
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
Definition ThermoPhase.cpp:1099
virtual void setState_TP(double t, double p)
Set the temperature (K) and pressure (Pa)
Definition ThermoPhase.cpp:121
virtual double standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
Definition ThermoPhase.h:718
virtual void setState_TV(double t, double v, double tol=1e-9)
Set the temperature (K) and specific volume (m^3/kg).
Definition ThermoPhase.h:1237
virtual double logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
Definition ThermoPhase.cpp:55
double o2Present(const double *y) const
Helper function for computing the amount of oxygen available in the current mixture.
Definition ThermoPhase.cpp:666
virtual void setState_PV(double p, double v, double tol=1e-9)
Set the pressure (Pa) and specific volume (m^3/kg).
Definition ThermoPhase.h:1253
virtual void setState(const AnyMap &state)
Set the state using an AnyMap containing any combination of properties supported by the thermodynamic...
Definition ThermoPhase.cpp:145
virtual double minTemp(size_t k=npos) const
Minimum temperature for which the thermodynamic data for the species or phase are valid.
Definition ThermoPhase.h:451
virtual void setState_TPX(double t, double p, const double *x)
Set the temperature (K), pressure (Pa), and mole fractions.
Definition ThermoPhase.cpp:85
void setState_SPorSV(double s, double p, double tol=1e-9, bool doSV=false)
Carry out work in SP and SV calculations.
Definition ThermoPhase.cpp:464
double RT() const
Return the Gas Constant multiplied by the current temperature.
Definition ThermoPhase.h:1062
virtual void setState_TPY(double t, double p, const double *y)
Set the internally stored temperature (K), pressure (Pa), and mass fractions of the phase.
Definition ThermoPhase.cpp:103
double m_tlast
last value of the temperature processed by reference state
Definition ThermoPhase.h:1985
virtual void setState_ST(double s, double t, double tol=1e-9)
Set the specific entropy (J/kg/K) and temperature (K).
Definition ThermoPhase.h:1221
void setState_HPorUV(double h, double p, double tol=1e-9, bool doUV=false)
Carry out work in HP and UV calculations.
Definition ThermoPhase.cpp:262
virtual void getActivityConcentrations(double *c) const
This method returns an array of generalized concentrations.
Definition ThermoPhase.h:697
double stoichAirFuelRatio(const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar) const
Compute the stoichiometric air to fuel ratio (kg oxidizer / kg fuel) given fuel and oxidizer composit...
Definition ThermoPhase.cpp:700
string type() const override
String indicating the thermodynamic model implemented.
Definition ThermoPhase.h:399
AnyMap parameters(bool withInput=true) const
Returns the parameters of a ThermoPhase object such that an identical one could be reconstructed usin...
Definition ThermoPhase.cpp:1089
virtual string report(bool show_thermo=true, double threshold=-1e-14) const
returns a summary of the state of the phase as a string
Definition ThermoPhase.cpp:1277
virtual double maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
Definition ThermoPhase.h:504
double mixtureFraction(const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar, const string &element="Bilger") const
Compute the mixture fraction = kg fuel / (kg oxidizer + kg fuel) for the current mixture given fuel a...
Definition ThermoPhase.cpp:915
double o2Required(const double *y) const
Helper function for computing the amount of oxygen required for complete oxidation.
Definition ThermoPhase.cpp:637
void getElectrochemPotentials(double *mu) const
Get the species electrochemical potentials.
Definition ThermoPhase.cpp:76
virtual void getdlnActCoeffdlnN(const size_t ld, double *const dlnActCoeffdlnN)
Get the array of derivatives of the log activity coefficients with respect to the log of the species ...
Definition ThermoPhase.cpp:1212
virtual void getActivityCoefficients(double *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
Definition ThermoPhase.h:747
virtual string phaseOfMatter() const
String indicating the mechanical phase of the matter in this Phase.
Definition ThermoPhase.h:428
virtual void setState_Tsat(double t, double x)
Set the state to a saturated system at a particular temperature.
Definition ThermoPhase.h:1730
virtual int activityConvention() const
This method returns the convention used in specification of the activities, of which there are curren...
Definition ThermoPhase.cpp:39
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
Definition ThermoPhase.cpp:1016
virtual MultiSpeciesThermo & speciesThermo(int k=-1)
Return a changeable reference to the calculation manager for species reference-state thermodynamic pr...
Definition ThermoPhase.cpp:984
virtual void setState_UP(double u, double p, double tol=1e-9)
Set the specific internal energy (J/kg) and pressure (Pa).
Definition ThermoPhase.h:1269
void initThermoFile(const string &inputFile, const string &id)
Initialize a ThermoPhase object using an input file.
Definition ThermoPhase.cpp:995
virtual void setState_SP(double s, double p, double tol=1e-9)
Set the specific entropy (J/kg/K) and pressure (Pa).
Definition ThermoPhase.cpp:453
virtual int standardStateConvention() const
This method returns the convention used in specification of the standard state, of which there are cu...
Definition ThermoPhase.cpp:44
void modifySpecies(size_t k, shared_ptr< Species > spec) override
Modify the thermodynamic data associated with a species.
Definition ThermoPhase.cpp:1068
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)
Definition ThermoPhase.h:1317
void invalidateCache() override
Invalidate any cached values which are normally updated only when a change in state is detected.
Definition ThermoPhase.cpp:1162
virtual void getActivities(double *a) const
Get the array of non-dimensional activities at the current solution temperature, pressure,...
Definition ThermoPhase.cpp:60
void setMixtureFraction(double mixFrac, const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar)
Set the mixture composition according to the mixture fraction = kg fuel / (kg oxidizer + kg fuel)
Definition ThermoPhase.cpp:858
virtual void resetHf298(const size_t k=npos)
Restore the original heat of formation of one or more species.
Definition ThermoPhase.cpp:28
virtual void getChemPotentials(double *mu) const
Get the species chemical potentials. Units: J/kmol.
Definition ThermoPhase.h:775
double cp_mass() const
Specific heat at constant pressure. Units: J/kg/K.
Definition ThermoPhase.h:1048
virtual void setState_TH(double t, double h, double tol=1e-9)
Set the temperature (K) and the specific enthalpy (J/kg)
Definition ThermoPhase.h:1301
virtual void getLnActivityCoefficients(double *lnac) const
Get the array of non-dimensional molar-based ln activity coefficients at the current solution tempera...
Definition ThermoPhase.cpp:68
virtual Units standardConcentrationUnits() const
Returns the units of the "standard concentration" for this phase.
Definition ThermoPhase.cpp:49
virtual double cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition ThermoPhase.h:550
MultiSpeciesThermo m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
Definition ThermoPhase.h:1962
virtual double satPressure(double t)
Return the saturation pressure given the temperature.
Definition ThermoPhase.h:1716
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
Definition ThermoPhase.cpp:1054
virtual double intEnergy_mole() const
Molar internal energy. Units: J/kmol.
Definition ThermoPhase.h:530
virtual void setState_DP(double rho, double p)
Set the density (kg/m**3) and pressure (Pa) at constant composition.
Definition ThermoPhase.h:1335
void setEquivalenceRatio(double phi, const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar)
Set the mixture composition according to the equivalence ratio.
Definition ThermoPhase.cpp:731
void setState_TPQ(double T, double P, double Q)
Set the temperature, pressure, and vapor fraction (quality).
Definition ThermoPhase.cpp:1025
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)
Definition ThermoPhase.h:1285
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).
Definition ThermoPhase.cpp:458
const AnyMap & input() const
Access input data associated with the phase description.
Definition ThermoPhase.cpp:1152
virtual void setState_Psat(double p, double x)
Set the state to a saturated system at a particular pressure.
Definition ThermoPhase.h:1739
void setState_conditional_TP(double t, double p, bool set_p)
Helper function used by setState_HPorUV and setState_SPorSV.
Definition ThermoPhase.cpp:254
A representation of the units associated with a dimensional quantity.
Definition Units.h:35
void fmt_append(fmt::memory_buffer &b, Args... args)
Versions 6.2.0 and 6.2.1 of fmtlib do not include this define before they include windows....
Definition fmt.h:29
Composition parseCompString(const string &ss, const vector< string > &names)
Parse a composition string into a map consisting of individual key:composition pairs.
Definition stringUtils.cpp:58
void equilibrate(const string &XY, const string &solver="auto", double rtol=1e-9, int max_steps=50000, int max_iter=100, int estimate_equil=0, int log_level=0)
Equilibrate a ThermoPhase object.
Definition ThermoPhase.cpp:1167
void debuglog(const string &msg, int loglevel)
Write a message to the log only if loglevel > 0.
Definition global.h:158
double dot(InputIter x_begin, InputIter x_end, InputIter2 y_begin)
Function that calculates a templated inner product.
Definition utilities.h:82
T clip(const T &value, const T &lower, const T &upper)
Clip value such that lower <= value <= upper.
Definition global.h:329
void setupPhase(ThermoPhase &thermo, const AnyMap &phaseNode, const AnyMap &rootNode)
Initialize a ThermoPhase object.
Definition ThermoFactory.cpp:207
ThermoBasis
Differentiate between mole fractions and mass fractions for input mixture composition.
Definition ThermoPhase.h:154
Contains declarations for string manipulation functions within Cantera.
Generated by