Cantera
2.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
thermo
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
9
#include "
cantera/base/ct_defs.h
"
10
#include "cantera/thermo/mix_defs.h"
11
#include "
cantera/thermo/ConstDensityThermo.h
"
12
#include "
cantera/thermo/SpeciesThermo.h
"
13
14
#include <cmath>
15
16
using namespace
ctml;
17
18
namespace
Cantera
19
{
20
21
ConstDensityThermo::ConstDensityThermo() : m_tlast(0.0)
22
{
23
}
24
25
26
ConstDensityThermo::ConstDensityThermo
(
const
ConstDensityThermo
& right)
27
: m_tlast(0.0)
28
{
29
*
this
=
operator=
(right);
30
}
31
32
ConstDensityThermo
&
ConstDensityThermo::operator=
(
const
ConstDensityThermo
& right)
33
{
34
if
(&right ==
this
) {
35
return
*
this
;
36
}
37
38
m_mm
= right.
m_mm
;
39
m_tmin
= right.
m_tmin
;
40
m_tmax
= right.
m_tmax
;
41
m_p0
= right.
m_p0
;
42
m_tlast
= right.
m_tlast
;
43
m_h0_RT
= right.
m_h0_RT
;
44
m_cp0_R
= right.
m_cp0_R
;
45
m_g0_RT
= right.
m_g0_RT
;
46
m_s0_R
= right.
m_s0_R
;
47
m_expg0_RT
= right.
m_expg0_RT
;
48
m_pe
= right.
m_pe
;
49
m_pp
= right.
m_pp
;
50
51
return
*
this
;
52
53
}
54
55
SpeciesThermo
*
ConstDensityThermo::duplMyselfAsSpeciesThermo
()
const
56
{
57
ConstDensityThermo
* cdt =
new
ConstDensityThermo
(*
this
);
58
return
(
SpeciesThermo
*) cdt;
59
}
60
int
ConstDensityThermo::
61
eosType
()
const
62
{
63
return
cIncompressible;
64
}
65
66
doublereal
ConstDensityThermo::enthalpy_mole
()
const
67
{
68
doublereal p0 =
m_spthermo
->
refPressure
();
69
return
GasConstant
*
temperature
() *
70
mean_X
(&
enthalpy_RT
()[0])
71
+ (
pressure
() - p0)/
molarDensity
();
72
}
73
74
doublereal
ConstDensityThermo::intEnergy_mole
()
const
75
{
76
doublereal p0 =
m_spthermo
->
refPressure
();
77
return
GasConstant
*
temperature
() *
78
mean_X
(&
enthalpy_RT
()[0])
79
- p0/
molarDensity
();
80
}
81
82
doublereal
ConstDensityThermo::entropy_mole
()
const
83
{
84
return
GasConstant
* (
mean_X
(&
entropy_R
()[0]) -
85
sum_xlogx
());
86
}
87
88
doublereal
ConstDensityThermo::gibbs_mole
()
const
89
{
90
return
enthalpy_mole
() -
temperature
() *
entropy_mole
();
91
}
92
93
doublereal
ConstDensityThermo::cp_mole
()
const
94
{
95
return
GasConstant
*
mean_X
(&
cp_R
()[0]);
96
}
97
98
doublereal
ConstDensityThermo::cv_mole
()
const
99
{
100
return
cp_mole
();
101
}
102
103
doublereal
ConstDensityThermo::pressure
()
const
104
{
105
return
m_press
;
106
}
107
108
void
ConstDensityThermo::setPressure
(doublereal p)
109
{
110
m_press
= p;
111
}
112
113
void
ConstDensityThermo::getActivityConcentrations
(doublereal* c)
const
114
{
115
getConcentrations
(c);
116
}
117
118
void
ConstDensityThermo::getActivityCoefficients
(doublereal* ac)
const
119
{
120
for
(
size_t
k = 0; k <
m_kk
; k++) {
121
ac[k] = 1.0;
122
}
123
}
124
125
doublereal
ConstDensityThermo::standardConcentration
(
size_t
k)
const
126
{
127
return
molarDensity
();
128
}
129
130
doublereal
ConstDensityThermo::logStandardConc
(
size_t
k)
const
131
{
132
return
log(
molarDensity
());
133
}
134
135
void
ConstDensityThermo::getChemPotentials
(doublereal* mu)
const
136
{
137
doublereal vdp = (
pressure
() -
m_spthermo
->
refPressure
())/
138
molarDensity
();
139
doublereal xx;
140
doublereal rt =
temperature
() *
GasConstant
;
141
const
vector_fp
& g_RT =
gibbs_RT
();
142
for
(
size_t
k = 0; k <
m_kk
; k++) {
143
xx =
std::max
(
SmallNumber
,
moleFraction
(k));
144
mu[k] = rt*(g_RT[k] + log(xx)) + vdp;
145
}
146
}
147
148
149
void
ConstDensityThermo::getStandardChemPotentials
(doublereal* mu0)
const
150
{
151
getPureGibbs
(mu0);
152
}
153
154
void
ConstDensityThermo::initThermo
()
155
{
156
m_kk
=
nSpecies
();
157
m_mm
=
nElements
();
158
doublereal tmin =
m_spthermo
->
minTemp
();
159
doublereal tmax =
m_spthermo
->
maxTemp
();
160
if
(tmin > 0.0) {
161
m_tmin
= tmin;
162
}
163
if
(tmax > 0.0) {
164
m_tmax
= tmax;
165
}
166
m_p0
=
refPressure
();
167
168
m_h0_RT
.resize(
m_kk
);
169
m_g0_RT
.resize(
m_kk
);
170
m_expg0_RT
.resize(
m_kk
);
171
m_cp0_R
.resize(
m_kk
);
172
m_s0_R
.resize(
m_kk
);
173
m_pe
.resize(
m_kk
, 0.0);
174
m_pp
.resize(
m_kk
);
175
}
176
177
178
void
ConstDensityThermo::setToEquilState
(
const
doublereal* lambda_RT)
179
{
180
throw
CanteraError
(
"setToEquilState"
,
"not yet impl."
);
181
}
182
183
void
ConstDensityThermo::_updateThermo
()
const
184
{
185
doublereal tnow =
temperature
();
186
if
(
m_tlast
!= tnow) {
187
m_spthermo
->
update
(tnow, &
m_cp0_R
[0], &
m_h0_RT
[0],
188
&
m_s0_R
[0]);
189
m_tlast
= tnow;
190
for
(
size_t
k = 0; k <
m_kk
; k++) {
191
m_g0_RT
[k] =
m_h0_RT
[k] -
m_s0_R
[k];
192
}
193
m_tlast
= tnow;
194
}
195
}
196
197
void
ConstDensityThermo::setParametersFromXML
(
const
XML_Node
& eosdata)
198
{
199
eosdata.
_require
(
"model"
,
"Incompressible"
);
200
doublereal rho =
getFloat
(eosdata,
"density"
,
"toSI"
);
201
setDensity
(rho);
202
}
203
204
}
205
206
207
208
Generated by
1.8.2