Added skeletal implementation of multiphase mixtures to new Python module
This commit is contained in:
parent
eabb46b9e7
commit
96f9b05f8c
6 changed files with 61 additions and 0 deletions
|
|
@ -1,2 +1,3 @@
|
|||
from .solution import *
|
||||
from .constants import *
|
||||
from .mixture import *
|
||||
|
|
|
|||
16
interfaces/cython/cantera/mixture.pxd
Normal file
16
interfaces/cython/cantera/mixture.pxd
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from solution cimport *
|
||||
|
||||
cdef extern from "cantera/equil/MultiPhase.h" namespace "Cantera":
|
||||
cdef cppclass CxxMultiPhase "Cantera::MultiPhase":
|
||||
CxxMultiPhase()
|
||||
void addPhase(CxxThermoPhase*, double) except +
|
||||
void init() except +
|
||||
double nSpecies()
|
||||
void setTemperature(double)
|
||||
double temperature()
|
||||
void setPressure(double)
|
||||
double pressure()
|
||||
|
||||
cdef class Mixture:
|
||||
cdef CxxMultiPhase* mix
|
||||
cdef list _phases
|
||||
38
interfaces/cython/cantera/mixture.pyx
Normal file
38
interfaces/cython/cantera/mixture.pyx
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
from mixture cimport *
|
||||
|
||||
cdef class Mixture:
|
||||
def __cinit__(self, phases):
|
||||
self.mix = new CxxMultiPhase()
|
||||
self._phases = []
|
||||
|
||||
cdef _SolutionBase phase
|
||||
for phase,moles in phases:
|
||||
self.mix.addPhase(phase.thermo, moles)
|
||||
self._phases.append(phase)
|
||||
|
||||
self.mix.init()
|
||||
if self._phases:
|
||||
self.pressure = self._phases[0].pressure
|
||||
self.temperature = self._phases[0].temperature
|
||||
|
||||
def __dealloc__(self):
|
||||
del self.mix
|
||||
|
||||
def phase(self, n):
|
||||
return self._phases[n]
|
||||
|
||||
property nSpecies:
|
||||
def __get__(self):
|
||||
return self.mix.nSpecies()
|
||||
|
||||
property temperature:
|
||||
def __get__(self):
|
||||
return self.mix.temperature()
|
||||
def __set__(self, T):
|
||||
self.mix.setTemperature(T)
|
||||
|
||||
property pressure:
|
||||
def __get__(self):
|
||||
return self.mix.pressure()
|
||||
def __set__(self, P):
|
||||
self.mix.setPressure(P)
|
||||
|
|
@ -5,6 +5,7 @@ cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera":
|
|||
cdef cppclass CxxThermoPhase "Cantera::ThermoPhase":
|
||||
CxxThermoPhase()
|
||||
double pressure() except +
|
||||
double temperature() except +
|
||||
void setMoleFractions(double*) except +
|
||||
void getMassFractions(double*) except +
|
||||
int nSpecies()
|
||||
|
|
|
|||
|
|
@ -54,6 +54,10 @@ cdef class ThermoPhase(_SolutionBase):
|
|||
def __get__(self):
|
||||
return self.thermo.pressure()
|
||||
|
||||
property temperature:
|
||||
def __get__(self):
|
||||
return self.thermo.temperature()
|
||||
|
||||
def setMoleFractions(self, X):
|
||||
if len(X) != self.nSpecies:
|
||||
raise ValueError("Mole fraction array has incorrect length")
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ def addExtension(name):
|
|||
extra_link_args=@py_extra_link_args@))
|
||||
|
||||
addExtension('solution')
|
||||
addExtension('mixture')
|
||||
addExtension('utils')
|
||||
addExtension('constants')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue