Cantera/Reactor Equations
From charlesreid1
The thermochemical state of a gas inside a gas reactor is set by specifying the gas's energy state, pressure, and composition. Cantera does this by solving equations for a the gas internal energy U, the reactor volume V, the mass of each species, and the coverage of surface species on walls of the reactor.
Equations
Volume Equation
The equation for reactor volume is:
$ \frac{dV}{dt} = \sum_{walls} K_w A_w \Delta P + F(t) $
where $ K_w $ is a wall factor that controls the dependence of wall velocity on pressure gradient across the wall, $ A_w $ is the wall area, $ \Delta P $ is the pressure difference across the wall (so that the wall velocity is pressure-dependent), and $ F(t) $ is an arbitrary, user-specified function of time.
Code:
Wall::vdot()
/**
* The volume rate of change is given by
* \f[ \dot V = K A (P_{left} - P_{right}) + F(t) \f]
* where \f$ F(t) \f$ is a specified function of time.
*
* This method is used by class Reactor to compute the
* rate of volume change of the reactor.
*/
doublereal Wall::vdot(doublereal t)
{
double rate1 = m_k * m_area *
(m_left->pressure() - m_right->pressure());
if (m_vf) {
rate1 += m_area * m_vf->eval(t);
}
return rate1;
}Reactor::evalEqs()
m_vdot = 0.0;
// compute wall terms
size_t loc = m_nsp+2;
fill(m_sdot.begin(), m_sdot.end(), 0.0);
for (size_t i = 0; i < m_nwalls; i++) {
int lr = 1 - 2*m_lr[i];
double vdot = lr*m_wall[i]->vdot(time);
m_vdot += vdot;
[...]
// volume equation
ydot[1] = m_vdot;