Cantera  2.0
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(string name) : m_nsp(0),
16  m_thermo(0),
17  m_time(0.0),
18  m_vol(1.0),
19  m_vol0(1.0),
20  m_init(false),
21  m_nInlets(0),
22  m_nOutlets(0),
23  m_open(false),
24  m_enthalpy(0.0),
25  m_intEnergy(0.0),
26  m_pressure(0.0),
27  m_nwalls(0)
28 {
29  m_name = name;
30 }
31 
32 // void ReactorBase::resetState() {
33 // m_thermo->saveState(m_state);
34 // m_enthalpy = m_thermo->enthalpy_mass();
35 // m_intEnergy = m_thermo->intEnergy_mass();
36 // m_pressure = m_thermo->pressure();
37 // m_init = false;
38 // }
39 
41 {
42  m_thermo = &thermo;
43  m_nsp = m_thermo->nSpecies();
44  m_thermo->saveState(m_state);
45  m_enthalpy = m_thermo->enthalpy_mass();
46  m_intEnergy = m_thermo->intEnergy_mass();
47  m_pressure = m_thermo->pressure();
48 }
49 
50 void ReactorBase::addInlet(FlowDevice& inlet)
51 {
52  m_inlet.push_back(&inlet);
53  m_open = true;
54  m_nInlets++;
55 }
56 
57 void ReactorBase::addOutlet(FlowDevice& outlet)
58 {
59  m_outlet.push_back(&outlet);
60  m_open = true;
61  m_nOutlets++;
62 }
63 
64 void ReactorBase::addWall(Wall& w, int lr)
65 {
66  m_wall.push_back(&w);
67  if (lr == 0) {
68  m_lr.push_back(0);
69  } else {
70  m_lr.push_back(1);
71  }
72  m_nwalls++;
73 }
74 
75 Wall& ReactorBase::wall(size_t n)
76 {
77  return *m_wall[n];
78 }
79 
80 doublereal ReactorBase::residenceTime()
81 {
82  int nout = static_cast<int>(m_outlet.size());
83  doublereal mout = 0.0;
84  for (int i = 0; i < nout; i++) {
85  mout += m_outlet[i]->massFlowRate();
86  }
87  return mass()/mout;
88 }
89 
90 FlowDevice& ReactorBase::inlet(size_t n)
91 {
92  return *m_inlet[n];
93 }
94 FlowDevice& ReactorBase::outlet(size_t n)
95 {
96  return *m_outlet[n];
97 }
98 
99 }