Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes issue #275 #276

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions interfaces/cython/cantera/_cantera.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ cdef extern from "cantera/thermo/SpeciesThermoInterpType.h":
cdef cppclass CxxSpeciesThermo "Cantera::SpeciesThermoInterpType":
CxxSpeciesThermo()
int reportType()
void reportParameters(size_t&, int&, double&, double&, double&, double* const)
void updatePropertiesTemp(double, double*, double*, double*) except +

cdef extern from "cantera/thermo/SpeciesThermoFactory.h":
Expand Down
10 changes: 10 additions & 0 deletions interfaces/cython/cantera/speciesthermo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ cdef class SpeciesThermo:
self.spthermo.updatePropertiesTemp(T, &cp_r, &h_rt, &s_r)
return s_r * gas_constant

def report_parameters(self):
"""Returns a tuple containing the species index, parameterization type, min temperature (K), max temperature (K), reference Pressure (Pa), and list of the coefficients of this parameterization"""
cdef size_t index = 0
cdef int type = 0
cdef double min_t = 0, max_t = 0, ref_p = 0
cdef np.ndarray[np.double_t, ndim=1] coeffs = np.empty((self.n_coeffs,))
self.spthermo.reportParameters(index, type, min_t, max_t, ref_p, &coeffs[0])
return index, type, min_t, max_t, ref_p, coeffs



cdef class ConstantCp(SpeciesThermo):
r"""
Expand Down
30 changes: 30 additions & 0 deletions interfaces/cython/cantera/test/test_thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,3 +887,33 @@ def test_wrap(self):
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_report(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])
index, parameterization, t_min, t_max, \
p_ref, array = st.report_parameters()
self.assertEqual(index, 0)
self.assertEqual(parameterization, st.derived_type)
self.assertEqual(t_min, 300)
self.assertEqual(t_max, 3500)
self.assertEqual(p_ref, 101325)
self.assertEqual(array[0], 1000.0)
self.assertEqual(array[1], 3.03399249E+00)
self.assertEqual(array[2], 2.17691804E-03)
self.assertEqual(array[3], -1.64072518E-07)
self.assertEqual(array[4], -9.70419870E-11)
self.assertEqual(array[5], 1.68200992E-14)
self.assertEqual(array[6], -3.00042971E+04)
self.assertEqual(array[7], 4.96677010E+00)
self.assertEqual(array[8], 4.19864056E+00)
self.assertEqual(array[9], -2.03643410E-03)
self.assertEqual(array[10], 6.52040211E-06)
self.assertEqual(array[11], -5.48797062E-09)
self.assertEqual(array[12], 1.77197817E-12)
self.assertEqual(array[13], -3.02937267E+04)
self.assertEqual(array[14], -8.49032208E-01)