From 7484827f2b546c12baaa43276495974ccda6596a Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 2 Dec 2015 23:16:35 -0500 Subject: [PATCH] [1D] Modify fixed temperature selection to keep grid more uniform The previous method for setting the fixed temperature point could add a point very close to an existing grid point, which could then make convergence on the initial grid difficult. --- interfaces/cython/cantera/onedim.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/interfaces/cython/cantera/onedim.py b/interfaces/cython/cantera/onedim.py index 9674edb63..480713c60 100644 --- a/interfaces/cython/cantera/onedim.py +++ b/interfaces/cython/cantera/onedim.py @@ -403,7 +403,19 @@ class FreeFlame(FlameBase): locs = [0.0, 0.3, 0.5, 1.0] self.set_profile('u', locs, [u0, u0, u1, u1]) self.set_profile('T', locs, [T0, T0, Teq, Teq]) - self.set_fixed_temperature(0.5 * (T0 + Teq)) + + # Pick the location of the fixed temperature point, using an existing + # point if a reasonable choice exists + T = self.T + Tmid = 0.5 * (T0 + Teq) + i = np.flatnonzero(T < Tmid)[-1] # last point less than Tmid + if Tmid - T[i] < 0.5 * (Tmid - T0): + self.set_fixed_temperature(T[i]) + elif T[i+1] - Tmid < 0.5 * (Teq - Tmid): + self.set_fixed_temperature(T[i+1]) + else: + self.set_fixed_temperature(0.5 * (T[i] + T[i+1])) + for n in range(self.gas.n_species): self.set_profile(self.gas.species_name(n), locs, [Y0[n], Y0[n], Yeq[n], Yeq[n]])