Skip to content

Commit

Permalink
[Python] Add equivalence_ratio to CounterflowDiffusionFlame
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Jul 27, 2022
1 parent 83139cf commit e0a0fa9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions interfaces/cython/cantera/onedim.py
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,18 @@ def mixture_fraction(self, m):
vals[i] = self.gas.mixture_fraction(Yf, Yo, 'mass', m)
return vals

@property
def equivalence_ratio(self):
Yf = [self.solution(k, 0) for k in self.gas.species_names]
Yo = [self.solution(k, self.flame.n_points-1) for k in self.gas.species_names]

vals = np.empty(self.flame.n_points)
for i in range(self.flame.n_points):
self.set_gas_state(i)
vals[i] = self.gas.equivalence_ratio(Yf, Yo, "mass")
return vals


class ImpingingJet(FlameBase):
"""An axisymmetric flow impinging on a surface at normal incidence."""
__slots__ = ('inlet', 'flame', 'surface')
Expand Down
6 changes: 6 additions & 0 deletions interfaces/cython/cantera/test/test_onedim.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,12 @@ def test_mixture_fraction(self):
self.assertTrue(all(Z >= 0))
self.assertTrue(all(Z <= 1.0))

def test_equivalence_ratio(self):
self.create_sim(p=ct.one_atm)
phi = self.sim.equivalence_ratio
assert phi[0] == np.inf
assert np.isclose(phi[-1], 0.0)

class TestCounterflowPremixedFlame(utilities.CanteraTest):
# Note: to re-create the reference file:
# (1) set PYTHONPATH to build/python.
Expand Down

0 comments on commit e0a0fa9

Please sign in to comment.