Adding parts of "oneDim" to the new Python module
This commit is contained in:
parent
514abaa0da
commit
062ab1dad9
3 changed files with 176 additions and 2 deletions
|
|
@ -12,9 +12,14 @@ cdef extern from "cantera/base/ctml.h" namespace "ctml":
|
|||
XML_Node getCtmlTree(string) except +
|
||||
|
||||
cdef extern from "cantera/thermo/mix_defs.h":
|
||||
cdef int thermo_type_ideal_gas "Cantera::cIdealGas"
|
||||
cdef int thermo_type_surf "Cantera::cSurf"
|
||||
cdef int thermo_type_edge "Cantera::cEdge"
|
||||
|
||||
cdef int kinetics_type_gas "Cantera::cGasKinetics"
|
||||
cdef int kinetics_type_interface "Cantera::cInterfaceKinetics"
|
||||
cdef int kinetics_type_edge "Cantera::cEdgeKinetics"
|
||||
|
||||
cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera":
|
||||
cdef cppclass CxxThermoPhase "Cantera::ThermoPhase":
|
||||
CxxThermoPhase()
|
||||
|
|
@ -26,6 +31,9 @@ cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera":
|
|||
int nSpecies()
|
||||
XML_Node& xml()
|
||||
|
||||
cdef extern from "cantera/thermo/IdealGasPhase.h":
|
||||
cdef cppclass CxxIdealGasPhase "Cantera::IdealGasPhase"
|
||||
|
||||
cdef extern from "cantera/thermo/SurfPhase.h":
|
||||
cdef cppclass CxxSurfPhase "Cantera::SurfPhase":
|
||||
CxxSurfPhase()
|
||||
|
|
@ -35,8 +43,12 @@ cdef extern from "cantera/thermo/SurfPhase.h":
|
|||
cdef extern from "cantera/kinetics/Kinetics.h" namespace "Cantera":
|
||||
cdef cppclass CxxKinetics "Cantera::Kinetics":
|
||||
CxxKinetics()
|
||||
int type()
|
||||
int nReactions()
|
||||
|
||||
cdef extern from "cantera/kinetics/InterfaceKinetics.h":
|
||||
cdef cppclass CxxInterfaceKinetics "Cantera::InterfaceKinetics"
|
||||
|
||||
cdef extern from "cantera/transport/TransportBase.h" namespace "Cantera":
|
||||
cdef cppclass CxxTransport "Cantera::Transport":
|
||||
CxxTransport(CxxThermoPhase*)
|
||||
|
|
@ -109,6 +121,41 @@ cdef extern from "cantera/transport/TransportFactory.h" namespace "Cantera":
|
|||
cdef extern from "cantera/zeroD/ReactorFactory.h" namespace "Cantera":
|
||||
cdef CxxReactorBase* newReactor(string) except +
|
||||
|
||||
cdef extern from "cantera/oneD/Domain1D.h":
|
||||
cdef cppclass CxxDomain1D "Cantera::Domain1D":
|
||||
int nPoints()
|
||||
void setupGrid(size_t, double)
|
||||
|
||||
cdef extern from "cantera/oneD/Inlet1D.h":
|
||||
cdef cppclass CxxBdry1D "Cantera::Bdry1D":
|
||||
void setTemperature(double)
|
||||
cdef cppclass CxxInlet1D "Cantera::Inlet1D":
|
||||
CxxInlet1D()
|
||||
cdef cppclass CxxOutlet1D "Cantera::Outlet1D":
|
||||
CxxOutlet1D()
|
||||
cdef cppclass CxxOutletRes1D "Cantera::OutletRes1D":
|
||||
CxxOutletRes1D()
|
||||
cdef cppclass CxxSymm1D "Cantera::Symm1D":
|
||||
CxxSymm1D()
|
||||
cdef cppclass CxxSurf1D "Cantera::Surf1D":
|
||||
CxxSurf1D()
|
||||
cdef cppclass CxxReactingSurf1D "Cantera::ReactingSurf1D":
|
||||
CxxRreactingSurf1D()
|
||||
void setKineticsMgr(CxxInterfaceKinetics*)
|
||||
|
||||
cdef extern from "cantera/oneD/StFlow.h":
|
||||
cdef cppclass CxxStFlow "Cantera::StFlow":
|
||||
CxxStFlow(CxxIdealGasPhase*, int, int)
|
||||
void setKinetics(CxxKinetics&)
|
||||
cdef cppclass CxxFreeFlame "Cantera::FreeFlame":
|
||||
CxxFreeFlame(CxxIdealGasPhase*, int, int)
|
||||
cdef cppclass CxxAxiStagnFlow "Cantera::AxiStagnFlow":
|
||||
CxxAxiStagnFlow(CxxIdealGasPhase*, int, int)
|
||||
|
||||
cdef extern from "cantera/oneD/Sim1D.h":
|
||||
cdef cppclass CxxSim1D "Cantera::Sim1D":
|
||||
CxxSim1D(vector[CxxDomain1D*]&)
|
||||
|
||||
cdef string stringify(x)
|
||||
|
||||
cdef class _SolutionBase:
|
||||
|
|
|
|||
|
|
@ -16,5 +16,5 @@ include "transport.pyx"
|
|||
include "composite.pyx"
|
||||
|
||||
include "mixture.pyx"
|
||||
|
||||
include "reactor.pyx"
|
||||
include "reactor.pyx"
|
||||
include "onedim.pyx"
|
||||
|
|
|
|||
127
interfaces/cython/cantera/onedim.pyx
Normal file
127
interfaces/cython/cantera/onedim.pyx
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
cdef class Domain1D:
|
||||
cdef CxxDomain1D* domain
|
||||
def __cinit__(self, *args, **kwargs):
|
||||
self.domain = NULL
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
if self.domain is NULL:
|
||||
raise TypeError("Can't instantiate abstract class Domain1D.")
|
||||
|
||||
|
||||
cdef class Boundary1D(Domain1D):
|
||||
cdef CxxBdry1D* boundary
|
||||
def __cinit__(self, *args, **kwargs):
|
||||
self.boundary = NULL
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
if self.boundary is NULL:
|
||||
raise TypeError("Can't instantiate abstract class Boundary1D.")
|
||||
self.domain = <CxxDomain1D*>(self.boundary)
|
||||
Domain1D.__init__(self, *args, **kwargs)
|
||||
|
||||
def setTemperature(self, value):
|
||||
self.boundary.setTemperature(value)
|
||||
|
||||
|
||||
cdef class Inlet1D(Boundary1D):
|
||||
cdef CxxInlet1D* inlet
|
||||
def __cinit__(self, *args, **kwargs):
|
||||
self.inlet = new CxxInlet1D()
|
||||
self.boundary = <CxxBdry1D*>(self.inlet)
|
||||
|
||||
def __dealloc__(self):
|
||||
del self.inlet
|
||||
|
||||
|
||||
cdef class Outlet1D(Boundary1D):
|
||||
cdef CxxOutlet1D* outlet
|
||||
def __cinit__(self, *args, **kwargs):
|
||||
self.outlet = new CxxOutlet1D()
|
||||
self.boundary = <CxxBdry1D*>(self.outlet)
|
||||
|
||||
def __dealloc__(self):
|
||||
del self.outlet
|
||||
|
||||
|
||||
cdef class OutletReservoir1D(Boundary1D):
|
||||
cdef CxxOutletRes1D* outlet
|
||||
def __cinit__(self, *args, **kwargs):
|
||||
self.outlet = new CxxOutletRes1D()
|
||||
self.boundary = <CxxBdry1D*>(self.outlet)
|
||||
|
||||
def __dealloc__(self):
|
||||
del self.outlet
|
||||
|
||||
|
||||
cdef class SymmetryPlane1D(Boundary1D):
|
||||
cdef CxxSymm1D* symm
|
||||
def __cinit__(self, *args, **kwargs):
|
||||
self.symm = new CxxSymm1D()
|
||||
self.boundary = <CxxBdry1D*>(self.symm)
|
||||
|
||||
def __dealloc__(self):
|
||||
del self.symm
|
||||
|
||||
|
||||
cdef class Surface1D(Boundary1D):
|
||||
cdef CxxSurf1D* surf
|
||||
def __cinit__(self, *args, **kwargs):
|
||||
self.surf = new CxxSurf1D()
|
||||
self.boundary = <CxxBdry1D*>(self.surf)
|
||||
|
||||
def __dealloc__(self):
|
||||
del self.surf
|
||||
|
||||
|
||||
cdef class ReactingSurface1D(Boundary1D):
|
||||
cdef CxxReactingSurf1D* surf
|
||||
def __cinit__(self, *args, **kwargs):
|
||||
self.surf = new CxxReactingSurf1D()
|
||||
self.boundary = <CxxBdry1D*>(self.surf)
|
||||
|
||||
def __dealloc__(self):
|
||||
del self.surf
|
||||
|
||||
def setKinetics(self, Kinetics kin):
|
||||
if kin.kinetics.type() not in (kinetics_type_interface,
|
||||
kinetics_type_edge):
|
||||
raise TypeError('Kinetics object must be derived from '
|
||||
'InterfaceKinetics.')
|
||||
self.surf.setKineticsMgr(<CxxInterfaceKinetics*>kin.kinetics)
|
||||
|
||||
|
||||
cdef class _FlowBase(Domain1D):
|
||||
cdef CxxStFlow* flow
|
||||
def __cinit__(self, *args, **kwargs):
|
||||
self.flow = NULL
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.domain = <CxxDomain1D*>(self.flow)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def __dealloc__(self):
|
||||
del self.flow
|
||||
|
||||
|
||||
cdef CxxIdealGasPhase* getIdealGasPhase(ThermoPhase phase) except *:
|
||||
if phase.thermo.eosType() != thermo_type_ideal_gas:
|
||||
raise TypeError('ThermoPhase object is not an IdealGasPhase')
|
||||
return <CxxIdealGasPhase*>(phase.thermo)
|
||||
|
||||
|
||||
cdef class StagnationFlow(_FlowBase):
|
||||
def __cinit__(self, ThermoPhase thermo, *args, **kwargs):
|
||||
gas = getIdealGasPhase(thermo)
|
||||
self.flow = new CxxStFlow(gas, thermo.nSpecies(), 2)
|
||||
|
||||
|
||||
cdef class FreeFlame(_FlowBase):
|
||||
def __cinit__(self, ThermoPhase thermo, *args, **kwargs):
|
||||
gas = getIdealGasPhase(thermo)
|
||||
self.flow = <CxxStFlow*>(new CxxFreeFlame(gas, thermo.nSpecies, 2))
|
||||
|
||||
|
||||
cdef class AxisymmetricStagnationFlow(_FlowBase):
|
||||
def __cinit__(self, ThermoPhase thermo, *args, **kwargs):
|
||||
gas = getIdealGasPhase(thermo)
|
||||
self.flow = <CxxStFlow*>(new CxxAxiStagnFlow(gas, thermo.nSpecies, 2))
|
||||
Loading…
Add table
Reference in a new issue