Cantera  2.3.0
ReactorBase.cpp
Go to the documentation of this file.
1 //! @file ReactorBase.cpp
2 
3 // This file is part of Cantera. See License.txt in the top-level directory or
4 // at http://www.cantera.org/license.txt for license and copyright information.
5 
10 
11 using namespace std;
12 namespace Cantera
13 {
14 
15 ReactorBase::ReactorBase(const string& name) : m_nsp(0),
16  m_thermo(0),
17  m_vol(1.0),
18  m_enthalpy(0.0),
19  m_intEnergy(0.0),
20  m_pressure(0.0),
21  m_net(0)
22 {
23  m_name = name;
24 }
25 
27 {
28  m_thermo = &thermo;
29  m_nsp = m_thermo->nSpecies();
30  m_thermo->saveState(m_state);
31  m_enthalpy = m_thermo->enthalpy_mass();
32  m_intEnergy = m_thermo->intEnergy_mass();
33  m_pressure = m_thermo->pressure();
34 }
35 
37 {
38  m_thermo->saveState(m_state);
39  m_enthalpy = m_thermo->enthalpy_mass();
40  m_intEnergy = m_thermo->intEnergy_mass();
41  m_pressure = m_thermo->pressure();
42  if (m_net) {
44  }
45 }
46 
48 {
49  m_inlet.push_back(&inlet);
50 }
51 
53 {
54  m_outlet.push_back(&outlet);
55 }
56 
57 void ReactorBase::addWall(Wall& w, int lr)
58 {
59  m_wall.push_back(&w);
60  if (lr == 0) {
61  m_lr.push_back(0);
62  } else {
63  m_lr.push_back(1);
64  }
65 }
66 
68 {
69  return *m_wall[n];
70 }
71 
72 void ReactorBase::addSurface(ReactorSurface* surf)
73 {
74  if (find(m_surfaces.begin(), m_surfaces.end(), surf) == m_surfaces.end()) {
75  m_surfaces.push_back(surf);
76  surf->setReactor(this);
77  }
78 }
79 
80 ReactorSurface* ReactorBase::surface(size_t n)
81 {
82  return m_surfaces[n];
83 }
84 
86 {
87  if (m_net) {
88  return *m_net;
89  } else {
90  throw CanteraError("ReactorBase::network",
91  "Reactor is not part of a ReactorNet");
92  }
93 }
94 
96 {
97  m_net = net;
98 }
99 
101 {
102  doublereal mout = 0.0;
103  for (size_t i = 0; i < m_outlet.size(); i++) {
104  mout += m_outlet[i]->massFlowRate();
105  }
106  return mass()/mout;
107 }
108 
110 {
111  return *m_inlet[n];
112 }
114 {
115  return *m_outlet[n];
116 }
117 
118 }
A class representing a network of connected reactors.
Definition: ReactorNet.h:23
Base class for &#39;flow devices&#39; (valves, pressure regulators, etc.) connecting reactors.
Definition: FlowDevice.h:27
void saveState(vector_fp &state) const
Save the current internal state of the phase.
Definition: Phase.cpp:297
ReactorNet * m_net
The ReactorNet that this reactor is part of.
Definition: ReactorBase.h:246
ReactorNet & network()
The ReactorNet that this reactor belongs to.
Definition: ReactorBase.cpp:85
void setNeedsReinit()
Called to trigger integrator reinitialization before further integration.
Definition: ReactorNet.h:210
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:262
STL namespace.
doublereal enthalpy_mass() const
Specific enthalpy. Units: J/kg.
Definition: ThermoPhase.h:764
void addOutlet(FlowDevice &outlet)
Connect an outlet FlowDevice to this reactor.
Definition: ReactorBase.cpp:52
void addInlet(FlowDevice &inlet)
Connect an inlet FlowDevice to this reactor.
Definition: ReactorBase.cpp:47
doublereal mass() const
Returns the mass (kg) of the reactor&#39;s contents.
Definition: ReactorBase.h:207
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
Wall & wall(size_t n)
Return a reference to the n-th Wall connected to this reactor.
Definition: ReactorBase.cpp:67
Represents a wall between between two ReactorBase objects.
Definition: Wall.h:25
virtual void syncState()
Set the state of the reactor to correspond to the state of the associated ThermoPhase object...
Definition: ReactorBase.cpp:36
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
void addWall(Wall &w, int lr)
Insert a Wall between this reactor and another reactor.
Definition: ReactorBase.cpp:57
virtual void setThermoMgr(thermo_t &thermo)
Specify the mixture contained in the reactor.
Definition: ReactorBase.cpp:26
Header file for class ReactorSurface.
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
Definition: ThermoPhase.h:278
FlowDevice & inlet(size_t n=0)
Return a reference to the n-th inlet FlowDevice connected to this reactor.
void setNetwork(ReactorNet *net)
Set the ReactorNet that this reactor belongs to.
Definition: ReactorBase.cpp:95
doublereal residenceTime()
Return the residence time (s) of the contents of this reactor, based on the outlet mass flow rates an...
ReactorSurface * surface(size_t n)
Return a reference to the n-th ReactorSurface connected to this reactor.
Definition: ReactorBase.cpp:80
size_t m_nsp
Number of homogeneous species in the mixture.
Definition: ReactorBase.h:231
FlowDevice & outlet(size_t n=0)
Return a reference to the n-th outlet FlowDevice connected to this reactor.
Namespace for the Cantera kernel.
Definition: application.cpp:29
doublereal intEnergy_mass() const
Specific internal energy. Units: J/kg.
Definition: ThermoPhase.h:769
std::string name() const
Return the name of this reactor.
Definition: ReactorBase.h:56