Cantera
Install
User Guide
Examples
Reference
Develop
Community
4.0.0a2
Toggle main menu visibility
Loading...
Searching...
No Matches
Wall.cpp
Go to the documentation of this file.
1
//! @file Wall.cpp
2
3
// This file is part of Cantera. See License.txt in the top-level directory or
4
// at https://cantera.org/license.txt for license and copyright information.
5
6
#include "
cantera/base/stringUtils.h
"
7
#include "
cantera/numerics/Func1.h
"
8
#include "
cantera/zeroD/Wall.h
"
9
10
namespace
Cantera
11
{
12
13
WallBase::WallBase(shared_ptr<ReactorBase> r0, shared_ptr<ReactorBase> r1,
14
const
string
& name) :
ConnectorNode
(r0, r1, name)
15
{
16
if
(!m_nodes.first || !m_nodes.second) {
17
throw CanteraError(
"WallBase::WallBase"
,
18
"Reactors must be provided to WallBase constructor."
);
19
}
20
m_left = r0.get();
21
m_right = r1.get();
22
m_left->addWall(*
this
, 0);
23
m_right->addWall(*
this
, 1);
24
}
25
26
void
WallBase::setArea
(
double
a) {
27
m_area = a;
28
}
29
30
double
Wall::velocity
()
const
{
31
if
(
m_vf
) {
32
return
m_vf
->eval(
m_time
);
33
}
34
return
0.;
35
}
36
37
double
Wall::expansionRate
()
38
{
39
if
(!
ready
()) {
40
throw
CanteraError
(
"Wall::expansionRate"
,
41
"Wall is not ready; some parameters have not been set."
);
42
}
43
double
rate =
m_k
* m_area * (m_left->pressure() - m_right->pressure());
44
45
if
(
m_vf
) {
46
rate += m_area *
m_vf
->eval(
m_time
);
47
}
48
return
rate;
49
}
50
51
double
Wall::heatFlux
()
const
{
52
if
(
m_qf
) {
53
return
m_qf
->eval(
m_time
);
54
}
55
return
0.;
56
}
57
58
double
Wall::heatRate
()
59
{
60
if
(!
ready
()) {
61
throw
CanteraError
(
"Wall::heatRate"
,
62
"Wall is not ready; some parameters have not been set."
);
63
}
64
double
q1 = (m_area *
m_rrth
) *
65
(m_left->temperature() - m_right->temperature());
66
if
(
m_emiss
> 0.0) {
67
double
tl = m_left->temperature();
68
double
tr = m_right->temperature();
69
q1 +=
m_emiss
* m_area *
StefanBoltz
* (tl*tl*tl*tl - tr*tr*tr*tr);
70
}
71
72
if
(
m_qf
) {
73
q1 += m_area *
m_qf
->eval(
m_time
);
74
}
75
return
q1;
76
}
77
78
void
Wall::addExpansionRateJacobian
(
79
SparseTriplets& trips,
size_t
row,
double
coeff,
bool
includePressureSpecies)
80
{
81
double
alpha =
m_k
* m_area;
82
if
(alpha == 0.0) {
83
return
;
84
}
85
// Chain rule for expansionRate(P_left - P_right): the wall supplies
86
// d(expansionRate)/dDeltaP, while reactors supply dP/dy.
87
m_left->addPressureJacobian(trips, row, coeff * alpha, includePressureSpecies);
88
m_right->addPressureJacobian(trips, row, -coeff * alpha, includePressureSpecies);
89
}
90
91
void
Wall::addHeatRateJacobian
(SparseTriplets& trips,
size_t
row,
double
coeff)
92
{
93
double
leftCoeff = m_area *
m_rrth
;
94
double
rightCoeff = -leftCoeff;
95
if
(
m_emiss
> 0.0) {
96
leftCoeff += 4.0 *
m_emiss
* m_area *
StefanBoltz
97
* std::pow(m_left->temperature(), 3);
98
rightCoeff -= 4.0 *
m_emiss
* m_area *
StefanBoltz
99
* std::pow(m_right->temperature(), 3);
100
}
101
// Chain rule for heatRate(T_left, T_right): the wall supplies dQ/dT, while
102
// reactors supply dT/dy.
103
if
(leftCoeff != 0.0) {
104
m_left->addTemperatureJacobian(trips, row, coeff * leftCoeff);
105
}
106
if
(rightCoeff != 0.0) {
107
m_right->addTemperatureJacobian(trips, row, coeff * rightCoeff);
108
}
109
}
110
111
}
Func1.h
Wall.h
Header file for base class WallBase.
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition
ctexceptions.h:66
Cantera::ConnectorNode
Base class for walls and flow devices connecting reactors.
Definition
ConnectorNode.h:28
Cantera::WallBase::ready
virtual bool ready()
True if the wall is correctly configured and ready to use.
Definition
Wall.h:67
Cantera::WallBase::m_time
double m_time
current reactor network time
Definition
Wall.h:126
Cantera::WallBase::setArea
virtual void setArea(double a)
Set the area [m^2].
Definition
Wall.cpp:26
Cantera::Wall::addHeatRateJacobian
void addHeatRateJacobian(SparseTriplets &trips, size_t row, double coeff) override
Add Jacobian terms proportional to derivatives of the wall heat rate.
Definition
Wall.cpp:91
Cantera::Wall::m_vf
Func1 * m_vf
Velocity function.
Definition
Wall.h:252
Cantera::Wall::addExpansionRateJacobian
void addExpansionRateJacobian(SparseTriplets &trips, size_t row, double coeff, bool includePressureSpecies=true) override
Add Jacobian terms proportional to derivatives of the wall expansion rate.
Definition
Wall.cpp:78
Cantera::Wall::heatFlux
double heatFlux() const
Heat flux function evaluated at current reactor network time.
Definition
Wall.cpp:51
Cantera::Wall::heatRate
double heatRate() override
Heat flow rate through the wall (W).
Definition
Wall.cpp:58
Cantera::Wall::m_rrth
double m_rrth
heat transfer coefficient
Definition
Wall.h:246
Cantera::Wall::m_qf
Func1 * m_qf
Heat flux function.
Definition
Wall.h:255
Cantera::Wall::m_k
double m_k
expansion rate coefficient
Definition
Wall.h:243
Cantera::Wall::velocity
double velocity() const
Wall velocity at current reactor network time.
Definition
Wall.cpp:30
Cantera::Wall::expansionRate
double expansionRate() override
Rate of volume change (m^3/s) for the adjacent reactors.
Definition
Wall.cpp:37
Cantera::Wall::m_emiss
double m_emiss
emissivity
Definition
Wall.h:249
Cantera::StefanBoltz
const double StefanBoltz
Stefan-Boltzmann constant [W/m2/K4].
Definition
ct_defs.h:131
Cantera
Namespace for the Cantera kernel.
Definition
AnyMap.cpp:595
stringUtils.h
Contains declarations for string manipulation functions within Cantera.
src
zeroD
Wall.cpp
Generated by
1.17.0