Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ReactorBase.cpp
Go to the documentation of this file.
1 /**
2  * @file ReactorBase.cpp
3  */
4 
5 // Copyright 2001 California Institute of Technology
6 
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 
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  doublereal mout = 0.0;
90  for (size_t i = 0; i < m_outlet.size(); i++) {
91  mout += m_outlet[i]->massFlowRate();
92  }
93  return mass()/mout;
94 }
95 
97 {
98  return *m_inlet[n];
99 }
101 {
102  return *m_outlet[n];
103 }
104 
105 }
A class representing a network of connected reactors.
Definition: ReactorNet.h:23
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:231
ReactorNet & network()
The ReactorNet that this reactor belongs to.
Definition: ReactorBase.cpp:72
void setNeedsReinit()
Called to trigger integrator reinitialization before further integration.
Definition: ReactorNet.h:232
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 intEnergy_mass() const
Specific internal energy.
Definition: ThermoPhase.h:899
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
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:27
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:99
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
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:96
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:265
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:278
doublereal mass() const
Returns the mass (kg) of the reactor's contents.
Definition: ReactorBase.h:193
doublereal enthalpy_mass() const
Specific enthalpy.
Definition: ThermoPhase.h:892
size_t m_nsp
Number of homogeneous species in the mixture.
Definition: ReactorBase.h:217
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:302
FlowDevice & outlet(size_t n=0)
Return a reference to the n-th outlet FlowDevice connected to this reactor.