Cantera  3.1.0
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
9
10namespace Cantera
11{
12
13bool WallBase::setDefaultName(map<string, int>& counts)
14{
15 if (m_defaultNameSet) {
16 return false;
17 }
18 m_defaultNameSet = true;
19 if (m_name == "(none)" || m_name == "") {
20 m_name = fmt::format("{}_{}", type(), counts[type()]);
21 }
22 counts[type()]++;
23 return true;
24}
25
27{
28 // check if wall is already installed
29 if (m_left || m_right) {
30 return false;
31 }
32 m_left = &rleft;
33 m_right = &rright;
34 m_left->addWall(*this, 0);
35 m_right->addWall(*this, 1);
36 return true;
37}
38
39void WallBase::setArea(double a) {
40 m_area = a;
41}
42
43double Wall::velocity() const {
44 if (m_vf) {
45 return m_vf->eval(m_time);
46 }
47 return 0.;
48}
49
51{
52 if (!ready()) {
53 throw CanteraError("Wall::expansionRate",
54 "Wall is not ready; some parameters have not been set.");
55 }
56 double rate = m_k * m_area * (m_left->pressure() - m_right->pressure());
57
58 if (m_vf) {
59 rate += m_area * m_vf->eval(m_time);
60 }
61 return rate;
62}
63
64double Wall::heatFlux() const {
65 if (m_qf) {
66 return m_qf->eval(m_time);
67 }
68 return 0.;
69}
70
72{
73 if (!ready()) {
74 throw CanteraError("Wall::heatRate",
75 "Wall is not ready; some parameters have not been set.");
76 }
77 double q1 = (m_area * m_rrth) *
78 (m_left->temperature() - m_right->temperature());
79 if (m_emiss > 0.0) {
80 double tl = m_left->temperature();
81 double tr = m_right->temperature();
82 q1 += m_emiss * m_area * StefanBoltz * (tl*tl*tl*tl - tr*tr*tr*tr);
83 }
84
85 if (m_qf) {
86 q1 += m_area * m_qf->eval(m_time);
87 }
88 return q1;
89}
90
91}
Header file for base class WallBase.
Base class for exceptions thrown by Cantera classes.
virtual double eval(double t) const
Evaluate the function.
Definition Func1.cpp:28
Base class for stirred reactors.
Definition ReactorBase.h:49
double pressure() const
Returns the current pressure (Pa) of the reactor.
void addWall(WallBase &w, int lr)
Insert a Wall between this reactor and another reactor.
double temperature() const
Returns the current temperature (K) of the reactor's contents.
bool install(ReactorBase &leftReactor, ReactorBase &rightReactor)
Install the wall between two reactors or reservoirs.
Definition Wall.cpp:26
virtual bool ready()
True if the wall is correctly configured and ready to use.
Definition Wall.h:85
bool m_defaultNameSet
true if default name has been previously set.
Definition Wall.h:109
virtual string type() const
String indicating the wall model implemented.
Definition Wall.h:32
double m_time
current reactor network time
Definition Wall.h:115
bool setDefaultName(map< string, int > &counts)
Set the default name of a wall. Returns false if it was previously set.
Definition Wall.cpp:13
virtual void setArea(double a)
Set the area [m^2].
Definition Wall.cpp:39
string m_name
Wall name.
Definition Wall.h:108
Func1 * m_vf
Velocity function.
Definition Wall.h:234
double heatFlux() const
Heat flux function evaluated at current reactor network time.
Definition Wall.cpp:64
double heatRate() override
Heat flow rate through the wall (W).
Definition Wall.cpp:71
double m_rrth
heat transfer coefficient
Definition Wall.h:228
Func1 * m_qf
Heat flux function.
Definition Wall.h:237
double m_k
expansion rate coefficient
Definition Wall.h:225
double velocity() const
Wall velocity at current reactor network time.
Definition Wall.cpp:43
double expansionRate() override
Rate of volume change (m^3/s) for the adjacent reactors.
Definition Wall.cpp:50
double m_emiss
emissivity
Definition Wall.h:231
const double StefanBoltz
Stefan-Boltzmann constant [W/m2/K4].
Definition ct_defs.h:128
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
Contains declarations for string manipulation functions within Cantera.