[SpeciesThermo] assign nCoeffs in C++ layer
This commit is contained in:
parent
5ab15e15ce
commit
cf8d2efa09
11 changed files with 61 additions and 8 deletions
|
|
@ -86,6 +86,9 @@ public:
|
|||
void updatePropertiesTemp(const doublereal temp,
|
||||
doublereal* cp_R, doublereal* h_RT,
|
||||
doublereal* s_R) const;
|
||||
|
||||
size_t nCoeffs() const { return 4; }
|
||||
|
||||
void reportParameters(size_t& n, int& type,
|
||||
doublereal& tlow, doublereal& thigh,
|
||||
doublereal& pref,
|
||||
|
|
|
|||
|
|
@ -127,6 +127,9 @@ public:
|
|||
doublereal* cp_R,
|
||||
doublereal* h_RT,
|
||||
doublereal* s_R) const;
|
||||
|
||||
virtual size_t nCoeffs() const;
|
||||
|
||||
virtual void reportParameters(size_t& n, int& type,
|
||||
doublereal& tlow, doublereal& thigh,
|
||||
doublereal& pref,
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ public:
|
|||
doublereal* cp_R, doublereal* h_RT,
|
||||
doublereal* s_R) const;
|
||||
|
||||
virtual size_t nCoeffs() const;
|
||||
|
||||
//! This utility function reports back the type of parameterization and all
|
||||
//! of the parameters for the species, index.
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -123,6 +123,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
size_t nCoeffs() const { return 15; }
|
||||
|
||||
void reportParameters(size_t& n, int& type,
|
||||
doublereal& tlow, doublereal& thigh,
|
||||
doublereal& pref,
|
||||
|
|
|
|||
|
|
@ -306,6 +306,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual size_t nCoeffs() const { return 15; }
|
||||
|
||||
virtual void reportParameters(size_t& n, int& type,
|
||||
doublereal& tlow, doublereal& thigh,
|
||||
doublereal& pref,
|
||||
|
|
|
|||
|
|
@ -206,6 +206,12 @@ public:
|
|||
doublereal* h_RT,
|
||||
doublereal* s_R) const;
|
||||
|
||||
|
||||
//! This utility function reports back the number of coefficients
|
||||
//! for a given type of species parameterization
|
||||
virtual size_t nCoeffs() const;
|
||||
|
||||
|
||||
//! This utility function reports back the type of parameterization and all
|
||||
//! of the parameters for the species.
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ cdef extern from "cantera/thermo/SpeciesThermoInterpType.h":
|
|||
double maxTemp()
|
||||
double refPressure()
|
||||
void reportParameters(size_t&, int&, double&, double&, double&, double* const) except +translate_exception
|
||||
int nCoeffs() except +translate_exception
|
||||
|
||||
cdef extern from "cantera/thermo/SpeciesThermoFactory.h":
|
||||
cdef CxxSpeciesThermo* CxxNewSpeciesThermo "Cantera::newSpeciesThermoInterpType"\
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ cdef class SpeciesThermo:
|
|||
if not init:
|
||||
return
|
||||
|
||||
if len(coeffs) != self.n_coeffs:
|
||||
if not self.check_n_coeffs(len(coeffs)):
|
||||
raise ValueError("Coefficient array has incorrect length")
|
||||
cdef np.ndarray[np.double_t, ndim=1] data = np.ascontiguousarray(
|
||||
coeffs, dtype=np.double)
|
||||
|
|
@ -59,6 +59,11 @@ cdef class SpeciesThermo:
|
|||
def __get__(self):
|
||||
return self.spthermo.refPressure()
|
||||
|
||||
property n_coeffs:
|
||||
""" Number of parameters for the parameterization."""
|
||||
def __get__(self):
|
||||
return self.spthermo.nCoeffs()
|
||||
|
||||
property coeffs:
|
||||
"""
|
||||
Array of coefficients for the parameterization. The length of this
|
||||
|
|
@ -74,6 +79,9 @@ cdef class SpeciesThermo:
|
|||
T_high, P_ref, &data[0])
|
||||
return data
|
||||
|
||||
def check_n_coeffs(self, n):
|
||||
raise NotImplementedError('Needs to be overloaded')
|
||||
|
||||
def cp(self, T):
|
||||
"""
|
||||
Molar heat capacity at constant pressure [J/kmol/K] at temperature *T*.
|
||||
|
|
@ -109,7 +117,9 @@ cdef class ConstantCp(SpeciesThermo):
|
|||
- `coeffs[3]` = :math:`c_p^o(T_0, p_{ref})` [J/kmol-K]
|
||||
"""
|
||||
derived_type = SPECIES_THERMO_CONSTANT_CP
|
||||
n_coeffs = 4
|
||||
|
||||
def check_n_coeffs(self, n):
|
||||
return n == 4
|
||||
|
||||
|
||||
cdef class Mu0Poly(SpeciesThermo):
|
||||
|
|
@ -130,7 +140,9 @@ cdef class Mu0Poly(SpeciesThermo):
|
|||
- ...
|
||||
"""
|
||||
derived_type = SPECIES_THERMO_MU0_INTERP
|
||||
n_coeffs = 2
|
||||
|
||||
def check_n_coeffs(self, n):
|
||||
return n > 3 and n % 2 == 0
|
||||
|
||||
|
||||
cdef class NasaPoly2(SpeciesThermo):
|
||||
|
|
@ -153,7 +165,9 @@ cdef class NasaPoly2(SpeciesThermo):
|
|||
input files.
|
||||
"""
|
||||
derived_type = SPECIES_THERMO_NASA2
|
||||
n_coeffs = 15
|
||||
|
||||
def check_n_coeffs(self, n):
|
||||
return n == 15
|
||||
|
||||
|
||||
cdef class Nasa9PolyMultiTempRegion(SpeciesThermo):
|
||||
|
|
@ -176,7 +190,9 @@ cdef class Nasa9PolyMultiTempRegion(SpeciesThermo):
|
|||
as in the NIST Chemistry WebBook).
|
||||
"""
|
||||
derived_type = SPECIES_THERMO_NASA9MULTITEMP
|
||||
n_coeffs = 11
|
||||
|
||||
def check_n_coeffs(self, n):
|
||||
return n > 11 and ((n - 1) % 11) == 0
|
||||
|
||||
|
||||
cdef class ShomatePoly2(SpeciesThermo):
|
||||
|
|
@ -200,7 +216,9 @@ cdef class ShomatePoly2(SpeciesThermo):
|
|||
as in the NIST Chemistry WebBook).
|
||||
"""
|
||||
derived_type = SPECIES_THERMO_SHOMATE2
|
||||
n_coeffs = 15
|
||||
|
||||
def check_n_coeffs(self, n):
|
||||
return n == 15
|
||||
|
||||
|
||||
cdef wrapSpeciesThermo(shared_ptr[CxxSpeciesThermo] spthermo):
|
||||
|
|
|
|||
|
|
@ -129,6 +129,11 @@ void Mu0Poly::updatePropertiesTemp(const doublereal T,
|
|||
updateProperties(&T, cp_R, h_RT, s_R);
|
||||
}
|
||||
|
||||
size_t Mu0Poly::nCoeffs() const
|
||||
{
|
||||
return 2*m_numIntervals + 2;
|
||||
}
|
||||
|
||||
void Mu0Poly::reportParameters(size_t& n, int& type,
|
||||
doublereal& tlow, doublereal& thigh,
|
||||
doublereal& pref,
|
||||
|
|
|
|||
|
|
@ -127,6 +127,11 @@ void Nasa9PolyMultiTempRegion::updatePropertiesTemp(const doublereal temp,
|
|||
m_regionPts[m_currRegion]->updatePropertiesTemp(temp, cp_R, h_RT, s_R);
|
||||
}
|
||||
|
||||
size_t Nasa9PolyMultiTempRegion::nCoeffs() const
|
||||
{
|
||||
return 11*m_regionPts.size() + 1;
|
||||
}
|
||||
|
||||
void Nasa9PolyMultiTempRegion::reportParameters(size_t& n, int& type,
|
||||
doublereal& tlow, doublereal& thigh,
|
||||
doublereal& pref,
|
||||
|
|
|
|||
|
|
@ -41,6 +41,12 @@ void SpeciesThermoInterpType::updatePropertiesTemp(const double temp,
|
|||
"Not implemented");
|
||||
}
|
||||
|
||||
size_t SpeciesThermoInterpType::nCoeffs() const
|
||||
{
|
||||
throw CanteraError("SpeciesThermoInterpType::nCoeffs",
|
||||
"Not implemented");
|
||||
}
|
||||
|
||||
void SpeciesThermoInterpType::reportParameters(size_t& index, int& type,
|
||||
double& minTemp, double& maxTemp, double& refPressure,
|
||||
double* const coeffs) const
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue