00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CT_NASAPOLY2_H
00020 #define CT_NASAPOLY2_H
00021
00022 #include "SpeciesThermoInterpType.h"
00023
00024 namespace Cantera {
00025
00026
00027
00028
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 NasaPoly2 : public SpeciesThermoInterpType {
00057
00058 public:
00059
00060
00061 NasaPoly2()
00062 : m_lowT(0.0),
00063 m_midT(0.0),
00064 m_highT (0.0),
00065 m_Pref(0.0),
00066 mnp_low(0),
00067 mnp_high(0),
00068 m_index(0),
00069 m_coeff(array_fp(15)) {
00070 }
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 NasaPoly2(int n, doublereal tlow, doublereal thigh, doublereal pref,
00082 const doublereal* coeffs) :
00083 m_lowT(tlow),
00084 m_highT(thigh),
00085 m_Pref(pref),
00086 mnp_low(0),
00087 mnp_high(0),
00088 m_index(n),
00089 m_coeff(array_fp(15)) {
00090
00091 std::copy(coeffs, coeffs + 15, m_coeff.begin());
00092 m_midT = coeffs[0];
00093 mnp_low = new NasaPoly1(m_index, m_lowT, m_midT,
00094 m_Pref, &m_coeff[1]);
00095 mnp_high = new NasaPoly1(m_index, m_midT, m_highT,
00096 m_Pref, &m_coeff[8]);
00097 }
00098
00099
00100
00101
00102
00103 NasaPoly2(const NasaPoly2& b) :
00104 m_lowT(b.m_lowT),
00105 m_midT(b.m_midT),
00106 m_highT(b.m_highT),
00107 m_Pref(b.m_Pref),
00108 mnp_low(0),
00109 mnp_high(0),
00110 m_index(b.m_index),
00111 m_coeff(array_fp(15)) {
00112
00113 std::copy(b.m_coeff.begin(),
00114 b.m_coeff.begin() + 15,
00115 m_coeff.begin());
00116 mnp_low = new NasaPoly1(m_index, m_lowT, m_midT,
00117 m_Pref, &m_coeff[1]);
00118 mnp_high = new NasaPoly1(m_index, m_midT, m_highT,
00119 m_Pref, &m_coeff[8]);
00120 }
00121
00122
00123
00124
00125
00126 NasaPoly2& operator=(const NasaPoly2& b) {
00127 if (&b != this) {
00128 m_lowT = b.m_lowT;
00129 m_midT = b.m_midT;
00130 m_highT = b.m_highT;
00131 m_Pref = b.m_Pref;
00132 m_index = b.m_index;
00133 std::copy(b.m_coeff.begin(),
00134 b.m_coeff.begin() + 15,
00135 m_coeff.begin());
00136 if (mnp_low) delete mnp_low;
00137 if (mnp_high) delete mnp_high;
00138 mnp_low = new NasaPoly1(m_index, m_lowT, m_midT,
00139 m_Pref, &m_coeff[1]);
00140 mnp_high = new NasaPoly1(m_index, m_midT, m_highT,
00141 m_Pref, &m_coeff[8]);
00142 }
00143 return *this;
00144 }
00145
00146
00147 virtual ~NasaPoly2(){
00148 delete mnp_low;
00149 delete mnp_high;
00150 }
00151
00152
00153 virtual SpeciesThermoInterpType *
00154 duplMyselfAsSpeciesThermoInterpType() const {
00155 NasaPoly2* np = new NasaPoly2(*this);
00156 return (SpeciesThermoInterpType *) np;
00157 }
00158
00159
00160
00161 doublereal minTemp() const { return m_lowT;}
00162
00163
00164
00165 doublereal maxTemp() const { return m_highT;}
00166
00167
00168 doublereal refPressure() const { return m_Pref; }
00169
00170
00171 virtual int reportType() const { return NASA2; }
00172
00173
00174 virtual int speciesIndex() const { return m_index; }
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200 void updateProperties(const doublereal* tt,
00201 doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
00202
00203 double T = tt[0];
00204 if (T <= m_midT) {
00205 mnp_low->updateProperties(tt, cp_R, h_RT, s_R);
00206 } else {
00207 mnp_high->updateProperties(tt, cp_R, h_RT, s_R);
00208 }
00209 }
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227 void updatePropertiesTemp(const doublereal temp,
00228 doublereal* cp_R,
00229 doublereal* h_RT,
00230 doublereal* s_R) const {
00231 if (temp <= m_midT) {
00232 mnp_low->updatePropertiesTemp(temp, cp_R, h_RT, s_R);
00233 } else {
00234 mnp_high->updatePropertiesTemp(temp, cp_R, h_RT, s_R);
00235 }
00236 }
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252 void reportParameters(int &n, int &type,
00253 doublereal &tlow, doublereal &thigh,
00254 doublereal &pref,
00255 doublereal* const coeffs) const {
00256 n = m_index;
00257 type = NASA2;
00258 tlow = m_lowT;
00259 thigh = m_highT;
00260 pref = m_Pref;
00261 for (int i = 0; i < 15; i++) {
00262 coeffs[i] = m_coeff[i];
00263 }
00264 }
00265
00266 #ifdef H298MODIFY_CAPABILITY
00267
00268 doublereal reportHf298(doublereal* const h298 = 0) const {
00269 double h;
00270 if (298.15 <= m_midT) {
00271 h = mnp_low->reportHf298(0);
00272 } else {
00273 h = mnp_high->reportHf298(0);
00274 }
00275 if (h298) {
00276 h298[m_index] = h;
00277 }
00278 return h;
00279 }
00280
00281 void modifyOneHf298(const int k, const doublereal Hf298New) {
00282 if (k != m_index) return;
00283
00284 doublereal h298now = reportHf298(0);
00285 doublereal delH = Hf298New - h298now;
00286 double h = mnp_low->reportHf298(0);
00287 double hnew = h + delH;
00288 mnp_low->modifyOneHf298(k, hnew);
00289 h = mnp_high->reportHf298(0);
00290 hnew = h + delH;
00291 mnp_high->modifyOneHf298(k, hnew);
00292 }
00293
00294 #endif
00295
00296 protected:
00297
00298 doublereal m_lowT;
00299
00300 doublereal m_midT;
00301
00302 doublereal m_highT;
00303
00304 doublereal m_Pref;
00305
00306 NasaPoly1 *mnp_low;
00307
00308 NasaPoly1 *mnp_high;
00309
00310 int m_index;
00311
00312 array_fp m_coeff;
00313
00314 };
00315
00316 }
00317 #endif
00318
00319
00320
00321