Skip to content

Commit

Permalink
[1D] Modify fixed temperature selection to keep grid more uniform
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
speth committed Mar 25, 2016
1 parent ac246a2 commit 7484827
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion interfaces/cython/cantera/onedim.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,19 @@ def set_initial_guess(self):
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]])
Expand Down

0 comments on commit 7484827

Please sign in to comment.