Cantera
2.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
transport
SolidTransport.cpp
Go to the documentation of this file.
1
/**
2
* @file SolidTransport.cpp
3
* Definition file for the class SolidTransport, which handles transport
4
* of ions within solid phases
5
* (see \ref tranprops and \link Cantera::SolidTransport SolidTransport \endlink).
6
*/
7
// copyright 2008 California Institute of Technology
8
9
#include "
cantera/thermo/ThermoPhase.h
"
10
#include "
cantera/transport/SolidTransport.h
"
11
12
#include "
cantera/base/utilities.h
"
13
#include <iostream>
14
15
using namespace
std;
16
17
namespace
Cantera
18
{
19
20
//====================================================================================================================
21
SolidTransport::SolidTransport() :
22
Transport
() ,
23
m_nmobile(0),
24
m_Adiff(0),
25
m_Ndiff(0),
26
m_Ediff(0),
27
m_sp(0),
28
m_Alam(0),
29
m_Nlam(0),
30
m_Elam(0)
31
{
32
}
33
//====================================================================================================================
34
SolidTransport::~SolidTransport
()
35
{
36
}
37
//====================================================================================================================
38
SolidTransport::SolidTransport
(
const
SolidTransport
& right) :
39
Transport
(),
40
m_nmobile(0),
41
m_Adiff(0),
42
m_Ndiff(0),
43
m_Ediff(0),
44
m_sp(0),
45
m_Alam(0),
46
m_Nlam(0),
47
m_Elam(0)
48
{
49
/*
50
* Use the assignment operator to do the brunt
51
* of the work for the copy constructor.
52
*/
53
*
this
= right;
54
}
55
//====================================================================================================================
56
SolidTransport
&
SolidTransport::operator=
(
const
SolidTransport
& b)
57
{
58
if
(&b !=
this
) {
59
return
*
this
;
60
}
61
Transport::operator=
(b);
62
63
m_nmobile
= b.
m_nmobile
;
64
m_Adiff
= b.
m_Adiff
;
65
m_Ndiff
= b.
m_Ndiff
;
66
m_Ediff
= b.
m_Ediff
;
67
m_sp
= b.
m_sp
;
68
m_Alam
= b.
m_Alam
;
69
m_Nlam
= b.
m_Nlam
;
70
m_Elam
= b.
m_Elam
;
71
72
return
*
this
;
73
}
74
//====================================================================================================================
75
Transport
*
SolidTransport::duplMyselfAsTransport
()
const
76
{
77
SolidTransport
* tr =
new
SolidTransport
(*
this
);
78
return
(dynamic_cast<Transport*>(tr));
79
}
80
//====================================================================================================================
81
void
SolidTransport::setParameters
(
const
int
n,
const
int
k,
const
doublereal*
const
p)
82
{
83
switch
(n) {
84
85
case
0:
86
// set the Arrhenius parameters for the diffusion coefficient
87
// of species k.
88
m_sp
.push_back(k);
89
m_Adiff
.push_back(p[0]);
90
m_Ndiff
.push_back(p[1]);
91
m_Ediff
.push_back(p[2]);
92
m_nmobile
=
m_sp
.size();
93
break
;
94
95
case
1:
96
// set the thermal conductivity Arrhenius parameters.
97
m_Alam
= p[0];
98
m_Nlam
= p[2];
99
m_Elam
= p[2];
100
break
;
101
102
default
:
103
;
104
}
105
106
m_work
.resize(
m_thermo
->
nSpecies
());
107
}
108
//====================================================================================================================
109
/*
110
* Compute the mobilities of the species from the diffusion coefficients,
111
* using the Einstein relation.
112
*/
113
void
SolidTransport::getMobilities
(doublereal*
const
mobil)
114
{
115
getMixDiffCoeffs
(mobil);
116
doublereal t =
m_thermo
->
temperature
();
117
doublereal c1 = ElectronCharge / (
Boltzmann
* t);
118
for
(
size_t
k = 0; k <
m_thermo
->
nSpecies
(); k++) {
119
mobil[k] *= c1;
120
}
121
}
122
//====================================================================================================================
123
/*
124
* Thermal Conductivity.
125
* \f[
126
* \lambda = A T^n \exp(-E/RT)
127
* \f]
128
*/
129
doublereal
SolidTransport::thermalConductivity
()
130
{
131
doublereal t =
m_thermo
->
temperature
();
132
return
m_Alam
* pow(t,
m_Nlam
) * exp(-
m_Elam
/t);
133
}
134
//====================================================================================================================
135
/*
136
* The diffusion coefficients are computed from
137
*
138
* \f[
139
* D_k = A_k T^{n_k} \exp(-E_k/RT).
140
* \f]
141
*
142
* The diffusion coefficients are only non-zero for species for
143
* which parameters have been specified using method
144
* setParameters.
145
*/
146
void
SolidTransport::getMixDiffCoeffs
(doublereal*
const
d)
147
{
148
doublereal temp =
m_thermo
->
temperature
();
149
size_t
nsp =
m_thermo
->
nSpecies
();
150
for
(
size_t
k = 0; k < nsp; k++) {
151
d[k] = 0.0;
152
}
153
for
(
size_t
k = 0; k <
m_nmobile
; k++) {
154
d[
m_sp
[k]] =
155
m_Adiff
[k] * pow(temp,
m_Ndiff
[k]) * exp(-
m_Ediff
[k]/temp);
156
}
157
}
158
//====================================================================================================================
159
doublereal
SolidTransport::electricalConductivity
()
160
{
161
getMobilities
(&
m_work
[0]);
162
size_t
nsp =
m_thermo
->
nSpecies
();
163
doublereal sum = 0.0;
164
for
(
size_t
k = 0; k < nsp; k++) {
165
sum +=
m_thermo
->
charge
(k) *
m_thermo
->
moleFraction
(k) *
m_work
[k];
166
}
167
return
sum *
m_thermo
->
molarDensity
();
168
}
169
//====================================================================================================================
170
}
Generated by
1.8.2