[1D/Cython] Adds Python interface to getRefineCriteria

This commit is contained in:
Bryan W. Weber 2017-08-02 14:46:40 -04:00 committed by Ray Speth
parent bce4210e1b
commit 4b44c66182
3 changed files with 33 additions and 3 deletions

View file

@ -721,6 +721,7 @@ cdef extern from "cantera/oneD/Sim1D.h":
void solve(int, cbool) except +translate_exception
void refine(int) except +translate_exception
void setRefineCriteria(size_t, double, double, double, double) except +translate_exception
vector[double] getRefineCriteria(int) except +translate_exception
void save(string, string, string, int) except +translate_exception
void restore(string, string, int) except +translate_exception
void writeStats(int) except +translate_exception

View file

@ -57,6 +57,18 @@ class FlameBase(Sim1D):
super(FlameBase, self).set_refine_criteria(self.flame, ratio, slope,
curve, prune)
def get_refine_criteria(self):
"""
Get a dictionary of the criteria used for grid refinement. The items in
the dictionary are the ``ratio``, ``slope``, ``curve``, and ``prune``,
as defined in `~FlameBase.set_refine_criteria`.
>>> f.set_refine_criteria(ratio=3.0, slope=0.1, curve=0.2, prune=0)
>>> f.get_refine_criteria()
{'ratio': 3.0, 'slope': 0.1, 'curve': 0.2, 'prune': 0.0}
"""
return super(FlameBase, self).get_refine_criteria(self.flame)
def set_profile(self, component, locations, values):
"""
Set an initial estimate for a profile of one component.
@ -414,10 +426,10 @@ class FreeFlame(FlameBase):
"""
Set the initial guess for the solution. The adiabatic flame
temperature and equilibrium composition are computed for the inlet gas
composition.
composition.
:param locs:
A list of four locations to define the temperature and mass fraction profiles.
A list of four locations to define the temperature and mass fraction profiles.
Profiles rise linearly between the second and third location.
Locations are given as a fraction of the entire domain
"""

View file

@ -997,6 +997,23 @@ cdef class Sim1D:
idom = self.domain_index(domain)
self.sim.setRefineCriteria(idom, ratio, slope, curve, prune)
def get_refine_criteria(self, domain):
"""
Get a dictionary of the criteria used to refine one domain. The items in
the dictionary are the ``ratio``, ``slope``, ``curve``, and ``prune``,
as defined in `~Sim1D.set_refine_criteria`.
:param domain:
domain object, index, or name
>>> s.set_refine_criteria(d, ratio=5.0, slope=0.2, curve=0.3, prune=0.03)
>>> s.get_refine_criteria(d)
{'ratio': 5.0, 'slope': 0.2, 'curve': 0.3, 'prune': 0.03}
"""
idom = self.domain_index(domain)
c = self.sim.getRefineCriteria(idom)
return {'ratio': c[0], 'slope': c[1], 'curve': c[2], 'prune': c[3]}
def set_grid_min(self, dz, domain=None):
"""
Set the minimum grid spacing on *domain*. If *domain* is None, then