Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // Copyright 2002 California Institute of Technology
11 #include "cantera/base/ctml.h"
12 
13 namespace Cantera
14 {
15 
17 {
18  *this = right;
19 }
20 
22 {
23  if (&right == this) {
24  return *this;
25  }
26 
27  m_h0_RT = right.m_h0_RT;
28  m_cp0_R = right.m_cp0_R;
29  m_g0_RT = right.m_g0_RT;
30  m_s0_R = right.m_s0_R;
31  m_pp = right.m_pp;
32 
33  return *this;
34 
35 }
36 
38 {
39  return new ConstDensityThermo(*this);
40 }
41 
43 {
44  return cIncompressible;
45 }
46 
48 {
49  doublereal p0 = m_spthermo->refPressure();
50  return GasConstant * temperature() *
51  mean_X(enthalpy_RT()) + (pressure() - p0)/molarDensity();
52 }
53 
55 {
56  return GasConstant * (mean_X(entropy_R()) - sum_xlogx());
57 }
58 
59 doublereal ConstDensityThermo::cp_mole() const
60 {
61  return GasConstant * mean_X(cp_R());
62 }
63 
64 doublereal ConstDensityThermo::cv_mole() const
65 {
66  return cp_mole();
67 }
68 
69 doublereal ConstDensityThermo::pressure() const
70 {
71  return m_press;
72 }
73 
75 {
76  m_press = p;
77 }
78 
80 {
82 }
83 
85 {
86  for (size_t k = 0; k < m_kk; k++) {
87  ac[k] = 1.0;
88  }
89 }
90 
92 {
93  return molarDensity();
94 }
95 
96 void ConstDensityThermo::getChemPotentials(doublereal* mu) const
97 {
98  doublereal vdp = (pressure() - m_spthermo->refPressure())/
99  molarDensity();
100  doublereal rt = temperature() * GasConstant;
101  const vector_fp& g_RT = gibbs_RT();
102  for (size_t k = 0; k < m_kk; k++) {
103  double xx = std::max(SmallNumber, moleFraction(k));
104  mu[k] = rt*(g_RT[k] + log(xx)) + vdp;
105  }
106 }
107 
108 
110 {
111  getPureGibbs(mu0);
112 }
113 
115 {
117  m_h0_RT.resize(m_kk);
118  m_g0_RT.resize(m_kk);
119  m_cp0_R.resize(m_kk);
120  m_s0_R.resize(m_kk);
121  m_pp.resize(m_kk);
122 }
123 
124 
125 void ConstDensityThermo::setToEquilState(const doublereal* lambda_RT)
126 {
127  throw CanteraError("setToEquilState","not yet impl.");
128 }
129 
131 {
132  doublereal tnow = temperature();
133  if (m_tlast != tnow) {
134  m_spthermo->update(tnow, &m_cp0_R[0], &m_h0_RT[0],
135  &m_s0_R[0]);
136  m_tlast = tnow;
137  for (size_t k = 0; k < m_kk; k++) {
138  m_g0_RT[k] = m_h0_RT[k] - m_s0_R[k];
139  }
140  m_tlast = tnow;
141  }
142 }
143 
145 {
146  eosdata._require("model","Incompressible");
147  doublereal rho = getFloat(eosdata, "density", "toSI");
148  setDensity(rho);
149 }
150 
151 }
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:603
vector_fp m_s0_R
Temporary storage for dimensionless reference state entropies.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
virtual void setToEquilState(const doublereal *lambda_RT)
This method is used by the ChemEquil equilibrium solver.
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
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...
const vector_fp & cp_R() const
Returns a reference to the vector of nondimensional constant pressure heat capacities of the referenc...
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
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:100
vector_fp m_h0_RT
Temporary storage for dimensionless reference state enthalpies.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
doublereal molarDensity() const
Molar density (kmol/m^3).
Definition: Phase.cpp:663
Header for a Thermo manager for incompressible ThermoPhases (see Thermodynamic Properties and ConstDe...
void getConcentrations(doublereal *const c) const
Get the species concentrations (kmol/m^3).
Definition: Phase.cpp:609
doublereal m_tlast
last value of the temperature processed by reference state
Definition: ThermoPhase.h:1656
doublereal m_press
Current pressure (Pa)
vector_fp m_pp
Temporary array containing internally calculated partial pressures.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
doublereal mean_X(const doublereal *const Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
Definition: Phase.cpp:687
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
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 sum_xlogx() const
Evaluate .
Definition: Phase.cpp:703
void _updateThermo() const
Function to update the reference state thermo functions.
virtual doublereal refPressure(size_t k=npos) const =0
The reference-state pressure for species k.
Overloads the virtual methods of class ThermoPhase to implement the incompressible equation of state...
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
const vector_fp & enthalpy_RT() const
Returns a reference to the vector of nondimensional enthalpies of the reference state at the current ...
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
doublereal moleFraction(size_t k) const
Return the mole fraction of a single species.
Definition: Phase.cpp:561
const vector_fp & gibbs_RT() const
Returns a reference to the vector of nondimensional Gibbs Free Energies of the reference state at the...
doublereal temperature() const
Temperature (K).
Definition: Phase.h:602
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 int eosType() const
Returns a constant corresponding to this class's equation of state.
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:64
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
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:194
ConstDensityThermo & operator=(const ConstDensityThermo &right)
Assignment Operator.
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 entropy_mole() const
Molar entropy. Units: J/kmol/K.
size_t m_kk
Number of species in the phase.
Definition: Phase.h:843
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
virtual void update(doublereal T, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const =0
Compute the reference-state properties for all species.
vector_fp m_g0_RT
Temporary storage for dimensionless reference state Gibbs energies.
vector_fp m_cp0_R
Temporary storage for dimensionless reference state heat capacities.
SpeciesThermo * m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
Definition: ThermoPhase.h:1607
virtual void setDensity(const doublereal density_)
Set the internally stored density (kg/m^3) of the phase Note the density of a phase is an independent...
Definition: Phase.h:623
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.