[Python] Adjust names to avoid namespace clutter
This commit is contained in:
parent
0f6f9c8f5a
commit
ae5132060e
5 changed files with 40 additions and 41 deletions
|
|
@ -4,10 +4,10 @@ from .liquidvapor import *
|
|||
from .onedim import *
|
||||
from .utils import *
|
||||
|
||||
import os as _os
|
||||
import sys as _sys
|
||||
add_directory(_os.path.join(_os.path.dirname(__file__), 'data'))
|
||||
import os
|
||||
import sys
|
||||
add_directory(os.path.join(os.path.dirname(__file__), 'data'))
|
||||
|
||||
# Python interpreter used for converting mechanisms
|
||||
if 'PYTHON_CMD' not in _os.environ:
|
||||
_os.environ['PYTHON_CMD'] = _sys.executable
|
||||
if 'PYTHON_CMD' not in os.environ:
|
||||
os.environ['PYTHON_CMD'] = sys.executable
|
||||
|
|
|
|||
|
|
@ -327,35 +327,35 @@ def _array_property(attr, size=None):
|
|||
return property(getter, doc=doc)
|
||||
|
||||
# Add scalar properties to FlameBase
|
||||
for attr in ['density', 'density_mass', 'density_mole', 'volume_mass',
|
||||
'volume_mole', 'int_energy_mole', 'int_energy_mass', 'h',
|
||||
'enthalpy_mole', 'enthalpy_mass', 's', 'entropy_mole',
|
||||
'entropy_mass', 'g', 'gibbs_mole', 'gibbs_mass', 'cv',
|
||||
'cv_mole', 'cv_mass', 'cp', 'cp_mole', 'cp_mass',
|
||||
'isothermal_compressibility', 'thermal_expansion_coeff',
|
||||
'viscosity', 'thermal_conductivity']:
|
||||
setattr(FlameBase, attr, _array_property(attr))
|
||||
for _attr in ['density', 'density_mass', 'density_mole', 'volume_mass',
|
||||
'volume_mole', 'int_energy_mole', 'int_energy_mass', 'h',
|
||||
'enthalpy_mole', 'enthalpy_mass', 's', 'entropy_mole',
|
||||
'entropy_mass', 'g', 'gibbs_mole', 'gibbs_mass', 'cv',
|
||||
'cv_mole', 'cv_mass', 'cp', 'cp_mole', 'cp_mass',
|
||||
'isothermal_compressibility', 'thermal_expansion_coeff',
|
||||
'viscosity', 'thermal_conductivity']:
|
||||
setattr(FlameBase, _attr, _array_property(_attr))
|
||||
FlameBase.volume = _array_property('v') # avoid confusion with velocity gradient 'V'
|
||||
FlameBase.int_energy = _array_property('u') # avoid collision with velocity 'u'
|
||||
|
||||
# Add properties with values for each species
|
||||
for attr in ['X', 'Y', 'concentrations', 'partial_molar_enthalpies',
|
||||
'partial_molar_entropies', 'partial_molar_int_energies',
|
||||
'chemical_potentials', 'electrochemical_potentials', 'partial_molar_cp',
|
||||
'partial_molar_volumes', 'standard_enthalpies_RT',
|
||||
'standard_entropies_R', 'standard_int_energies_RT',
|
||||
'standard_gibbs_RT', 'standard_cp_R', 'creation_rates',
|
||||
'destruction_rates', 'net_production_rates', 'mix_diff_coeffs',
|
||||
'mix_diff_coeffs_mass', 'mix_diff_coeffs_mole', 'thermal_diff_coeffs']:
|
||||
setattr(FlameBase, attr, _array_property(attr, 'n_species'))
|
||||
for _attr in ['X', 'Y', 'concentrations', 'partial_molar_enthalpies',
|
||||
'partial_molar_entropies', 'partial_molar_int_energies',
|
||||
'chemical_potentials', 'electrochemical_potentials', 'partial_molar_cp',
|
||||
'partial_molar_volumes', 'standard_enthalpies_RT',
|
||||
'standard_entropies_R', 'standard_int_energies_RT',
|
||||
'standard_gibbs_RT', 'standard_cp_R', 'creation_rates',
|
||||
'destruction_rates', 'net_production_rates', 'mix_diff_coeffs',
|
||||
'mix_diff_coeffs_mass', 'mix_diff_coeffs_mole', 'thermal_diff_coeffs']:
|
||||
setattr(FlameBase, _attr, _array_property(_attr, 'n_species'))
|
||||
|
||||
# Add properties with values for each reaction
|
||||
for attr in ['forward_rates_of_progress', 'reverse_rates_of_progress', 'net_rates_of_progress',
|
||||
'equilibrium_constants', 'forward_rate_constants', 'reverse_rate_constants',
|
||||
'delta_enthalpy', 'delta_gibbs', 'delta_entropy',
|
||||
'delta_standard_enthalpy', 'delta_standard_gibbs',
|
||||
'delta_standard_entropy']:
|
||||
setattr(FlameBase, attr, _array_property(attr, 'n_reactions'))
|
||||
for _attr in ['forward_rates_of_progress', 'reverse_rates_of_progress', 'net_rates_of_progress',
|
||||
'equilibrium_constants', 'forward_rate_constants', 'reverse_rate_constants',
|
||||
'delta_enthalpy', 'delta_gibbs', 'delta_entropy',
|
||||
'delta_standard_enthalpy', 'delta_standard_gibbs',
|
||||
'delta_standard_entropy']:
|
||||
setattr(FlameBase, _attr, _array_property(_attr, 'n_reactions'))
|
||||
|
||||
|
||||
class FreeFlame(FlameBase):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import csv
|
||||
import interrupts
|
||||
|
||||
cdef class Domain1D:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from collections import defaultdict
|
||||
import numbers
|
||||
from collections import defaultdict as _defaultdict
|
||||
import numbers as _numbers
|
||||
|
||||
reactor_counts = defaultdict(int)
|
||||
_reactor_counts = _defaultdict(int)
|
||||
|
||||
cdef class ReactorBase:
|
||||
"""
|
||||
|
|
@ -22,8 +22,8 @@ cdef class ReactorBase:
|
|||
if name is not None:
|
||||
self.name = name
|
||||
else:
|
||||
reactor_counts[self.reactor_type] += 1
|
||||
n = reactor_counts[self.reactor_type]
|
||||
_reactor_counts[self.reactor_type] += 1
|
||||
n = _reactor_counts[self.reactor_type]
|
||||
self.name = '{0}_{1}'.format(self.reactor_type, n)
|
||||
|
||||
if volume is not None:
|
||||
|
|
@ -415,8 +415,8 @@ cdef class Wall:
|
|||
if name is not None:
|
||||
self.name = name
|
||||
else:
|
||||
reactor_counts['Wall'] += 1
|
||||
n = reactor_counts['Wall']
|
||||
_reactor_counts['Wall'] += 1
|
||||
n = _reactor_counts['Wall']
|
||||
self.name = 'Wall_{0}'.format(n)
|
||||
|
||||
if A is not None:
|
||||
|
|
@ -562,8 +562,8 @@ cdef class FlowDevice:
|
|||
if name is not None:
|
||||
self.name = name
|
||||
else:
|
||||
reactor_counts[self.__class__.__name__] += 1
|
||||
n = reactor_counts[self.__class__.__name__]
|
||||
_reactor_counts[self.__class__.__name__] += 1
|
||||
n = _reactor_counts[self.__class__.__name__]
|
||||
self.name = '{0}_{1}'.format(self.__class__.__name__, n)
|
||||
|
||||
self._install(upstream, downstream)
|
||||
|
|
@ -682,7 +682,7 @@ cdef class Valve(FlowDevice):
|
|||
"""
|
||||
cdef double kv
|
||||
cdef Func1 f
|
||||
if isinstance(k, numbers.Real):
|
||||
if isinstance(k, _numbers.Real):
|
||||
kv = k
|
||||
self.dev.setParameters(1, &kv)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import os
|
||||
import inspect
|
||||
import inspect as _inspect
|
||||
|
||||
from . import Solution, add_directory
|
||||
|
||||
|
|
@ -17,4 +17,4 @@ def add_module_directory():
|
|||
Add the directory containing the module from which this function is called
|
||||
to the Cantera input file search path.
|
||||
"""
|
||||
add_directory(os.path.dirname(os.path.abspath(inspect.stack()[1][1])))
|
||||
add_directory(os.path.dirname(os.path.abspath(_inspect.stack()[1][1])))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue