Cantera  2.3.0
ConstDensityThermo.cpp
Go to the documentation of this file.
1 /**
2  * @file ConstDensityThermo.cpp
3  * Declarations for a Thermo manager for incompressible ThermoPhases
4  * (see \ref thermoprops and \link Cantera::ConstDensityThermo ConstDensityThermo
5 \endlink).
6  */
7 
8 // This file is part of Cantera. See License.txt in the top-level directory or
9 // at http://www.cantera.org/license.txt for license and copyright information.
10 
13 #include "cantera/base/ctml.h"
14 
15 namespace Cantera
16 {
17 
18 ConstDensityThermo::ConstDensityThermo(const ConstDensityThermo& right)
19 {
20  *this = right;
21 }
22 
23 ConstDensityThermo& ConstDensityThermo::operator=(const ConstDensityThermo& right)
24 {
25  if (&right == this) {
26  return *this;
27  }
28 
29  m_h0_RT = right.m_h0_RT;
30  m_cp0_R = right.m_cp0_R;
31  m_g0_RT = right.m_g0_RT;
32  m_s0_R = right.m_s0_R;
33 
34  return *this;
35 
36 }
37 
39 {
40  return new ConstDensityThermo(*this);
41 }
42 
44 {
45  warn_deprecated("ConstDensityThermo::eosType",
46  "To be removed after Cantera 2.3.");
47  return cIncompressible;
48 }
49 
51 {
52  doublereal p0 = m_spthermo->refPressure();
53  return RT() * mean_X(enthalpy_RT()) + (pressure() - p0)/molarDensity();
54 }
55 
57 {
58  return GasConstant * (mean_X(entropy_R()) - sum_xlogx());
59 }
60 
61 doublereal ConstDensityThermo::cp_mole() const
62 {
63  return GasConstant * mean_X(cp_R());
64 }
65 
66 doublereal ConstDensityThermo::cv_mole() const
67 {
68  return cp_mole();
69 }
70 
71 doublereal ConstDensityThermo::pressure() const
72 {
73  return m_press;
74 }
75 
77 {
78  m_press = p;
79 }
80 
82 {
84 }
85 
87 {
88  for (size_t k = 0; k < m_kk; k++) {
89  ac[k] = 1.0;
90  }
91 }
92 
94 {
95  return molarDensity();
96 }
97 
98 void ConstDensityThermo::getChemPotentials(doublereal* mu) const
99 {
100  doublereal vdp = (pressure() - m_spthermo->refPressure())/
101  molarDensity();
102  const vector_fp& g_RT = gibbs_RT();
103  for (size_t k = 0; k < m_kk; k++) {
104  double xx = std::max(SmallNumber, moleFraction(k));
105  mu[k] = RT()*(g_RT[k] + log(xx)) + vdp;
106  }
107 }
108 
109 
111 {
112  getPureGibbs(mu0);
113 }
114 
115 bool ConstDensityThermo::addSpecies(shared_ptr<Species> spec)
116 {
117  bool added = ThermoPhase::addSpecies(spec);
118  if (added) {
119  m_h0_RT.push_back(0.0);
120  m_g0_RT.push_back(0.0);
121  m_cp0_R.push_back(0.0);
122  m_s0_R.push_back(0.0);
123  }
124  return added;
125 }
126 
128 {
129  doublereal tnow = temperature();
130  if (m_tlast != tnow) {
131  m_spthermo->update(tnow, &m_cp0_R[0], &m_h0_RT[0],
132  &m_s0_R[0]);
133  m_tlast = tnow;
134  for (size_t k = 0; k < m_kk; k++) {
135  m_g0_RT[k] = m_h0_RT[k] - m_s0_R[k];
136  }
137  m_tlast = tnow;
138  }
139 }
140 
142 {
143  eosdata._require("model","Incompressible");
144  doublereal rho = getFloat(eosdata, "density", "toSI");
145  setDensity(rho);
146 }
147 
148 }
virtual bool addSpecies(shared_ptr< Species > spec)
virtual void getPureGibbs(doublereal *gpure) const
Get the Gibbs functions for the standard state of the species at the current T and P of the solution...
vector_fp m_s0_R
Temporary storage for dimensionless reference state entropies.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
doublereal temperature() const
Temperature (K).
Definition: Phase.h:601
virtual void update(doublereal T, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Compute the reference-state properties for all species.
doublereal moleFraction(size_t k) const
Return the mole fraction of a single species.
Definition: Phase.cpp:547
doublereal sum_xlogx() const
Evaluate .
Definition: Phase.cpp:700
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
vector_fp m_h0_RT
Temporary storage for dimensionless reference state enthalpies.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
virtual doublereal refPressure(size_t k=npos) const
The reference-state pressure for species k.
Header for a Thermo manager for incompressible ThermoPhases (see Thermodynamic Properties and ConstDe...
doublereal m_tlast
last value of the temperature processed by reference state
Definition: ThermoPhase.h:1737
doublereal m_press
Current pressure (Pa)
doublereal mean_X(const doublereal *const Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
Definition: Phase.cpp:690
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
Definition: ThermoPhase.h:809
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
const vector_fp & enthalpy_RT() const
Returns a reference to the vector of nondimensional enthalpies of the reference state at the current ...
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
void _require(const std::string &a, const std::string &v) const
Require that the current XML node have an attribute named by the first argument, a, and that this attribute have the the string value listed in the second argument, v.
Definition: xml.cpp:576
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
doublereal molarDensity() const
Molar density (kmol/m^3).
Definition: Phase.cpp:666
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
const vector_fp & entropy_R() const
Returns a reference to the vector of nondimensional entropies of the reference state at the current t...
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
virtual int eosType() const
Equation of state type flag.
virtual bool addSpecies(shared_ptr< Species > spec)
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
MultiSpeciesThermo * m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
Definition: ThermoPhase.h:1693
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
const vector_fp & cp_R() const
Returns a reference to the vector of nondimensional constant pressure heat capacities of the referenc...
const doublereal SmallNumber
smallest number to compare to zero.
Definition: ct_defs.h:126
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:157
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:64
virtual void getStandardChemPotentials(doublereal *mu0) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
doublereal getFloat(const XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
Definition: ctml.cpp:178
virtual doublereal standardConcentration(size_t k=0) const
Returns the standard Concentration in units of m3 kmol-1.
size_t m_kk
Number of species in the phase.
Definition: Phase.h:784
vector_fp m_g0_RT
Temporary storage for dimensionless reference state Gibbs energies.
Namespace for the Cantera kernel.
Definition: application.cpp:29
void getConcentrations(doublereal *const c) const
Get the species concentrations (kmol/m^3).
Definition: Phase.cpp:595
vector_fp m_cp0_R
Temporary storage for dimensionless reference state heat capacities.
const vector_fp & gibbs_RT() const
Returns a reference to the vector of nondimensional Gibbs Free Energies of the reference state at the...
void _updateThermo() const
Function to update the reference state thermo functions.
virtual void setDensity(const doublereal density_)
Set the internally stored density (kg/m^3) of the phase.
Definition: Phase.h:622