NasaPoly1.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef CT_NASAPOLY1_H
00014 #define CT_NASAPOLY1_H
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "global.h"
00026 #include "SpeciesThermoInterpType.h"
00027
00028 namespace Cantera {
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 class NasaPoly1 : public SpeciesThermoInterpType {
00057
00058 public:
00059
00060
00061 NasaPoly1()
00062 : m_lowT(0.0), m_highT (0.0),
00063 m_Pref(0.0), m_index (0), m_coeff(array_fp(7)) {}
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 NasaPoly1(int n, doublereal tlow, doublereal thigh, doublereal pref,
00076 const doublereal* coeffs) :
00077 m_lowT (tlow),
00078 m_highT (thigh),
00079 m_Pref (pref),
00080 m_index (n),
00081 m_coeff (array_fp(7)) {
00082 std::copy(coeffs, coeffs + 7, m_coeff.begin());
00083 }
00084
00085
00086
00087
00088
00089 NasaPoly1(const NasaPoly1& b) :
00090 m_lowT (b.m_lowT),
00091 m_highT (b.m_highT),
00092 m_Pref (b.m_Pref),
00093 m_index (b.m_index),
00094 m_coeff (array_fp(7)) {
00095 std::copy(b.m_coeff.begin(),
00096 b.m_coeff.begin() + 7,
00097 m_coeff.begin());
00098 }
00099
00100
00101
00102
00103
00104 NasaPoly1& operator=(const NasaPoly1& b) {
00105 if (&b != this) {
00106 m_lowT = b.m_lowT;
00107 m_highT = b.m_highT;
00108 m_Pref = b.m_Pref;
00109 m_index = b.m_index;
00110 std::copy(b.m_coeff.begin(),
00111 b.m_coeff.begin() + 7,
00112 m_coeff.begin());
00113 }
00114 return *this;
00115 }
00116
00117
00118 virtual ~NasaPoly1(){}
00119
00120
00121 virtual SpeciesThermoInterpType *
00122 duplMyselfAsSpeciesThermoInterpType() const {
00123 NasaPoly1* np = new NasaPoly1(*this);
00124 return (SpeciesThermoInterpType *) np;
00125 }
00126
00127
00128
00129 virtual doublereal minTemp() const { return m_lowT;}
00130
00131
00132
00133 virtual doublereal maxTemp() const { return m_highT;}
00134
00135
00136 virtual doublereal refPressure() const { return m_Pref; }
00137
00138
00139 virtual int reportType() const { return NASA1; }
00140
00141
00142 virtual int speciesIndex() const { return m_index; }
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 virtual void updateProperties(const doublereal* tt,
00168 doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
00169
00170 doublereal ct0 = m_coeff[2];
00171 doublereal ct1 = m_coeff[3]*tt[0];
00172 doublereal ct2 = m_coeff[4]*tt[1];
00173 doublereal ct3 = m_coeff[5]*tt[2];
00174 doublereal ct4 = m_coeff[6]*tt[3];
00175
00176 doublereal cp, h, s;
00177 cp = ct0 + ct1 + ct2 + ct3 + ct4;
00178 h = ct0 + 0.5*ct1 + OneThird*ct2 + 0.25*ct3 + 0.2*ct4
00179 + m_coeff[0]*tt[4];
00180 s = ct0*tt[5] + ct1 + 0.5*ct2 + OneThird*ct3
00181 +0.25*ct4 + m_coeff[1];
00182
00183
00184
00185 cp_R[m_index] = cp;
00186 h_RT[m_index] = h;
00187 s_R[m_index] = s;
00188
00189
00190 }
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 virtual void updatePropertiesTemp(const doublereal temp,
00210 doublereal* cp_R, doublereal* h_RT,
00211 doublereal* s_R) const {
00212 double tPoly[6];
00213 tPoly[0] = temp;
00214 tPoly[1] = temp * temp;
00215 tPoly[2] = tPoly[1] * temp;
00216 tPoly[3] = tPoly[2] * temp;
00217 tPoly[4] = 1.0 / temp;
00218 tPoly[5] = std::log(temp);
00219 updateProperties(tPoly, cp_R, h_RT, s_R);
00220 }
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236 virtual void reportParameters(int &n, int &type,
00237 doublereal &tlow, doublereal &thigh,
00238 doublereal &pref,
00239 doublereal* const coeffs) const {
00240 n = m_index;
00241 type = NASA1;
00242 tlow = m_lowT;
00243 thigh = m_highT;
00244 pref = m_Pref;
00245 coeffs[5] = m_coeff[0];
00246 coeffs[6] = m_coeff[1];
00247 for (int i = 2; i < 7; i++) {
00248 coeffs[i-2] = m_coeff[i];
00249 }
00250 #ifdef WARN_ABOUT_CHANGES_FROM_VERSION_1_6
00251 cout << "************************************************\n"
00252 cout << "Warning: NasaPoly1::reportParameters now returns \n"
00253 << "the coefficient array in the same order as in\n"
00254 << "the input file. See file NasaPoly1.h" << endl;
00255 cout << "************************************************\n"
00256 #endif
00257 }
00258
00259
00260
00261
00262
00263
00264 virtual void modifyParameters(doublereal* coeffs) {
00265 m_coeff[0] = coeffs[5];
00266 m_coeff[1] = coeffs[6];
00267 for (int i = 0; i < 5; i++) {
00268 m_coeff[i+2] = coeffs[i];
00269 }
00270 }
00271
00272 #ifdef H298MODIFY_CAPABILITY
00273
00274 virtual doublereal reportHf298(doublereal* const h298 = 0) const {
00275 double tt[6];
00276 double temp = 298.15;
00277 tt[0] = temp;
00278 tt[1] = temp * temp;
00279 tt[2] = tt[1] * temp;
00280 tt[3] = tt[2] * temp;
00281 tt[4] = 1.0 / temp;
00282
00283 doublereal ct0 = m_coeff[2];
00284 doublereal ct1 = m_coeff[3]*tt[0];
00285 doublereal ct2 = m_coeff[4]*tt[1];
00286 doublereal ct3 = m_coeff[5]*tt[2];
00287 doublereal ct4 = m_coeff[6]*tt[3];
00288
00289 double h_RT = ct0 + 0.5*ct1 + OneThird*ct2 + 0.25*ct3 + 0.2*ct4
00290 + m_coeff[0]*tt[4];
00291
00292 double h = h_RT * GasConstant * temp;
00293 if (h298) {
00294 h298[m_index] = h;
00295 }
00296 return h;
00297 }
00298
00299 virtual void modifyOneHf298(const int k, const doublereal Hf298New) {
00300 if (k != m_index) return;
00301 double hcurr = reportHf298(0);
00302 double delH = Hf298New - hcurr;
00303 m_coeff[0] += (delH) / GasConstant;
00304 }
00305
00306 #endif
00307
00308 protected:
00309
00310 doublereal m_lowT;
00311
00312 doublereal m_highT;
00313
00314 doublereal m_Pref;
00315
00316 int m_index;
00317
00318 array_fp m_coeff;
00319
00320 };
00321
00322 }
00323 #endif
00324