mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
Ensure mass flow rate is set for FlowReactor
Fixes a confusing error (depending on the LAPACK implementation) if the reactor is initialized before setting the mass flow rate.
This commit is contained in:
parent
ae3c63e8e6
commit
c1b3d5c4b1
@ -140,7 +140,7 @@ protected:
|
||||
//! Density [kg/m^3]. First component of the state vector.
|
||||
double m_rho = NAN;
|
||||
//! Axial velocity [m/s]. Second component of the state vector.
|
||||
double m_u = NAN;
|
||||
double m_u = -1.0;
|
||||
//! Pressure [Pa]. Third component of the state vector.
|
||||
double m_P = NAN;
|
||||
//! Temperature [K]. Fourth component of the state vector.
|
||||
|
@ -29,6 +29,11 @@ void FlowReactor::getStateDae(double* y, double* ydot)
|
||||
// set the first component to the initial density
|
||||
y[0] = m_rho;
|
||||
|
||||
if (m_u < 0) {
|
||||
throw CanteraError("FlowReactor::getStateDae",
|
||||
"Set mass flow rate before initializing reactor");
|
||||
}
|
||||
|
||||
// set the second component to the initial speed
|
||||
y[1] = m_u;
|
||||
|
||||
|
@ -1499,6 +1499,7 @@ class TestFlowReactor(utilities.CanteraTest):
|
||||
surf = ct.Interface('methane_pox_on_pt.yaml', 'Pt_surf')
|
||||
gas = surf.adjacent['gas']
|
||||
r = ct.FlowReactor(gas)
|
||||
r.mass_flow_rate = 0.1
|
||||
rsurf = ct.ReactorSurface(surf, r)
|
||||
sim = ct.ReactorNet([r])
|
||||
sim.initialize()
|
||||
@ -1530,6 +1531,14 @@ class TestFlowReactor2(utilities.CanteraTest):
|
||||
sim = ct.ReactorNet([r])
|
||||
return r, rsurf, sim
|
||||
|
||||
def test_no_mass_flow_rate(self):
|
||||
surf, gas = self.import_phases()
|
||||
r = ct.FlowReactor(gas)
|
||||
rsurf = ct.ReactorSurface(surf, r)
|
||||
sim = ct.ReactorNet([r])
|
||||
with pytest.raises(ct.CanteraError, match="mass flow rate"):
|
||||
sim.initialize()
|
||||
|
||||
def test_mixed_reactor_types(self):
|
||||
surf, gas = self.import_phases()
|
||||
r1 = ct.FlowReactor(gas)
|
||||
|
Loading…
Reference in New Issue
Block a user