Cantera  2.5.1
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 https://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 
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 }
Cantera::ThermoPhase::enthalpy_mass
doublereal enthalpy_mass() const
Specific enthalpy. Units: J/kg.
Definition: ThermoPhase.h:742
Cantera::ReactorBase::inlet
FlowDevice & inlet(size_t n=0)
Return a reference to the n-th inlet FlowDevice connected to this reactor.
Definition: ReactorBase.cpp:109
Cantera::FlowDevice
Base class for 'flow devices' (valves, pressure regulators, etc.) connecting reactors.
Definition: FlowDevice.h:30
Cantera::ReactorBase::addOutlet
void addOutlet(FlowDevice &outlet)
Connect an outlet FlowDevice to this reactor.
Definition: ReactorBase.cpp:52
Cantera::ReactorBase::mass
doublereal mass() const
Returns the mass (kg) of the reactor's contents.
Definition: ReactorBase.h:238
Cantera::ReactorBase::wall
WallBase & wall(size_t n)
Return a reference to the n-th Wall connected to this reactor.
Definition: ReactorBase.cpp:67
Cantera::ReactorBase::syncState
virtual void syncState()
Set the state of the reactor to correspond to the state of the associated ThermoPhase object.
Definition: ReactorBase.cpp:36
Cantera::ThermoPhase::intEnergy_mass
doublereal intEnergy_mass() const
Specific internal energy. Units: J/kg.
Definition: ThermoPhase.h:747
FlowDevice.h
Cantera::ReactorBase::outlet
FlowDevice & outlet(size_t n=0)
Return a reference to the n-th outlet FlowDevice connected to this reactor.
Definition: ReactorBase.cpp:113
ReactorBase.h
Cantera::ReactorNet::setNeedsReinit
void setNeedsReinit()
Called to trigger integrator reinitialization before further integration.
Definition: ReactorNet.h:229
Cantera::ReactorBase::setNetwork
void setNetwork(ReactorNet *net)
Set the ReactorNet that this reactor belongs to.
Definition: ReactorBase.cpp:95
Cantera::ReactorBase::residenceTime
doublereal residenceTime()
Return the residence time (s) of the contents of this reactor, based on the outlet mass flow rates an...
Definition: ReactorBase.cpp:100
Cantera::ReactorBase::m_nsp
size_t m_nsp
Number of homogeneous species in the mixture.
Definition: ReactorBase.h:262
Cantera::ReactorBase::surface
ReactorSurface * surface(size_t n)
Return a reference to the n-th ReactorSurface connected to this reactor.
Definition: ReactorBase.cpp:80
Cantera::ReactorBase::m_net
ReactorNet * m_net
The ReactorNet that this reactor is part of.
Definition: ReactorBase.h:278
Cantera::ReactorBase::addWall
void addWall(WallBase &w, int lr)
Insert a Wall between this reactor and another reactor.
Definition: ReactorBase.cpp:57
ReactorNet.h
Cantera::Phase::saveState
void saveState(vector_fp &state) const
Save the current internal state of the phase.
Definition: Phase.cpp:315
Cantera::ThermoPhase
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
Cantera::ReactorBase::name
std::string name() const
Return the name of this reactor.
Definition: ReactorBase.h:72
Cantera::Phase::pressure
virtual double pressure() const
Return the thermodynamic pressure (Pa).
Definition: Phase.h:679
Cantera::Phase::nSpecies
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:285
Cantera::WallBase
Base class for 'walls' (walls, pistons, etc.) connecting reactors.
Definition: Wall.h:28
ReactorSurface.h
Cantera::ReactorBase::network
ReactorNet & network()
The ReactorNet that this reactor belongs to.
Definition: ReactorBase.cpp:85
Cantera::ReactorNet
A class representing a network of connected reactors.
Definition: ReactorNet.h:23
Cantera::ReactorBase::setThermoMgr
virtual void setThermoMgr(thermo_t &thermo)
Specify the mixture contained in the reactor.
Definition: ReactorBase.cpp:26
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:60
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:263
Cantera::ReactorBase::addInlet
void addInlet(FlowDevice &inlet)
Connect an inlet FlowDevice to this reactor.
Definition: ReactorBase.cpp:47