[1D] Refine grid after expanding domain width

The test for a sufficiently wide domain short circuits the normal control logic
which makes a call to refine() after each successful steady-state solve. This
caused failures for certain cases where sucessive solutions on wider grids with
only a few points still failed to satisfy the gradient criterion at the edges of
the domain.
This commit is contained in:
Ray Speth 2018-08-02 17:16:02 -04:00
parent 5f556acd34
commit 4911539b56
2 changed files with 13 additions and 1 deletions

View file

@ -508,7 +508,7 @@ class FreeFlame(FlameBase):
# The domain is considered too narrow if gradient at the left or
# right edge is significant, compared to the average gradient across
# the domain.
if mLeft > 0.05 or mRight > 0.05:
if mLeft > 0.02 or mRight > 0.02:
raise DomainTooNarrow()
if original_callback:
@ -527,6 +527,8 @@ class FreeFlame(FlameBase):
print('Expanding domain to accomodate flame thickness. '
'New width: {} m'.format(
self.flame.grid[-1] - self.flame.grid[0]))
if refine_grid:
self.refine(loglevel)
self.set_steady_callback(original_callback)

View file

@ -170,6 +170,16 @@ class TestFreeFlame(utilities.CanteraTest):
Tad = self.gas.T
self.assertNear(Tad, self.sim.T[-1], 2e-2)
def test_auto_width2(self):
self.create_sim(p=ct.one_atm, Tin=400, reactants='H2:0.8, O2:0.5',
width=0.1)
self.sim.set_refine_criteria(ratio=4, slope=0.8, curve=0.8)
self.sim.solve(refine_grid=True, auto=True, loglevel=0)
self.assertNear(self.sim.u[0], 17.02, 1e-1)
self.assertLess(self.sim.grid[-1], 2.0) # grid should not be too wide
def test_converge_adiabatic(self):
# Test that the adiabatic flame temperature and species profiles
# converge to the correct equilibrium values as the grid is refined