Cantera  4.0.0a1
Loading...
Searching...
No Matches
SingleSpeciesTP.cpp
Go to the documentation of this file.
1/**
2 * @file SingleSpeciesTP.cpp
3 * Definitions for the SingleSpeciesTP class, which is a filter class for ThermoPhase,
4 * that eases the construction of single species phases
5 * ( see @ref thermoprops and class @link Cantera::SingleSpeciesTP SingleSpeciesTP@endlink).
6 */
7
8// This file is part of Cantera. See License.txt in the top-level directory or
9// at https://cantera.org/license.txt for license and copyright information.
10
13#include "cantera/base/global.h"
14
15namespace Cantera
16{
17
18// ------------ Molar Thermodynamic Properties --------------------
19
21{
22 double hbar;
23 getPartialMolarEnthalpies(span<double>(&hbar, 1));
24 return hbar;
25}
26
28{
29 double ubar;
30 getPartialMolarIntEnergies(span<double>(&ubar, 1));
31 return ubar;
32}
33
35{
36 double sbar;
37 getPartialMolarEntropies(span<double>(&sbar, 1));
38 return sbar;
39}
40
42{
43 double gbar;
44
45 // Get the chemical potential of the first species. This is the same as the
46 // partial molar Gibbs free energy.
47 getChemPotentials(span<double>(&gbar, 1));
48 return gbar;
49}
50
52{
53 double cpbar;
54
55 // Really should have a partial molar heat capacity function in ThermoPhase.
56 // However, the standard state heat capacity will do fine here for now.
57 getCp_R(span<double>(&cpbar, 1));
58 cpbar *= GasConstant;
59 return cpbar;
60}
61
63{
64 // For single species, we go directory to the general Cp - Cv relation
65 //
66 // Cp = Cv + alpha**2 * V * T / beta
67 //
68 // where
69 // alpha = volume thermal expansion coefficient
70 // beta = isothermal compressibility
71 double cvbar = cp_mole();
72 double alpha = thermalExpansionCoeff();
73 double beta = isothermalCompressibility();
74 double V = molecularWeight(0)/density();
75 double T = temperature();
76 if (beta != 0.0) {
77 cvbar -= alpha * alpha * V * T / beta;
78 }
79 return cvbar;
80}
81
82// ----------- Partial Molar Properties of the Solution -----------------
83
84void SingleSpeciesTP::getChemPotentials(span<double> mu) const
85{
87}
88
89void SingleSpeciesTP::getPartialMolarEnthalpies(span<double> hbar) const
90{
91 getEnthalpy_RT(hbar);
92 hbar[0] *= RT();
93}
94
96{
97 getIntEnergy_RT(ubar);
98 ubar[0] *= RT();
99}
100
101void SingleSpeciesTP::getPartialMolarEntropies(span<double> sbar) const
102{
103 getEntropy_R(sbar);
104 sbar[0] *= GasConstant;
105}
106
107void SingleSpeciesTP::getPartialMolarCp(span<double> cpbar) const
108{
109 getCp_R(cpbar);
110 cpbar[0] *= GasConstant;
111}
112
113void SingleSpeciesTP::getPartialMolarVolumes(span<double> vbar) const
114{
115 checkArraySize("SingleSpeciesTP::getPartialMolarVolumes", vbar.size(), 1);
116 vbar[0] = molecularWeight(0) / density();
117}
118
119// Properties of the Standard State of the Species in the Solution
120
121void SingleSpeciesTP::getStandardVolumes(span<double> vbar) const
122{
123 checkArraySize("SingleSpeciesTP::getStandardVolumes", vbar.size(), 1);
124 vbar[0] = molecularWeight(0) / density();
125}
126
127// ---- Thermodynamic Values for the Species Reference States -------
128
129void SingleSpeciesTP::getEnthalpy_RT_ref(span<double> hrt) const
130{
131 checkArraySize("SingleSpeciesTP::getEnthalpy_RT_ref", hrt.size(), 1);
133 hrt[0] = m_h0_RT;
134}
135
136void SingleSpeciesTP::getGibbs_RT_ref(span<double> grt) const
137{
138 checkArraySize("SingleSpeciesTP::getGibbs_RT_ref", grt.size(), 1);
140 grt[0] = m_h0_RT - m_s0_R;
141}
142
143void SingleSpeciesTP::getGibbs_ref(span<double> g) const
144{
146 g[0] *= RT();
147}
148
149void SingleSpeciesTP::getEntropy_R_ref(span<double> er) const
150{
151 checkArraySize("SingleSpeciesTP::getEntropy_R_ref", er.size(), 1);
153 er[0] = m_s0_R;
154}
155
156void SingleSpeciesTP::getCp_R_ref(span<double> cpr) const
157{
158 checkArraySize("SingleSpeciesTP::getCp_R_ref", cpr.size(), 1);
160 cpr[0] = m_cp0_R;
161}
162
163bool SingleSpeciesTP::addSpecies(shared_ptr<Species> spec)
164{
165 if (m_kk != 0) {
166 throw CanteraError("SingleSpeciesTP::addSpecies",
167 "Stoichiometric substances may only contain one species.");
168 }
169 return ThermoPhase::addSpecies(spec);
170}
171
173{
174 double tnow = temperature();
175 if (m_tlast != tnow) {
177 m_tlast = tnow;
178 }
179}
180
181}
Header for the SingleSpeciesTP class, which is a filter class for ThermoPhase, that eases the constru...
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.
size_t m_kk
Number of species in the phase.
Definition Phase.h:875
double temperature() const
Temperature (K).
Definition Phase.h:585
virtual double density() const
Density (kg/m^3).
Definition Phase.h:610
double molecularWeight(size_t k) const
Molecular weight of species k.
Definition Phase.cpp:388
void getGibbs_ref(span< double > g) const override
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
double enthalpy_mole() const override
Molar enthalpy. Units: J/kmol.
void getEntropy_R_ref(span< double > er) const override
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
void getPartialMolarEnthalpies(span< double > hbar) const override
Get the species partial molar enthalpies. Units: J/kmol.
void getPartialMolarCp(span< double > cpbar) const override
Get the species partial molar Heat Capacities. Units: J/ kmol /K.
void getCp_R_ref(span< double > cprt) const override
Returns the vector of nondimensional constant pressure heat capacities of the reference state at the ...
void getEnthalpy_RT_ref(span< double > hrt) const override
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
double cv_mole() const override
Molar heat capacity at constant volume and composition [J/kmol/K].
double m_h0_RT
Dimensionless enthalpy at the (mtlast, m_p0)
double m_s0_R
Dimensionless entropy at the (mtlast, m_p0)
void getStandardVolumes(span< double > vbar) const override
Get the molar volumes of each species in their standard states at the current T and P of the solution...
double intEnergy_mole() const override
Molar internal energy. Units: J/kmol.
double entropy_mole() const override
Molar entropy. Units: J/kmol/K.
void getGibbs_RT_ref(span< double > grt) const override
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
double m_cp0_R
Dimensionless heat capacity at the (mtlast, m_p0)
double cp_mole() const override
Molar heat capacity at constant pressure and composition [J/kmol/K].
void getPartialMolarVolumes(span< double > vbar) const override
Get the species partial molar volumes. Units: m^3/kmol.
void getPartialMolarEntropies(span< double > sbar) const override
Get the species partial molar entropy. Units: J/kmol K.
double gibbs_mole() const override
Molar Gibbs function. Units: J/kmol.
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
void _updateThermo() const
This internal routine calculates new species Cp0, H0, and S0 whenever the temperature has changed.
void getChemPotentials(span< double > mu) const override
Get the array of chemical potentials.
void getPartialMolarIntEnergies(span< double > ubar) const override
Get the species partial molar internal energies. Units: J/kmol.
virtual double thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
double RT() const
Return the Gas Constant multiplied by the current temperature.
double m_tlast
last value of the temperature processed by reference state
virtual void getCp_R(span< double > cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
virtual void getStandardChemPotentials(span< double > mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
virtual double isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
virtual void getEntropy_R(span< double > sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
virtual void getEnthalpy_RT(span< double > hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
virtual void getIntEnergy_RT(span< double > urt) const
Returns the vector of nondimensional Internal Energies of the standard state species at the current T...
MultiSpeciesThermo m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition ct_defs.h:123
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
void checkArraySize(const char *procedure, size_t available, size_t required)
Wrapper for throwing ArraySizeError.
Contains declarations for string manipulation functions within Cantera.