Cantera  2.1.2
ReactorBase.cpp
Go to the documentation of this file.
1 /**
2  * @file ReactorBase.cpp
3  */
4 
5 // Copyright 2001 California Institute of Technology
6 
9 #include "cantera/zeroD/Wall.h"
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_vol0(1.0),
19  m_init(false),
20  m_nInlets(0),
21  m_nOutlets(0),
22  m_open(false),
23  m_enthalpy(0.0),
24  m_intEnergy(0.0),
25  m_pressure(0.0),
26  m_nwalls(0),
27  m_net(0)
28 {
29  m_name = name;
30 }
31 
33 {
34  m_thermo = &thermo;
35  m_nsp = m_thermo->nSpecies();
36  m_thermo->saveState(m_state);
37  m_enthalpy = m_thermo->enthalpy_mass();
38  m_intEnergy = m_thermo->intEnergy_mass();
39  m_pressure = m_thermo->pressure();
40 }
41 
43 {
44  m_inlet.push_back(&inlet);
45  m_open = true;
46  m_nInlets++;
47 }
48 
50 {
51  m_outlet.push_back(&outlet);
52  m_open = true;
53  m_nOutlets++;
54 }
55 
56 void ReactorBase::addWall(Wall& w, int lr)
57 {
58  m_wall.push_back(&w);
59  if (lr == 0) {
60  m_lr.push_back(0);
61  } else {
62  m_lr.push_back(1);
63  }
64  m_nwalls++;
65 }
66 
68 {
69  return *m_wall[n];
70 }
71 
73 {
74  if (m_net) {
75  return *m_net;
76  } else {
77  throw CanteraError("ReactorBase::network",
78  "Reactor is not part of a ReactorNet");
79  }
80 }
81 
83 {
84  m_net = net;
85 }
86 
88 {
89  int nout = static_cast<int>(m_outlet.size());
90  doublereal mout = 0.0;
91  for (int i = 0; i < nout; i++) {
92  mout += m_outlet[i]->massFlowRate();
93  }
94  return mass()/mout;
95 }
96 
98 {
99  return *m_inlet[n];
100 }
102 {
103  return *m_outlet[n];
104 }
105 
106 }
A class representing a network of connected reactors.
Definition: ReactorNet.h:23
Header file for class Wall.
Base class for 'flow devices' (valves, pressure regulators, etc.) connecting reactors.
Definition: FlowDevice.h:28
ReactorNet * m_net
The ReactorNet that this reactor is part of.
Definition: ReactorBase.h:232
ReactorNet & network()
The ReactorNet that this reactor belongs to.
Definition: ReactorBase.cpp:72
void addOutlet(FlowDevice &outlet)
Connect an outlet FlowDevice to this reactor.
Definition: ReactorBase.cpp:49
void addInlet(FlowDevice &inlet)
Connect an inlet FlowDevice to this reactor.
Definition: ReactorBase.cpp:42
doublereal intEnergy_mass() const
Specific internal energy.
Definition: ThermoPhase.h:940
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
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:29
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:68
void addWall(Wall &w, int lr)
Insert a Wall between this reactor and another reactor.
Definition: ReactorBase.cpp:56
virtual void setThermoMgr(thermo_t &thermo)
Specify the mixture contained in the reactor.
Definition: ReactorBase.cpp:32
std::string name() const
Return the name of this reactor.
Definition: ReactorBase.h:42
FlowDevice & inlet(size_t n=0)
Return a reference to the n-th inlet FlowDevice connected to this reactor.
Definition: ReactorBase.cpp:97
void setNetwork(ReactorNet *net)
Set the ReactorNet that this reactor belongs to.
Definition: ReactorBase.cpp:82
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:252
doublereal residenceTime()
Return the residence time (s) of the contents of this reactor, based on the outlet mass flow rates an...
Definition: ReactorBase.cpp:87
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
Definition: ThermoPhase.h:314
doublereal mass() const
Returns the mass (kg) of the reactor's contents.
Definition: ReactorBase.h:184
doublereal enthalpy_mass() const
Specific enthalpy.
Definition: ThermoPhase.h:933
size_t m_nsp
Number of homogeneous species in the mixture.
Definition: ReactorBase.h:213
void saveState(vector_fp &state) const
Save the current internal state of the phase Write to vector 'state' the current internal state...
Definition: Phase.cpp:277
FlowDevice & outlet(size_t n=0)
Return a reference to the n-th outlet FlowDevice connected to this reactor.