Update Doxygen docs for class ReactorBase and descendants

This commit is contained in:
Ray Speth 2013-06-03 22:17:05 +00:00
parent 5c2b5cbde0
commit 5a94876c91
7 changed files with 131 additions and 134 deletions

View file

@ -1,5 +1,5 @@
/**
* @file Reactor.h
* @file ConstPressureReactor.h
*/
// Copyright 2001 California Institute of Technology
@ -13,33 +13,22 @@ namespace Cantera
{
/**
* Class ConstPressureReactor is a class for constant-pressure
* reactors. The reactor may have an arbitrary number of inlets
* and outlets, each of which may be connected to a "flow device"
* such as a mass flow controller, a pressure regulator,
* etc. Additional reactors may be connected to the other end of
* the flow device, allowing construction of arbitrary reactor
* Class ConstPressureReactor is a class for constant-pressure reactors. The
* reactor may have an arbitrary number of inlets and outlets, each of which
* may be connected to a "flow device" such as a mass flow controller, a
* pressure regulator, etc. Additional reactors may be connected to the other
* end of the flow device, allowing construction of arbitrary reactor
* networks.
*
*/
class ConstPressureReactor : public Reactor
{
public:
/**
* Default constructor.
*/
ConstPressureReactor();
virtual int type() const {
return ConstPressureReactorType;
}
//-----------------------------------------------------
//virtual int neq() { return m_nv; }
virtual void getInitialConditions(doublereal t0, size_t leny,
doublereal* y);
@ -49,15 +38,14 @@ public:
virtual void updateState(doublereal* y);
//! Return the index in the solution vector for this reactor of the
//! component named *nm*. Possible values for *nm* are "m", "T", the name
//! of a homogeneous phase species, or the name of a surface species.
virtual size_t componentIndex(const std::string& nm) const;
protected:
vector_fp m_hk; //!< Species molar enthalpies
private:
};
}
#endif

View file

@ -13,33 +13,20 @@ namespace Cantera
{
/**
* Adiabatic, reversible flow in a constant-area duct.
* Adiabatic flow in a constant-area duct.
*/
class FlowReactor : public Reactor
{
public:
/**
* Default constructor.
*/
FlowReactor();
virtual int type() const {
return FlowReactorType;
}
//-----------------------------------------------------
virtual void getInitialConditions(doublereal t0, size_t leny,
doublereal* y);
//-----------------------------------------------------
virtual size_t neq() {
return m_nv;
}
virtual void initialize(doublereal t0 = 0.0);
virtual void evalEqs(doublereal t, doublereal* y,
doublereal* ydot, doublereal* params);
@ -64,17 +51,18 @@ public:
double distance() const {
return m_dist;
}
//! Return the index in the solution vector for this reactor of the
//! component named *nm*. Possible values for *nm* are "X" (position),
//! "U", the name of a homogeneous phase species, or the name of a surface
//! species.
virtual size_t componentIndex(const std::string& nm) const;
protected:
doublereal m_speed, m_dist, m_T;
doublereal m_fctr;
doublereal m_rho0, m_speed0, m_P0, m_h0;
private:
};
}
#endif

View file

@ -14,44 +14,31 @@ namespace Cantera
{
/**
* Class Reactor is a general-purpose class for stirred
* reactors. The reactor may have an arbitrary number of inlets
* and outlets, each of which may be connected to a "flow device"
* such as a mass flow controller, a pressure regulator,
* etc. Additional reactors may be connected to the other end of
* the flow device, allowing construction of arbitrary reactor
* networks.
* Class Reactor is a general-purpose class for stirred reactors. The reactor
* may have an arbitrary number of inlets and outlets, each of which may be
* connected to a "flow device" such as a mass flow controller, a pressure
* regulator, etc. Additional reactors may be connected to the other end of
* the flow device, allowing construction of arbitrary reactor networks.
*
* The reactor class integrates the same governing equations no
* matter what type of reactor is simulated. The differences
* among reactor types are completely specified by the attached
* flow devices and the time-dependent user-specified boundary
* conditions.
* The reactor class integrates the same governing equations no matter what
* type of reactor is simulated. The differences among reactor types are
* completely specified by the attached flow devices and the time-dependent
* user-specified boundary conditions.
*
* If an instance of class Reactor is used directly, it will
* simulate an adiabatic, constant volume reactor with gas-phase
* chemistry but no surface chemistry. Other reactor types may be
* simulated by deriving a class from Reactor and overloading
* method getParams. This method allows specifying the following
* in terms of the instantaneous reactor state:
* If an instance of class Reactor is used directly, it will simulate an
* adiabatic, constant volume reactor with gas-phase chemistry but no surface
* chemistry. Other reactor types may be simulated by deriving a class from
* Reactor. This method allows specifying the following in terms of the
* instantaneous reactor state:
*
* - rate of change of the total volume (m^3/s)
* - surface heat loss rate (W)
* - species surface production rates (kmol/s)
*
* class Reactor inherits from both ReactorBase and
* FuncEval. ReactorBase provides the basic reactor-like methods
* that FlowDevice instances can access to determine their mass
* flow rate. Class FuncEval is the class used to define a system
* of ODE's to be integrated.
*/
class Reactor : public ReactorBase
{
public:
//! Default constructor.
Reactor();
virtual int type() const {
@ -78,14 +65,17 @@ public:
}
}
//! Disable changes in reactor composition due to chemical reactions.
void disableChemistry() {
m_chem = false;
}
//! Enable changes in reactor composition due to chemical reactions.
void enableChemistry() {
m_chem = true;
}
/// Set the energy equation on or off.
//! Set the energy equation on or off.
void setEnergy(int eflag = 1) {
if (eflag > 0) {
m_energy = true;
@ -94,33 +84,64 @@ public:
}
}
/// Returns 'true' if solution of the energy equation is enabled.
//! Returns `true` if solution of the energy equation is enabled.
bool energyEnabled() const {
return m_energy;
}
// overloaded methods of class FuncEval
//! Number of equations (state variables) for this reactor
virtual size_t neq() {
return m_nv;
}
//! Called by ReactorNet to get the initial conditions.
/*!
* @param[in] t0 Time at which initial conditions are determined
* @param[in] leny Length of *y* (unused)
* @param[out] y state vector representing the initial state of the reactor
*/
virtual void getInitialConditions(doublereal t0, size_t leny,
doublereal* y);
virtual void initialize(doublereal t0 = 0.0);
/*!
* Evaluate the reactor governing equations. Called by ReactorNet::eval.
* @param[in] t time.
* @param[in] y solution vector, length neq()
* @param[out] ydot rate of change of solution vector, length neq()
* @param[in] params sensitivity parameter vector, length ReactorNet::nparams()
*/
virtual void evalEqs(doublereal t, doublereal* y,
doublereal* ydot, doublereal* params);
/**
* Set the mixture to a state consistent with solution
* vector y.
*/
//! Set the state of the reactor to correspond to the state vector *y*.
virtual void updateState(doublereal* y);
//! Number of sensitivity parameters associated with this reactor
//! (including walls)
virtual size_t nSensParams();
//! Add a sensitivity parameter associated with the reaction number *rxn*
//! (in the homogeneous phase).
virtual void addSensitivityReaction(size_t rxn);
//! Return a vector specifying the ordering of objects to use when
//! determining sensitivity parameter indices.
/*!
* Used to construct ReactorNet::m_sensOrder.
*
* @return A vector of pairs where the first element of each pair is a
* pointer to either a Reactor object or a Wall object and the second
* element is either 0 (in the case of a Reactor) or in the case of a
* Wall indicates that the sensitivity parameters are associated with
* surface chemistry on the left (0) or right (1) side of the wall.
*/
std::vector<std::pair<void*, int> > getSensitivityOrder() const;
//! Return the index in the solution vector for this reactor of the
//! component named *nm*. Possible values for *nm* are "m", "V", "T", the
//! name of a homogeneous phase species, or the name of a surface species.
virtual size_t componentIndex(const std::string& nm) const;
protected:
@ -142,10 +163,7 @@ protected:
std::vector<size_t> m_pnum;
std::vector<size_t> m_nsens_wall;
vector_fp m_mult_save;
private:
};
}
#endif

View file

@ -8,7 +8,7 @@
#include "cantera/thermo/ThermoPhase.h"
/// Namespace for classes implementing zero-dimensional reactor networks.
//! Namespace for classes implementing zero-dimensional reactor networks.
namespace Cantera
{
class FlowDevice;
@ -21,27 +21,27 @@ const int FlowReactorType = 3;
const int ConstPressureReactorType = 4;
/**
* Base class for stirred reactors.
* Allows using any substance model, with arbitrary
* inflow, outflow, heat loss/gain, surface chemistry, and
* volume change.
* Base class for stirred reactors. Allows using any substance model, with
* arbitrary inflow, outflow, heat loss/gain, surface chemistry, and volume
* change.
*/
class ReactorBase
{
public:
explicit ReactorBase(const std::string& name = "(none)");
virtual ~ReactorBase() {}
//-----------------------------------------------------
//! Return a constant indicating the type of this Reactor
virtual int type() const {
return 0;
}
//! Return the name of this reactor
std::string name() const {
return m_name;
}
//! Set the name of this reactor
void setName(const std::string& name) {
m_name = name;
}
@ -49,7 +49,6 @@ public:
/** @name Methods to set up a simulation. */
//@{
/**
* Set the initial reactor volume. By default, the volume is
* 1.0 m^3.
@ -66,33 +65,56 @@ public:
*/
void setThermoMgr(thermo_t& thermo);
//! Connect an inlet FlowDevice to this reactor
void addInlet(FlowDevice& inlet);
//! Connect an outlet FlowDevice to this reactor
void addOutlet(FlowDevice& outlet);
//! Return a reference to the *n*-th inlet FlowDevice connected to this
//! reactor.
FlowDevice& inlet(size_t n = 0);
//! Return a reference to the *n*-th outlet FlowDevice connected to this
//! reactor.
FlowDevice& outlet(size_t n = 0);
//! Return the number of inlet FlowDevice objects connected to this
//! reactor.
size_t nInlets() {
return m_inlet.size();
}
//! Return the number of outlet FlowDevice objects connected to this
//! reactor.
size_t nOutlets() {
return m_outlet.size();
}
//! Return the number of Wall objects connected to this reactor.
size_t nWalls() {
return m_wall.size();
}
//! Insert a Wall between this reactor and another reactor.
/*!
* `lr` = 0 if this reactor is to the left of the wall and `lr` = 1 if
* this reactor is to the right of the wall. This method is called
* automatically for both the left and right reactors by Wall::install.
*/
void addWall(Wall& w, int lr);
//! Return a reference to the *n*-th Wall connected to this reactor.
Wall& wall(size_t n);
/**
* Initialize the reactor. Must be called after specifying the
* (and if necessary the inlet mixture) and before
* calling advance.
* Initialize the reactor. Called automatically by ReactorNet::initialize.
*/
virtual void initialize(doublereal t0 = 0.0) {
tilt();
}
//! @deprecated Not used in any derived class.
virtual void start() {}
//@}
@ -106,7 +128,7 @@ public:
m_thermo->restoreState(m_state);
}
/// return a reference to the contents.
//! return a reference to the contents.
thermo_t& contents() {
return *m_thermo;
}
@ -115,43 +137,58 @@ public:
return *m_thermo;
}
//! Return the residence time (s) of the contents of this reactor, based
//! on the outlet mass flow rates and the mass of the reactor contents.
doublereal residenceTime();
/**
* @name Solution components.
* The values returned are those after the last call to advance
* or step.
* The values returned are those after the last call to ReactorNet::advance
* or ReactorNet::step.
*/
//@{
//! Returns the current volume of the reactor
/*!
* @return Return the volume in m**3
*/
//! Returns the current volume (m^3) of the reactor.
doublereal volume() const {
return m_vol;
}
//! Returns the current density (kg/m^3) of the reactor's contents.
doublereal density() const {
return m_state[1];
}
//! Returns the current temperature (K) of the reactor's contents.
doublereal temperature() const {
return m_state[0];
}
//! Returns the current enthalpy (J/kg) of the reactor's contents.
doublereal enthalpy_mass() const {
return m_enthalpy;
}
//! Returns the current internal energy (J/kg) of the reactor's contents.
doublereal intEnergy_mass() const {
return m_intEnergy;
}
//! Returns the current pressure (Pa) of the reactor.
doublereal pressure() const {
return m_pressure;
}
//! Returns the mass (kg) of the reactor's contents.
doublereal mass() const {
return m_vol * density();
}
//! Return the vector of species mass fractions.
const doublereal* massFractions() const {
return DATA_PTR(m_state) + 2;
}
//! Return the mass fraction of the *k*-th species.
doublereal massFraction(size_t k) const {
return m_state[k+2];
}
@ -170,7 +207,6 @@ public:
void setNetwork(ReactorNet* net);
protected:
//! Number of homogeneous species in the mixture
size_t m_nsp;
@ -194,7 +230,6 @@ protected:
ReactorNet* m_net;
private:
void tilt(const std::string& method="") const {
throw CanteraError("ReactorBase::"+method,
"ReactorBase method called!");
@ -203,4 +238,3 @@ private:
}
#endif

View file

@ -1,7 +1,6 @@
/**
* @file Reactor.cpp
*
* A zero-dimensional reactor
* @file ConstPressureReactor.cpp A constant pressure zero-dimensional
* reactor
*/
// Copyright 2001 California Institute of Technology
@ -114,10 +113,6 @@ void ConstPressureReactor::updateState(doublereal* y)
m_thermo->saveState(m_state);
}
/*
* Called by the integrator to evaluate ydot given y at time 'time'.
*/
void ConstPressureReactor::evalEqs(doublereal time, doublereal* y,
doublereal* ydot, doublereal* params)
{

View file

@ -1,7 +1,5 @@
/**
* @file FlowReactor.cpp
*
* A zero-dimensional reactor
* @file FlowReactor.cpp A steady-state plug flow reactor
*/
// Copyright 2001 California Institute of Technology
@ -21,8 +19,6 @@ FlowReactor::FlowReactor() :
{
}
// overloaded method of FuncEval. Called by the integrator to
// get the initial conditions.
void FlowReactor::getInitialConditions(double t0, size_t leny, double* y)
{
m_init = true;
@ -40,9 +36,6 @@ void FlowReactor::getInitialConditions(double t0, size_t leny, double* y)
y[1] = m_speed0;
}
/*
* Must be called before calling method 'advance'
*/
void FlowReactor::initialize(doublereal t0)
{
m_thermo->restoreState(m_state);
@ -76,10 +69,6 @@ void FlowReactor::updateState(doublereal* y)
m_thermo->saveState(m_state);
}
/*
* Called by the integrator to evaluate ydot given y at time 'time'.
*/
void FlowReactor::evalEqs(doublereal time, doublereal* y,
doublereal* ydot, doublereal* params)
{
@ -125,11 +114,8 @@ void FlowReactor::evalEqs(doublereal time, doublereal* y,
m_kin->setMultiplier(m_pnum[n], mult/params[n]);
}
}
}
size_t FlowReactor::componentIndex(const string& nm) const
{
if (nm == "X") {

View file

@ -1,7 +1,5 @@
/**
* @file Reactor.cpp
*
* A zero-dimensional reactor
* @file Reactor.cpp A zero-dimensional reactor
*/
// Copyright 2001 California Institute of Technology
@ -28,8 +26,6 @@ Reactor::Reactor() : ReactorBase(),
m_nsens(npos)
{}
// overloaded method of FuncEval. Called by the integrator to
// get the initial conditions.
void Reactor::getInitialConditions(double t0, size_t leny, double* y)
{
m_init = true;
@ -65,9 +61,6 @@ void Reactor::getInitialConditions(double t0, size_t leny, double* y)
}
}
/*
* Must be called before calling method 'advance'
*/
void Reactor::initialize(doublereal t0)
{
m_thermo->restoreState(m_state);
@ -155,10 +148,6 @@ void Reactor::updateState(doublereal* y)
m_thermo->saveState(m_state);
}
/*
* Called by the integrator to evaluate ydot given y at time 'time'.
*/
void Reactor::evalEqs(doublereal time, doublereal* y,
doublereal* ydot, doublereal* params)
{
@ -327,7 +316,6 @@ std::vector<std::pair<void*, int> > Reactor::getSensitivityOrder() const
return order;
}
size_t Reactor::componentIndex(const string& nm) const
{
if (nm == "m") {