[Thermo] NasaPoly1 stores coefficients in the conventional order
This commit is contained in:
parent
b63d759918
commit
598e47d644
1 changed files with 30 additions and 32 deletions
|
|
@ -52,17 +52,23 @@ public:
|
|||
|
||||
//! constructor used in templated instantiations
|
||||
/*!
|
||||
* @param n Species index
|
||||
* @param tlow Minimum temperature
|
||||
* @param thigh Maximum temperature
|
||||
* @param pref reference pressure (Pa).
|
||||
* @param coeffs Vector of coefficients used to set the
|
||||
* parameters for the standard state.
|
||||
* @param n Species index
|
||||
* @param tlow Minimum temperature
|
||||
* @param thigh Maximum temperature
|
||||
* @param pref reference pressure (Pa).
|
||||
* @param coeffs Vector of coefficients used to set the parameters for the
|
||||
* standard state, in the order [a5,a6,a0,a1,a2,a3,a4]
|
||||
*/
|
||||
NasaPoly1(size_t n, doublereal tlow, doublereal thigh, doublereal pref,
|
||||
const doublereal* coeffs) :
|
||||
SpeciesThermoInterpType(n, tlow, thigh, pref),
|
||||
m_coeff(coeffs, coeffs + 7) {
|
||||
m_coeff(7)
|
||||
{
|
||||
for (size_t i = 0; i < 5; i++) {
|
||||
m_coeff[i] = coeffs[i+2];
|
||||
}
|
||||
m_coeff[5] = coeffs[0];
|
||||
m_coeff[6] = coeffs[1];
|
||||
}
|
||||
|
||||
//! copy constructor
|
||||
|
|
@ -130,18 +136,18 @@ public:
|
|||
*/
|
||||
virtual void updateProperties(const doublereal* tt,
|
||||
doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
|
||||
doublereal ct0 = m_coeff[2]; // a0
|
||||
doublereal ct1 = m_coeff[3]*tt[0]; // a1 * T
|
||||
doublereal ct2 = m_coeff[4]*tt[1]; // a2 * T^2
|
||||
doublereal ct3 = m_coeff[5]*tt[2]; // a3 * T^3
|
||||
doublereal ct4 = m_coeff[6]*tt[3]; // a4 * T^4
|
||||
doublereal ct0 = m_coeff[0]; // a0
|
||||
doublereal ct1 = m_coeff[1]*tt[0]; // a1 * T
|
||||
doublereal ct2 = m_coeff[2]*tt[1]; // a2 * T^2
|
||||
doublereal ct3 = m_coeff[3]*tt[2]; // a3 * T^3
|
||||
doublereal ct4 = m_coeff[4]*tt[3]; // a4 * T^4
|
||||
|
||||
doublereal cp, h, s;
|
||||
cp = ct0 + ct1 + ct2 + ct3 + ct4;
|
||||
h = ct0 + 0.5*ct1 + 1.0/3.0*ct2 + 0.25*ct3 + 0.2*ct4
|
||||
+ m_coeff[0]*tt[4]; // last term is a5/T
|
||||
+ m_coeff[5]*tt[4]; // last term is a5/T
|
||||
s = ct0*tt[5] + ct1 + 0.5*ct2 + 1.0/3.0*ct3
|
||||
+0.25*ct4 + m_coeff[1]; // last term is a6
|
||||
+0.25*ct4 + m_coeff[6]; // last term is a6
|
||||
|
||||
// return the computed properties in the location in the output
|
||||
// arrays for this species
|
||||
|
|
@ -169,11 +175,7 @@ public:
|
|||
tlow = m_lowT;
|
||||
thigh = m_highT;
|
||||
pref = m_Pref;
|
||||
coeffs[5] = m_coeff[0];
|
||||
coeffs[6] = m_coeff[1];
|
||||
for (int i = 2; i < 7; i++) {
|
||||
coeffs[i-2] = m_coeff[i];
|
||||
}
|
||||
std::copy(m_coeff.begin(), m_coeff.end(), coeffs);
|
||||
}
|
||||
|
||||
//! Modify parameters for the standard state
|
||||
|
|
@ -182,25 +184,21 @@ public:
|
|||
* parameters for the standard state.
|
||||
*/
|
||||
virtual void modifyParameters(doublereal* coeffs) {
|
||||
m_coeff[0] = coeffs[5];
|
||||
m_coeff[1] = coeffs[6];
|
||||
for (int i = 0; i < 5; i++) {
|
||||
m_coeff[i+2] = coeffs[i];
|
||||
}
|
||||
std::copy(coeffs, coeffs+7, m_coeff.begin());
|
||||
}
|
||||
|
||||
virtual doublereal reportHf298(doublereal* const h298 = 0) const {
|
||||
double tt[6];
|
||||
double temp = 298.15;
|
||||
updateTemperaturePoly(temp, tt);
|
||||
doublereal ct0 = m_coeff[2]; // a0
|
||||
doublereal ct1 = m_coeff[3]*tt[0]; // a1 * T
|
||||
doublereal ct2 = m_coeff[4]*tt[1]; // a2 * T^2
|
||||
doublereal ct3 = m_coeff[5]*tt[2]; // a3 * T^3
|
||||
doublereal ct4 = m_coeff[6]*tt[3]; // a4 * T^4
|
||||
doublereal ct0 = m_coeff[0]; // a0
|
||||
doublereal ct1 = m_coeff[1]*tt[0]; // a1 * T
|
||||
doublereal ct2 = m_coeff[2]*tt[1]; // a2 * T^2
|
||||
doublereal ct3 = m_coeff[3]*tt[2]; // a3 * T^3
|
||||
doublereal ct4 = m_coeff[4]*tt[3]; // a4 * T^4
|
||||
|
||||
double h_RT = ct0 + 0.5*ct1 + 1.0/3.0*ct2 + 0.25*ct3 + 0.2*ct4
|
||||
+ m_coeff[0]*tt[4]; // last t
|
||||
+ m_coeff[5]*tt[4]; // last t
|
||||
|
||||
double h = h_RT * GasConstant * temp;
|
||||
if (h298) {
|
||||
|
|
@ -215,11 +213,11 @@ public:
|
|||
}
|
||||
double hcurr = reportHf298(0);
|
||||
double delH = Hf298New - hcurr;
|
||||
m_coeff[0] += (delH) / GasConstant;
|
||||
m_coeff[5] += (delH) / GasConstant;
|
||||
}
|
||||
|
||||
protected:
|
||||
//! array of polynomial coefficients
|
||||
//! array of polynomial coefficients, stored in the order [a0, ..., a6]
|
||||
vector_fp m_coeff;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue