Fixed some documentation issues with the Python Flame classes
Docstrings for undocumented methods of child classes are automatically copied from the corresponding method of the parent class. This works both for docstrings as shown in the Python interpreter as well as the Sphinx-generated documentation. Removed manually duplicated docstrings from setProfile(), solve() and setRefineCriteria() methods.
This commit is contained in:
parent
8d57c11eac
commit
ac54d63782
6 changed files with 25 additions and 76 deletions
|
|
@ -73,20 +73,17 @@ class BurnerDiffFlame(Stack):
|
|||
|
||||
|
||||
def solve(self, loglevel = 1, refine_grid = 1):
|
||||
"""Solve the flame. :meth:`.Stack.solve`"""
|
||||
if not self._initialized: self.init()
|
||||
Stack.solve(self, loglevel = loglevel, refine_grid = refine_grid)
|
||||
|
||||
|
||||
def setRefineCriteria(self, ratio = 10.0, slope = 0.8,
|
||||
curve = 0.8, prune = 0.0):
|
||||
"""See :meth:`.Stack.setRefineCriteria`"""
|
||||
Stack.setRefineCriteria(self, domain = self.flame,
|
||||
ratio = ratio, slope = slope, curve = curve,
|
||||
prune = prune)
|
||||
|
||||
def setProfile(self, component, locs, vals):
|
||||
"""Set a profile in the flame"""
|
||||
self._initialized = 1
|
||||
Stack.setProfile(self, self.flame, component, locs, vals)
|
||||
|
||||
|
|
@ -134,3 +131,5 @@ class BurnerDiffFlame(Stack):
|
|||
nm = self.gas.speciesName(n)
|
||||
y[n] = self.solution(nm, j)
|
||||
self.gas.setState_TPY(self.T(j), self.pressure, y)
|
||||
|
||||
fix_docs(BurnerDiffFlame)
|
||||
|
|
|
|||
|
|
@ -73,20 +73,17 @@ class BurnerFlame(Stack):
|
|||
|
||||
|
||||
def solve(self, loglevel = 1, refine_grid = 1):
|
||||
"""Solve the flame. See :meth:`.Stack.solve`"""
|
||||
if not self._initialized: self.init()
|
||||
Stack.solve(self, loglevel = loglevel, refine_grid = refine_grid)
|
||||
|
||||
|
||||
def setRefineCriteria(self, ratio = 10.0, slope = 0.8,
|
||||
curve = 0.8, prune = 0.0):
|
||||
"""See :meth:`.Stack.setRefineCriteria`"""
|
||||
Stack.setRefineCriteria(self, domain = self.flame,
|
||||
ratio = ratio, slope = slope, curve = curve,
|
||||
prune = prune)
|
||||
|
||||
def setProfile(self, component, locs, vals):
|
||||
"""Set a profile in the flame"""
|
||||
self._initialized = 1
|
||||
Stack.setProfile(self, self.flame, component, locs, vals)
|
||||
|
||||
|
|
@ -134,3 +131,5 @@ class BurnerFlame(Stack):
|
|||
nm = self.gas.speciesName(n)
|
||||
y[n] = self.solution(nm, j)
|
||||
self.gas.setState_TPY(self.T(j), self.pressure, y)
|
||||
|
||||
fix_docs(BurnerFlame)
|
||||
|
|
|
|||
|
|
@ -152,50 +152,17 @@ class CounterFlame(Stack):
|
|||
|
||||
|
||||
def solve(self, loglevel = 1, refine_grid = 1):
|
||||
"""Solve the flame.
|
||||
|
||||
:param loglevel:
|
||||
integer flag controlling the amount of diagnostic output. Zero
|
||||
suppresses all output, and 5 produces very verbose output. Default: 1
|
||||
:param refine_grid:
|
||||
if non-zero, enable grid refinement.
|
||||
"""
|
||||
|
||||
if not self._initialized: self.init()
|
||||
Stack.solve(self, loglevel = loglevel, refine_grid = refine_grid)
|
||||
|
||||
|
||||
def setRefineCriteria(self, ratio = 10.0, slope = 0.8, curve = 0.8,
|
||||
prune = 0.0):
|
||||
"""
|
||||
Set the criteria used to refine the flame.
|
||||
|
||||
:param ratio:
|
||||
additional points will be added if the ratio of the spacing
|
||||
on either side of a grid point exceeds this value
|
||||
:param slope:
|
||||
maximum difference in value between two adjacent points,
|
||||
scaled by the maximum difference in the profile
|
||||
(0.0 < slope < 1.0). Adds points in regions of high slope.
|
||||
:param curve:
|
||||
maximum difference in slope between two adjacent intervals, scaled
|
||||
by the maximum difference in the profile (0.0 < curve < 1.0). Adds
|
||||
points in regions of high curvature.
|
||||
:param prune:
|
||||
if the slope or curve criteria are satisfied to the level of
|
||||
'prune', the grid point is assumed not to be needed and is removed.
|
||||
Set prune significantly smaller than 'slope' and 'curve'. Set to
|
||||
zero to disable pruning the grid.
|
||||
|
||||
>>> f.setRefineCriteria(ratio = 5.0, slope = 0.2, curve = 0.3,
|
||||
... prune = 0.03)
|
||||
"""
|
||||
Stack.setRefineCriteria(self, domain = self.flame,
|
||||
ratio = ratio, slope = slope, curve = curve,
|
||||
prune = prune)
|
||||
|
||||
def setProfile(self, component, locs, vals):
|
||||
"""Set a profile in the flame"""
|
||||
self._initialized = 1
|
||||
Stack.setProfile(self, self.flame, component, locs, vals)
|
||||
|
||||
|
|
@ -245,3 +212,5 @@ class CounterFlame(Stack):
|
|||
nm = self.gas.speciesName(n)
|
||||
y[n] = self.solution(nm, j)
|
||||
self.gas.setState_TPY(self.T(j), self.pressure, y)
|
||||
|
||||
fix_docs(CounterFlame)
|
||||
|
|
|
|||
|
|
@ -69,14 +69,12 @@ class FreeFlame(Stack):
|
|||
|
||||
|
||||
def solve(self, loglevel = 1, refine_grid = 1):
|
||||
"""Solve the flame. See :meth:`.Stack.solve`"""
|
||||
if not self._initialized: self.init()
|
||||
Stack.solve(self, loglevel = loglevel, refine_grid = refine_grid)
|
||||
|
||||
|
||||
def setRefineCriteria(self, ratio = 10.0, slope = 0.8,
|
||||
curve = 0.8, prune = 0.0):
|
||||
"""See :meth:`.Stack.setRefineCriteria`"""
|
||||
Stack.setRefineCriteria(self, domain = self.flame,
|
||||
ratio = ratio, slope = slope, curve = curve,
|
||||
prune = prune)
|
||||
|
|
@ -85,7 +83,6 @@ class FreeFlame(Stack):
|
|||
_cantera.sim1D_setFixedTemperature(self._hndl, temp)
|
||||
|
||||
def setProfile(self, component, locs, vals):
|
||||
"""Set a profile in the flame"""
|
||||
self._initialized = 1
|
||||
Stack.setProfile(self, self.flame, component, locs, vals)
|
||||
|
||||
|
|
@ -132,3 +129,5 @@ class FreeFlame(Stack):
|
|||
nm = self.gas.speciesName(n)
|
||||
y[n] = self.solution(nm, j)
|
||||
self.gas.setState_TPY(self.T(j), self.pressure, y)
|
||||
|
||||
fix_docs(FreeFlame)
|
||||
|
|
|
|||
|
|
@ -76,51 +76,17 @@ class StagnationFlow(Stack):
|
|||
|
||||
|
||||
def solve(self, loglevel = 1, refine_grid = 1):
|
||||
"""Solve the flame.
|
||||
|
||||
:param loglevel:
|
||||
integer flag controlling the amount of diagnostic output.
|
||||
Zero suppresses all output, and 5 produces very verbose output.
|
||||
Default: 1
|
||||
:param refine_grid:
|
||||
if non-zero, enable grid refinement.
|
||||
"""
|
||||
|
||||
if not self._initialized: self.init()
|
||||
Stack.solve(self, loglevel = loglevel, refine_grid = refine_grid)
|
||||
|
||||
|
||||
def setRefineCriteria(self, ratio = 10.0, slope = 0.8,
|
||||
curve = 0.8, prune = 0.0):
|
||||
"""
|
||||
Set the criteria used to refine the flame.
|
||||
|
||||
:param ratio:
|
||||
additional points will be added if the ratio of the spacing
|
||||
on either side of a grid point exceeds this value
|
||||
:param slope:
|
||||
maximum difference in value between two adjacent points, scaled by
|
||||
the maximum difference in the profile (0.0 < slope < 1.0). Adds
|
||||
points in regions of high slope.
|
||||
:param curve:
|
||||
maximum difference in slope between two adjacent intervals, scaled
|
||||
by the maximum difference in the profile (0.0 < curve < 1.0). Adds
|
||||
points in regions of high curvature.
|
||||
:param prune:
|
||||
if the slope or curve criteria are satisfied to the level of
|
||||
'prune', the grid point is assumed not to be needed and is removed.
|
||||
Set prune significantly smaller than 'slope' and 'curve'. Set to
|
||||
zero to disable pruning the grid.
|
||||
|
||||
>>> f.setRefineCriteria(ratio = 5.0, slope = 0.2, curve = 0.3,
|
||||
... prune = 0.03)
|
||||
"""
|
||||
Stack.setRefineCriteria(self, domain = self.flow,
|
||||
ratio = ratio, slope = slope, curve = curve,
|
||||
prune = prune)
|
||||
|
||||
def setProfile(self, component, locs, vals):
|
||||
"""Set a profile in the flame"""
|
||||
self._initialized = 1
|
||||
Stack.setProfile(self, self.flow, component, locs, vals)
|
||||
|
||||
|
|
@ -179,3 +145,5 @@ class StagnationFlow(Stack):
|
|||
nm = self.gas.speciesName(n)
|
||||
y[n] = self.solution(nm, j)
|
||||
self.gas.setState_TPY(self.T(j), self.pressure, y)
|
||||
|
||||
fix_docs(StagnationFlow)
|
||||
|
|
|
|||
|
|
@ -68,6 +68,21 @@ def reset():
|
|||
starting a fresh session."""
|
||||
_cantera.ct_appdelete()
|
||||
|
||||
def fix_docs(cls):
|
||||
"""
|
||||
Inherit method docstrings from parent class if none is specified on the
|
||||
child. Usable as a decorator in Python >= 2.6.
|
||||
"""
|
||||
for name, func in vars(cls).items():
|
||||
if not func.__doc__:
|
||||
for parent in cls.__bases__:
|
||||
parfunc = getattr(parent, name)
|
||||
if parfunc and getattr(parfunc, '__doc__', None):
|
||||
func.__doc__ = parfunc.__doc__
|
||||
break
|
||||
return cls
|
||||
|
||||
|
||||
# workaround for case problems in CVS repository file Mixture.py. On some
|
||||
# systems it appears as mixture.py, and on others as Mixture.py
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue