Cantera  2.1.2
FlowDevice.cpp
Go to the documentation of this file.
1 //! @file FlowDevice.cpp
5 
6 namespace Cantera
7 {
8 
10 {
11  if (m_in || m_out) {
12  return false;
13  }
14  m_in = ∈
15  m_out = &out;
16  m_in->addOutlet(*this);
17  m_out->addInlet(*this);
18 
19  // construct adapters between inlet and outlet species
20  ThermoPhase* mixin = &m_in->contents();
21  ThermoPhase* mixout = &m_out->contents();
22  if (mixin == 0 || mixout == 0) {
23  return false;
24  }
25 
26  m_nspin = mixin->nSpecies();
27  m_nspout = mixout->nSpecies();
28  std::string nm;
29  size_t ki, ko;
30  for (ki = 0; ki < m_nspin; ki++) {
31  nm = mixin->speciesName(ki);
32  ko = mixout->speciesIndex(nm);
33  m_in2out.push_back(ko);
34  }
35  for (ko = 0; ko < m_nspout; ko++) {
36  nm = mixout->speciesName(ko);
37  ki = mixin->speciesIndex(nm);
38  m_out2in.push_back(ki);
39  }
40  return true;
41 }
42 
44 {
45  m_func = f;
46 }
47 
49 {
50  if (k >= m_nspout) {
51  return 0.0;
52  }
53  size_t ki = m_out2in[k];
54  if (ki == npos) {
55  return 0.0;
56  }
57  return m_mdot * m_in->massFraction(ki);
58 }
59 
61 {
62  return m_in->enthalpy_mass();
63 }
64 
65 }
doublereal enthalpy_mass() const
Returns the current enthalpy (J/kg) of the reactor's contents.
Definition: ReactorBase.h:169
void setFunction(Cantera::Func1 *f)
Set a function of a single variable that is used in determining the mass flow rate through the device...
Definition: FlowDevice.cpp:43
const ReactorBase & out() const
Return a const reference to the downstream reactor.
Definition: FlowDevice.h:82
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:173
doublereal enthalpy_mass()
specific enthalpy
Definition: FlowDevice.cpp:60
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
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
Definition: Phase.cpp:229
Base class for 'functor' classes that evaluate a function of one variable.
Definition: Func1.h:45
ReactorBase & in() const
Return a reference to the upstream reactor.
Definition: FlowDevice.h:77
Base class for stirred reactors.
Definition: ReactorBase.h:30
doublereal outletSpeciesMassFlowRate(size_t k)
Definition: FlowDevice.cpp:48
bool install(ReactorBase &in, ReactorBase &out)
Install a flow device between two reactors.
Definition: FlowDevice.cpp:9
thermo_t & contents()
return a reference to the contents.
Definition: ReactorBase.h:134
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:252
doublereal massFraction(size_t k) const
Return the mass fraction of the k-th species.
Definition: ReactorBase.h:194
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:246