Cantera 2.6.0

FlowDevice.cpp
Go to the documentation of this file.
1//! @file FlowDevice.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
6#include "cantera/zeroD/FlowDevice.h"
7#include "cantera/zeroD/ReactorBase.h"
8#include "cantera/thermo/ThermoPhase.h"
9#include "cantera/numerics/Func1.h"
10
11 namespace Cantera
12{
13
14FlowDevice::FlowDevice() : m_mdot(Undef), m_pfunc(0), m_tfunc(0),
15 m_coeff(1.0), m_nspin(0), m_nspout(0),
16 m_in(0), m_out(0) {}
17
18 bool FlowDevice::install(ReactorBase& in, ReactorBase& out)
19{
20 if (m_in || m_out) {
21 throw CanteraError("FlowDevice::install", "Already installed");
22 }
23 m_in = &in;
24 m_out = &out;
25 m_in->addOutlet(*this);
26 m_out->addInlet(*this);
27
28 // construct adapters between inlet and outlet species
29 const ThermoPhase& mixin = m_in->contents();
30 const ThermoPhase& mixout = m_out->contents();
31
32 m_nspin = mixin.nSpecies();
33 m_nspout = mixout.nSpecies();
34 std::string nm;
35 size_t ki, ko;
36 for (ki = 0; ki < m_nspin; ki++) {
37 nm = mixin.speciesName(ki);
38 ko = mixout.speciesIndex(nm);
39 m_in2out.push_back(ko);
40 }
41 for (ko = 0; ko < m_nspout; ko++) {
42 nm = mixout.speciesName(ko);
43 ki = mixin.speciesIndex(nm);
44 m_out2in.push_back(ki);
45 }
46 return true;
47}
48
49 void FlowDevice::setPressureFunction(Func1* f)
50{
51 m_pfunc = f;
52}
53
54 void FlowDevice::setTimeFunction(Func1* g)
55{
56 m_tfunc = g;
57}
58
59 double FlowDevice::outletSpeciesMassFlowRate(size_t k)
60{
61 if (k >= m_nspout) {
62 return 0.0;
63 }
64 size_t ki = m_out2in[k];
65 if (ki == npos) {
66 return 0.0;
67 }
68 return m_mdot * m_in->massFraction(ki);
69}
70
71 double FlowDevice::enthalpy_mass()
72{
73 return m_in->enthalpy_mass();
74}
75
76}
FlowDevice.h
Func1.h
ReactorBase.h
ThermoPhase.h
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
Cantera::Func1
Base class for 'functor' classes that evaluate a function of one variable.
Definition: Func1.h:44
Cantera::Phase::nSpecies
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:273
Cantera::Phase::speciesName
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:200
Cantera::Phase::speciesIndex
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
Definition: Phase.cpp:187
Cantera::ReactorBase
Base class for stirred reactors.
Definition: ReactorBase.h:49
Cantera::ReactorBase::addOutlet
void addOutlet(FlowDevice &outlet)
Connect an outlet FlowDevice to this reactor.
Definition: ReactorBase.cpp:53
Cantera::ThermoPhase
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:102
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::npos
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:192
Cantera::Undef
const double Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
Definition: ct_defs.h:161