[Python/Thermo] Added functions for getting species thermo parameters
Resolves #275; Closes #276; Closes #277
This commit is contained in:
parent
30d1d5ea99
commit
cd545af5ed
3 changed files with 48 additions and 5 deletions
|
|
@ -76,6 +76,10 @@ cdef extern from "cantera/thermo/SpeciesThermoInterpType.h":
|
|||
CxxSpeciesThermo()
|
||||
int reportType()
|
||||
void updatePropertiesTemp(double, double*, double*, double*) except +
|
||||
double minTemp()
|
||||
double maxTemp()
|
||||
double refPressure()
|
||||
void reportParameters(size_t&, int&, double&, double&, double&, double* const) except +
|
||||
|
||||
cdef extern from "cantera/thermo/SpeciesThermoFactory.h":
|
||||
cdef CxxSpeciesThermo* CxxNewSpeciesThermo "Cantera::newSpeciesThermoInterpType"\
|
||||
|
|
|
|||
|
|
@ -39,6 +39,36 @@ cdef class SpeciesThermo:
|
|||
self._spthermo = other
|
||||
self.spthermo = self._spthermo.get()
|
||||
|
||||
property min_temp:
|
||||
""" Minimum temperature [K] at which the parameterization is valid."""
|
||||
def __get__(self):
|
||||
return self.spthermo.minTemp()
|
||||
|
||||
property max_temp:
|
||||
""" Maximum temperature [K] at which the parameterization is valid."""
|
||||
def __get__(self):
|
||||
return self.spthermo.maxTemp()
|
||||
|
||||
property reference_pressure:
|
||||
""" Reference pressure [Pa] for the parameterization."""
|
||||
def __get__(self):
|
||||
return self.spthermo.refPressure()
|
||||
|
||||
property coeffs:
|
||||
"""
|
||||
Array of coefficients for the parameterization. The length of this
|
||||
array and the meaning of each element depends on the specific
|
||||
parameterization.
|
||||
"""
|
||||
def __get__(self):
|
||||
cdef size_t index = 0
|
||||
cdef int thermo_type = 0
|
||||
cdef double T_low = 0, T_high = 0, P_ref = 0
|
||||
cdef np.ndarray[np.double_t, ndim=1] data = np.empty(self.n_coeffs)
|
||||
self.spthermo.reportParameters(index, thermo_type, T_low,
|
||||
T_high, P_ref, &data[0])
|
||||
return data
|
||||
|
||||
def cp(self, T):
|
||||
"""
|
||||
Molar heat capacity at constant pressure [J/kmol/K] at temperature *T*.
|
||||
|
|
|
|||
|
|
@ -854,16 +854,18 @@ class TestSpecies(utilities.CanteraTest):
|
|||
|
||||
|
||||
class TestSpeciesThermo(utilities.CanteraTest):
|
||||
h2o_coeffs = [
|
||||
1000.0, 3.03399249E+00, 2.17691804E-03, -1.64072518E-07,
|
||||
-9.70419870E-11, 1.68200992E-14, -3.00042971E+04, 4.96677010E+00,
|
||||
4.19864056E+00, -2.03643410E-03, 6.52040211E-06, -5.48797062E-09,
|
||||
1.77197817E-12, -3.02937267E+04, -8.49032208E-01
|
||||
]
|
||||
def setUp(self):
|
||||
self.gas = ct.Solution('h2o2.xml')
|
||||
self.gas.X = 'H2O:1.0'
|
||||
|
||||
def test_create(self):
|
||||
st = ct.NasaPoly2(300, 3500, 101325,
|
||||
[1000.0, 3.03399249E+00, 2.17691804E-03, -1.64072518E-07,
|
||||
-9.70419870E-11, 1.68200992E-14, -3.00042971E+04, 4.96677010E+00,
|
||||
4.19864056E+00, -2.03643410E-03, 6.52040211E-06, -5.48797062E-09,
|
||||
1.77197817E-12, -3.02937267E+04, -8.49032208E-01])
|
||||
st = ct.NasaPoly2(300, 3500, 101325, self.h2o_coeffs)
|
||||
|
||||
for T in [300, 500, 900, 1200, 2000]:
|
||||
self.gas.TP = T, 101325
|
||||
|
|
@ -887,3 +889,10 @@ class TestSpeciesThermo(utilities.CanteraTest):
|
|||
self.assertAlmostEqual(st.cp(T), self.gas.cp_mole)
|
||||
self.assertAlmostEqual(st.h(T), self.gas.enthalpy_mole)
|
||||
self.assertAlmostEqual(st.s(T), self.gas.entropy_mole)
|
||||
|
||||
def test_coeffs(self):
|
||||
st = ct.NasaPoly2(300, 3500, 101325, self.h2o_coeffs)
|
||||
self.assertEqual(st.min_temp, 300)
|
||||
self.assertEqual(st.max_temp, 3500)
|
||||
self.assertEqual(st.reference_pressure, 101325)
|
||||
self.assertArrayNear(self.h2o_coeffs, st.coeffs)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue