Skip to content

Commit

Permalink
python interface additions
Browse files Browse the repository at this point in the history
  • Loading branch information
wandadars committed Jan 6, 2024
1 parent 873beed commit b63b666
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
8 changes: 8 additions & 0 deletions interfaces/cython/cantera/_onedim.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ cdef extern from "cantera/oneD/StFlow.h":
cbool withSoret()
void setFreeFlow()
void setAxisymmetricFlow()
void enableTwoPointControl(cbool)
cbool twoPointControlEnabled()
double leftControlPointTemperature()
void setLeftControlPointTemperature(double)
double rightControlPointTemperature()
void setRightControlPointTemperature(double)


cdef extern from "cantera/oneD/Sim1D.h":
Expand Down Expand Up @@ -141,6 +147,8 @@ cdef extern from "cantera/oneD/Sim1D.h":
void setInterrupt(CxxFunc1*) except +translate_exception
void setTimeStepCallback(CxxFunc1*)
void setSteadyCallback(CxxFunc1*)
void setLeftControlPoint(double) except +translate_exception
void setRightControlPoint(double) except +translate_exception


cdef extern from "cantera/thermo/IdealGasPhase.h":
Expand Down
37 changes: 37 additions & 0 deletions interfaces/cython/cantera/_onedim.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,27 @@ cdef class _FlowBase(Domain1D):
else:
self.flow.fixElectricField()

property tLeft:
""" Left control point temperature [K] """
def __get__(self):
return self.flow.leftControlPointTemperature()
def __set__(self, T):
self.flow.setLeftControlPointTemperature(T)

property tRight:
""" Right control point temperature [K] """
def __get__(self):
return self.flow.rightControlPointTemperature()
def __set__(self, T):
self.flow.setRightControlPointTemperature(T)

property two_point_control_enabled:
""" Determines whether or not to enable two point flame control"""
def __get__(self):
return self.flow.twoPointControlEnabled()
def __set__(self, enable):
self.flow.enableTwoPointControl(<cbool>enable)


cdef class FreeFlow(_FlowBase):
r"""A free flow domain. The equations solved are standard equations for adiabatic
Expand Down Expand Up @@ -1294,6 +1315,22 @@ cdef class Sim1D:
def __get__(self):
return self.sim.fixedTemperatureLocation()

def set_left_control_point(self, T):
"""
Set the left control point using a specified temperature. This user-provided
temperature will be used to locate the closest grid point to that temperature,
which will serve to locate the left control point's coordinate.
"""
self.sim.setLeftControlPoint(T)

def set_right_control_point(self, T):
"""
Set the right control point using a specified temperature. This user-provided
temperature will be used to locate the closest grid point to that temperature,
which will serve to locate the right control point's coordinate.
"""
self.sim.setRightControlPoint(T)

def save(self, filename='soln.yaml', name='solution', description=None,
loglevel=None, *, overwrite=False, compression=0, basis=None):
"""
Expand Down
37 changes: 37 additions & 0 deletions interfaces/cython/cantera/onedim.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,32 @@ def E(self):
"Electric field is only defined for transport model 'ionized_gas'.")
return self.profile(self.flame, 'eField')

@property
def Uo(self):
"""
Array containing the oxidizer velocity (right boundary velocity) [m/s] at
each point. Note: This value is only defined when using two-point control.
"""
return self.profile(self.flame, 'Uo')

@property
def tLeft(self):
""" Get/Set the left control point temperature [K] """
return self.flame.tLeft

@tLeft.setter
def tLeft(self, T):
self.flame.tLeft = T

@property
def tRight(self):
""" Get/Set the right control point temperature [K] """
return self.flame.tRight

@tRight.setter
def tRight(self, T):
self.flame.tRight = T

def elemental_mass_fraction(self, m):
r"""
Get the elemental mass fraction :math:`Z_{\mathrm{mass},m}` of element
Expand Down Expand Up @@ -412,6 +438,17 @@ def electric_field_enabled(self):
def electric_field_enabled(self, enable):
self.flame.electric_field_enabled = enable

@property
def two_point_control_enabled(self):
"""
Get/Set whether or not to active two point flame control.
"""
return self.flame.two_point_control_enabled

@two_point_control_enabled.setter
def two_point_control_enabled(self, enable):
self.flame.two_point_control_enabled = enable


def _trim(docstring):
"""Remove block indentation from a docstring."""
Expand Down

0 comments on commit b63b666

Please sign in to comment.