[Thermo] Separate temperature polynomial calculation from property update

This commit is contained in:
Ray Speth 2014-10-15 02:02:48 +00:00
parent 930bcceddc
commit 40470c46af
8 changed files with 81 additions and 43 deletions

View file

@ -103,6 +103,9 @@ public:
virtual int reportType() const;
virtual size_t temperaturePolySize() const { return 7; }
virtual void updateTemperaturePoly(double T, double* T_poly) const;
//! Update the properties for this species, given a temperature polynomial
/*!
* This method is called with a pointer to an array containing the

View file

@ -72,6 +72,9 @@ public:
virtual int reportType() const;
virtual size_t temperaturePolySize() const { return 7; }
virtual void updateTemperaturePoly(double T, double* T_poly) const;
//! Update the properties for this species, given a temperature polynomial
/*!
* This method is called with a pointer to an array containing the

View file

@ -97,6 +97,17 @@ public:
return NASA1;
}
virtual size_t temperaturePolySize() const { return 6; }
virtual void updateTemperaturePoly(double T, double* T_poly) const {
T_poly[0] = T;
T_poly[1] = T * T;
T_poly[2] = T_poly[1] * T;
T_poly[3] = T_poly[2] * T;
T_poly[4] = 1.0 / T;
T_poly[5] = std::log(T);
}
//! Update the properties for this species, given a temperature polynomial
/*!
* This method is called with a pointer to an array containing the
@ -145,12 +156,7 @@ public:
doublereal* cp_R, doublereal* h_RT,
doublereal* s_R) const {
double tPoly[6];
tPoly[0] = temp;
tPoly[1] = temp * temp;
tPoly[2] = tPoly[1] * temp;
tPoly[3] = tPoly[2] * temp;
tPoly[4] = 1.0 / temp;
tPoly[5] = std::log(temp);
updateTemperaturePoly(temp, tPoly);
updateProperties(tPoly, cp_R, h_RT, s_R);
}
@ -186,12 +192,7 @@ public:
virtual doublereal reportHf298(doublereal* const h298 = 0) const {
double tt[6];
double temp = 298.15;
tt[0] = temp;
tt[1] = temp * temp;
tt[2] = tt[1] * temp;
tt[3] = tt[2] * temp;
tt[4] = 1.0 / temp;
//tt[5] = std::log(temp);
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

View file

@ -109,6 +109,12 @@ public:
return NASA2;
}
virtual size_t temperaturePolySize() const { return 6; }
virtual void updateTemperaturePoly(double T, double* T_poly) const {
mnp_low.updateTemperaturePoly(T, T_poly);
}
//! Update the properties for this species, given a temperature polynomial
/*!
* This method is called with a pointer to an array containing the
@ -131,8 +137,7 @@ public:
*/
void updateProperties(const doublereal* tt,
doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
double T = tt[0];
if (T <= m_midT) {
if (tt[0] <= m_midT) {
mnp_low.updateProperties(tt, cp_R, h_RT, s_R);
} else {
mnp_high.updateProperties(tt, cp_R, h_RT, s_R);

View file

@ -118,6 +118,19 @@ public:
return SHOMATE;
}
virtual size_t temperaturePolySize() const { return 7; }
virtual void updateTemperaturePoly(double T, double* T_poly) const {
doublereal tt = 1.e-3*T;
T_poly[0] = tt;
T_poly[1] = tt * tt;
T_poly[2] = T_poly[1] * tt;
T_poly[3] = 1.0/T_poly[1];
T_poly[4] = std::log(tt);
T_poly[5] = 1.0/GasConstant;
T_poly[6] = 1.0/(GasConstant * T);
}
//! Update the properties for this species, given a temperature polynomial
/*!
* This method is called with a pointer to an array containing the
@ -174,14 +187,7 @@ public:
doublereal* cp_R, doublereal* h_RT,
doublereal* s_R) const {
double tPoly[7];
doublereal tt = 1.e-3*temp;
tPoly[0] = tt;
tPoly[1] = tt * tt;
tPoly[2] = tPoly[1] * tt;
tPoly[3] = 1.0/tPoly[1];
tPoly[4] = std::log(tt);
tPoly[5] = 1.0/GasConstant;
tPoly[6] = 1.0/(GasConstant * temp);
updateTemperaturePoly(temp, tPoly);
updateProperties(tPoly, cp_R, h_RT, s_R);
}
@ -213,13 +219,8 @@ public:
}
virtual doublereal reportHf298(doublereal* const h298 = 0) const {
double tPoly[4];
doublereal tt = 1.e-3*298.15;
tPoly[0] = tt;
tPoly[1] = tt * tt;
tPoly[2] = tPoly[1] * tt;
tPoly[3] = 1.0/tPoly[1];
double tPoly[7];
updateTemperaturePoly(298.15, tPoly);
doublereal A = m_coeff[0];
doublereal Bt = m_coeff[1]*tPoly[0];
doublereal Ct2 = m_coeff[2]*tPoly[1];
@ -359,6 +360,12 @@ public:
return SHOMATE2;
}
virtual size_t temperaturePolySize() const { return 7; }
virtual void updateTemperaturePoly(double T, double* T_poly) const {
msp_low.updateTemperaturePoly(T, T_poly);
}
//! Update the properties for this species, given a temperature polynomial
/*!
* This method is called with a pointer to an array containing the

View file

@ -195,6 +195,15 @@ public:
return m_index;
}
//! Number of terms in the temperature polynomial for this parameterization
virtual size_t temperaturePolySize() const { return 1; }
//! Given the temperature *T*, compute the terms of the temperature
//! polynomial *T_poly*.
virtual void updateTemperaturePoly(double T, double* T_poly) const {
T_poly[0] = T;
}
//! Update the properties for this species, given a temperature polynomial
/*!
* This method is called with a pointer to an array containing the functions

View file

@ -55,6 +55,17 @@ int Nasa9Poly1::reportType() const
return NASA9;
}
void Nasa9Poly1::updateTemperaturePoly(double T, double* T_poly) const
{
T_poly[0] = T;
T_poly[1] = T * T;
T_poly[2] = T_poly[1] * T;
T_poly[3] = T_poly[2] * T;
T_poly[4] = 1.0 / T;
T_poly[5] = T_poly[4] / T;
T_poly[6] = std::log(T);
}
void Nasa9Poly1::updateProperties(const doublereal* tt,
doublereal* cp_R, doublereal* h_RT,
doublereal* s_R) const
@ -87,13 +98,7 @@ void Nasa9Poly1::updatePropertiesTemp(const doublereal temp,
doublereal* s_R) const
{
double tPoly[7];
tPoly[0] = temp;
tPoly[1] = temp * temp;
tPoly[2] = tPoly[1] * temp;
tPoly[3] = tPoly[2] * temp;
tPoly[4] = 1.0 / temp;
tPoly[5] = tPoly[4] / temp;
tPoly[6] = std::log(temp);
updateTemperaturePoly(temp, tPoly);
updateProperties(tPoly, cp_R, h_RT, s_R);
}

View file

@ -113,6 +113,17 @@ int Nasa9PolyMultiTempRegion::reportType() const
return NASA9MULTITEMP;
}
void Nasa9PolyMultiTempRegion::updateTemperaturePoly(double T, double* T_poly) const
{
T_poly[0] = T;
T_poly[1] = T * T;
T_poly[2] = T_poly[1] * T;
T_poly[3] = T_poly[2] * T;
T_poly[4] = 1.0 / T;
T_poly[5] = T_poly[4] / T;
T_poly[6] = std::log(T);
}
void Nasa9PolyMultiTempRegion::updateProperties(const doublereal* tt,
doublereal* cp_R,
doublereal* h_RT,
@ -143,13 +154,7 @@ void Nasa9PolyMultiTempRegion::updatePropertiesTemp(const doublereal temp,
doublereal* s_R) const
{
double tPoly[7];
tPoly[0] = temp;
tPoly[1] = temp * temp;
tPoly[2] = tPoly[1] * temp;
tPoly[3] = tPoly[2] * temp;
tPoly[4] = 1.0 / temp;
tPoly[5] = tPoly[4] / temp;
tPoly[6] = std::log(temp);
updateTemperaturePoly(temp, tPoly);
// Now find the region
m_currRegion = 0;
for (size_t i = 1; i < m_numTempRegions; i++) {