19 ConstPressureReactor::ConstPressureReactor() : Reactor() {}
27 "Error: reactor is empty.");
32 y[0] = m_thermo->
density() * m_vol;
42 size_t loc =
m_nsp + 2;
44 for (
size_t m = 0; m < m_nwalls; m++) {
45 surf = m_wall[m]->surface(m_lr[m]);
47 m_wall[m]->getCoverages(m_lr[m], y + loc);
56 m_sdot.resize(
m_nsp, 0.0);
59 for (
size_t w = 0; w < m_nwalls; w++)
60 if (m_wall[w]->surface(m_lr[w])) {
61 m_nv += m_wall[w]->surface(m_lr[w])->nSpecies();
68 size_t nt = 0, maxnt = 0;
69 for (
size_t m = 0; m < m_nwalls; m++) {
70 if (m_wall[m]->kinetics(m_lr[m])) {
71 nt = m_wall[m]->kinetics(m_lr[m])->nTotalSpecies();
75 if (m_wall[m]->kinetics(m_lr[m])) {
77 &m_wall[m]->kinetics(m_lr[m])->thermo(0)) {
79 "First phase of all kinetics managers must be"
86 std::sort(m_pnum.begin(), m_pnum.end());
104 size_t loc =
m_nsp + 2;
106 for (
size_t m = 0; m < m_nwalls; m++) {
107 surf = m_wall[m]->surface(m_lr[m]);
109 m_wall[m]->setCoverages(m_lr[m], y+loc);
121 doublereal* ydot, doublereal* params)
133 npar = m_pnum.size();
134 for (
size_t n = 0; n < npar; n++) {
139 for (
size_t m = 0; m < m_nwalls; m++) {
140 if (m_nsens_wall[m] > 0) {
141 m_wall[m]->setSensitivityParameters(m_lr[m], params + ploc);
142 ploc += m_nsens_wall[m];
150 doublereal rs0, sum, wallarea;
152 double* dYdt = ydot + 2;
155 size_t lr, ns, loc =
m_nsp+2, surfloc;
156 fill(m_sdot.begin(), m_sdot.end(), 0.0);
157 for (
size_t i = 0; i < m_nwalls; i++) {
159 m_Q += lr*m_wall[i]->Q(time);
160 kin = m_wall[i]->kinetics(m_lr[i]);
161 surf = m_wall[i]->surface(m_lr[i]);
167 m_wall[i]->syncCoverages(m_lr[i]);
171 for (
size_t k = 1; k < nk; k++) {
172 ydot[loc + k] = m_work[surfloc+k]*rs0*surf->
size(k);
173 sum -= ydot[loc + k];
178 wallarea = m_wall[i]->area();
179 for (
size_t k = 0; k <
m_nsp; k++) {
180 m_sdot[k] += m_work[k]*wallarea;
192 double mdot_surf = 0.0;
193 for (
size_t k = 0; k <
m_nsp; k++) {
195 dYdt[k] = (
m_wdot[k] * m_vol + m_sdot[k]) * mw[k] /
m_mass;
196 mdot_surf += m_sdot[k] * mw[k];
203 for (
size_t n = 0; n <
m_nsp; n++) {
205 dYdt[n] -= Y[n] * mdot_surf /
m_mass;
212 for (
size_t i = 0; i < m_nOutlets; i++) {
213 double mdot_out = m_outlet[i]->massFlowRate(time);
215 dHdt -= mdot_out * enthalpy;
219 for (
size_t i = 0; i < m_nInlets; i++) {
220 double mdot_in = m_inlet[i]->massFlowRate(time);
222 for (
size_t n = 0; n <
m_nsp; n++) {
223 double mdot_spec = m_inlet[i]->outletSpeciesMassFlowRate(n);
225 dYdt[n] += (mdot_spec - mdot_in * Y[n]) /
m_mass;
227 dHdt += mdot_in * m_inlet[i]->enthalpy_mass();
240 npar = m_pnum.size();
241 for (
size_t n = 0; n < npar; n++) {
246 for (
size_t m = 0; m < m_nwalls; m++) {
247 if (m_nsens_wall[m] > 0) {
248 m_wall[m]->resetSensitivityParameters(m_lr[m]);
249 ploc += m_nsens_wall[m];
270 size_t walloffset = 0, kp = 0;
272 for (
size_t m = 0; m < m_nwalls; m++) {
273 if (m_wall[m]->kinetics(m_lr[m])) {
274 kp = m_wall[m]->kinetics(m_lr[m])->reactionPhaseIndex();
275 th = &m_wall[m]->kinetics(m_lr[m])->thermo(kp);
278 return k + 2 +
m_nsp + walloffset;
virtual void setState_HP(doublereal h, doublereal p, doublereal tol=1.e-4)
Set the internally stored specific enthalpy (J/kg) and pressure (Pa) of the phase.
virtual doublereal density() const
Density (kg/m^3).
void restoreState(const vector_fp &state)
Restore a state saved on a previous call to saveState.
virtual size_t componentIndex(const std::string &nm) const
Return the index in the solution vector for this reactor of the component named nm.
doublereal m_mass
total mass
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase, assuming an ideal solution model (see Thermodynamic Properties and class SurfPhase).
Header file for class Wall.
vector_fp m_wdot
Species net molar production rates.
virtual void getInitialConditions(doublereal t0, size_t leny, doublereal *y)
Called by ReactorNet to get the initial conditions.
void getMassFractions(doublereal *const y) const
Get the species mass fractions.
thermo_t & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism...
const size_t npos
index returned by functions to indicate "no position"
virtual void getNetProductionRates(doublereal *wdot)
Species net production rates [kmol/m^3/s or kmol/m^2/s].
doublereal size(size_t k) const
This routine returns the size of species k.
doublereal multiplier(size_t i) const
The current value of the multiplier for reaction i.
virtual void evalEqs(doublereal t, doublereal *y, doublereal *ydot, doublereal *params)
void setMultiplier(size_t i, doublereal f)
Set the multiplier for reaction i to f.
doublereal intEnergy_mass() const
Specific internal energy.
Base class for a phase with thermodynamic properties.
virtual void updateState(doublereal *y)
Set the state of the reactor to correspond to the state vector y.
Kinetics * m_kin
Pointer to the homogeneous Kinetics object that handles the reactions.
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
size_t surfacePhaseIndex()
This returns the integer index of the phase which has ThermoPhase type cSurf.
virtual void initialize(doublereal t0=0.0)
Initialize the reactor.
const doublereal * massFractions() const
Return a const pointer to the mass fraction array.
Public interface for kinetics managers.
Base class for exceptions thrown by Cantera classes.
size_t kineticsSpeciesIndex(size_t k, size_t n) const
The location of species k of phase n in species arrays.
virtual void setMassFractions_NoNorm(const doublereal *const y)
Set the mass fractions to the specified values without normalizing.
size_t nSpecies() const
Returns the number of species in the phase.
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
const vector_fp & molecularWeights() const
Return a const reference to the internal vector of molecular weights.
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
virtual void setTemperature(const doublereal temp)
Set the internally stored temperature of the phase (K).
doublereal enthalpy_mass() const
Specific enthalpy.
#define DATA_PTR(vec)
Creates a pointer to the start of the raw data for a vector.
size_t m_nsp
Number of homogeneous species in the mixture.
void saveState(vector_fp &state) const
Save the current internal state of the phase Write to vector 'state' the current internal state...
doublereal siteDensity()
Returns the site density.