# ShomatePoly.h

Go to the documentation of this file.
00001 /**
00002  *  @file ShomatePoly.h
00003  *  Header for a single-species standard state object derived
00005  *  on the Shomate temperature polynomial form applied to one temperature region
00008  *    Shomate polynomial expressions.
00009  */
00010 /*
00011  * $Author: hkmoffa$
00012  * $Revision: 384$
00013  * $Date: 2010-01-16 13:57:05 -0500 (Sat, 16 Jan 2010)$
00014  */
00015
00016 // Copyright 2001  California Institute of Technology
00017
00018
00019 #ifndef CT_SHOMATEPOLY1_H
00020 #define CT_SHOMATEPOLY1_H
00021
00022 #include "SpeciesThermoInterpType.h"
00023
00024 namespace Cantera {
00025
00026
00027   //! The Shomate polynomial parameterization for one temperature range
00028   //! for one species
00029   /*!
00030    *
00031    * Seven coefficients \f$(A,\dots,G)\f$ are used to represent
00032    * \f$c_p^0(T)\f$, \f$h^0(T)\f$, and \f$s^0(T) \f$ as
00033    * polynomials in the temperature, \f$T \f$ :
00034    *
00035    * \f[
00036    * \tilde{c}_p^0(T) = A + B t + C t^2 + D t^3 + \frac{E}{t^2}
00037    * \f]
00038    * \f[
00039    * \tilde{h}^0(T) = A t + \frac{B t^2}{2} + \frac{C t^3}{3}
00040    + \frac{D t^4}{4}  - \frac{E}{t}  + F.
00041    * \f]
00042    * \f[
00043    * \tilde{s}^0(T) = A\ln t + B t + \frac{C t^2}{2}
00044    + \frac{D t^3}{3} - \frac{E}{2t^2}  + G.
00045    * \f]
00046    *
00047    * In the above expressions, the thermodynamic polynomials are expressed
00048    * in dimensional units, but the temperature,\f$t \f$, is divided by 1000. The
00049    * following dimensions are assumed in the above expressions:
00050    *
00051    *    - \f$\tilde{c}_p^0(T)\f$ = Heat Capacity (J/gmol*K)
00052    *    - \f$\tilde{h}^0(T) \f$ = standard Enthalpy (kJ/gmol)
00053    *    - \f$\tilde{s}^0(T) \f$= standard Entropy (J/gmol*K)
00054    *    - \f$t \f$= temperature (K) / 1000.
00055    *
00057    *  http://webbook.nist.gov/
00058    *
00059    * Before being used within Cantera, the dimensions must be adjusted to those
00060    * used by Cantera (i.e., Joules and kmol).
00061    *
00062
00063    * @ingroup spthermo
00064    */
00065   class ShomatePoly : public SpeciesThermoInterpType {
00066
00067   public:
00068
00069     //! Empty constructor
00070     ShomatePoly()
00071       : m_lowT(0.0), m_highT (0.0),
00072         m_Pref(0.0), m_index (0) {}
00073
00074     //! Constructor used in templated instantiations
00075     /*!
00076      * @param n            Species index
00077      * @param tlow         Minimum temperature
00078      * @param thigh        Maximum temperature
00079      * @param pref         reference pressure (Pa).
00080      * @param coeffs       Vector of coefficients used to set the
00081      *                     parameters for the standard state for species n.
00082      *                     There are 7 coefficients for the Shomate polynomial:
00083      *         -   c[0] = \f$A \f$
00084      *         -   c[1] = \f$B \f$
00085      *         -   c[2] = \f$C \f$
00086      *         -   c[3] = \f$D \f$
00087      *         -   c[4] = \f$E \f$
00088      *         -   c[5] = \f$F \f$
00089      *         -   c[6] = \f$G \f$
00090      *
00091      *  See the class description for the polynomial representation of the
00092      *  thermo functions in terms of \f$A, \dots, G \f$.
00093      */
00094     ShomatePoly(int n, doublereal tlow, doublereal thigh, doublereal pref,
00095                 const doublereal* coeffs) :
00096       m_lowT      (tlow),
00097       m_highT     (thigh),
00098       m_Pref      (pref),
00099       m_index     (n) {
00100       m_coeff.resize(7);
00101       std::copy(coeffs, coeffs + 7, m_coeff.begin());
00102     }
00103
00104     //! copy constructor
00105     /*!
00106      * @param b object to be copied
00107      */
00108     ShomatePoly(const ShomatePoly& b) :
00109       m_lowT      (b.m_lowT),
00110       m_highT     (b.m_highT),
00111       m_Pref      (b.m_Pref),
00112       m_coeff     (array_fp(7)),
00113       m_index     (b.m_index) {
00114       std::copy(b.m_coeff.begin(),
00115                 b.m_coeff.begin() + 7,
00116                 m_coeff.begin());
00117     }
00118
00119     //! Assignment operator
00120     /*!
00121      * @param  b
00122      */
00123     ShomatePoly& operator=(const ShomatePoly& b) {
00124       if (&b != this) {
00125         m_lowT   = b.m_lowT;
00126         m_highT  = b.m_highT;
00127         m_Pref   = b.m_Pref;
00128         m_index  = b.m_index;
00129         m_coeff.resize(7);
00130         std::copy(b.m_coeff.begin(),
00131                   b.m_coeff.begin() + 7,
00132                   m_coeff.begin());
00133       }
00134       return *this;
00135     }
00136
00137     //! Destructor
00138     virtual ~ShomatePoly(){}
00139
00140     //! Duplicator from the base class
00141     virtual SpeciesThermoInterpType *
00142     duplMyselfAsSpeciesThermoInterpType() const {
00143       ShomatePoly* sp = new ShomatePoly(*this);
00144       return (SpeciesThermoInterpType *) sp;
00145     }
00146
00147     //! Returns the minimum temperature that the thermo
00148     //! parameterization is valid
00149     virtual doublereal minTemp() const { return m_lowT;}
00150
00151     //! Returns the maximum temperature that the thermo
00152     //! parameterization is valid
00153     virtual doublereal maxTemp() const { return m_highT;}
00154
00155     //! Returns the reference pressure (Pa)
00156     virtual doublereal refPressure() const { return m_Pref; }
00157
00158     //! Returns an integer representing the type of parameterization
00159     virtual int reportType() const { return SHOMATE; }
00160
00161     //! Returns an integer representing the species index
00162     virtual int speciesIndex() const { return m_index; }
00163
00164
00165     //! Update the properties for this species, given a temperature polynomial
00166     /*!
00167      * This method is called with a pointer to an array containing the functions of
00168      * temperature needed by this  parameterization, and three pointers to arrays where the
00169      * computed property values should be written. This method updates only one value in
00170      * each array.
00171      *
00172      *  tt is T/1000.
00173      *  m_t[0] = tt;
00174      *  m_t[1] = tt*tt;
00175      *  m_t[2] = m_t[1]*tt;
00176      *  m_t[3] = 1.0/m_t[1];
00177      *  m_t[4] = log(tt);
00178      *  m_t[5] = 1.0/GasConstant;
00179      *  m_t[6] = 1.0/(GasConstant * T);
00180      *
00181      * @param tt      Vector of temperature polynomials
00182      * @param cp_R    Vector of Dimensionless heat capacities.
00183      *                (length m_kk).
00184      * @param h_RT    Vector of Dimensionless enthalpies.
00185      *                (length m_kk).
00186      * @param s_R     Vector of Dimensionless entropies.
00187      *                (length m_kk).
00188      */
00189     virtual void updateProperties(const doublereal* tt,
00190                           doublereal* cp_R, doublereal* h_RT,
00191                           doublereal* s_R) const {
00192
00193       doublereal A      = m_coeff[0];
00194       doublereal Bt     = m_coeff[1]*tt[0];
00195       doublereal Ct2    = m_coeff[2]*tt[1];
00196       doublereal Dt3    = m_coeff[3]*tt[2];
00197       doublereal Etm2   = m_coeff[4]*tt[3];
00198       doublereal F      = m_coeff[5];
00199       doublereal G      = m_coeff[6];
00200
00201       doublereal cp, h, s;
00202       cp = A + Bt + Ct2 + Dt3 + Etm2;
00203       h = tt[0]*(A + 0.5*Bt + OneThird*Ct2 + 0.25*Dt3 - Etm2) + F;
00204       s = A*tt[4] + Bt + 0.5*Ct2 + OneThird*Dt3 - 0.5*Etm2 + G;
00205
00206       /*
00207        *  Shomate polynomials parameterizes assuming units of
00208        *  J/(gmol*K) for cp_r and s_R and kJ/(gmol) for h.
00209        *  However, Cantera assumes default MKS units of
00210        *  J/(kmol*K). This requires us to multiply cp and s
00211        *  by 1.e3 and h by 1.e6, before we then nondimensionlize
00212        *  the results by dividing by (GasConstant * T),
00213        *  where GasConstant has units of J/(kmol * K).
00214        */
00215       cp_R[m_index] = 1.e3 * cp * tt[5];
00216       h_RT[m_index] = 1.e6 * h  * tt[6];
00217       s_R[m_index]  = 1.e3 * s  * tt[5];
00218     }
00219
00220     //! Compute the reference-state property of one species
00221     /*!
00222      * Given temperature T in K, this method updates the values of
00223      * the non-dimensional heat capacity at constant pressure,
00224      * enthalpy, and entropy, at the reference pressure, Pref
00225      * of one of the species. The species index is used
00226      * to reference into the cp_R, h_RT, and s_R arrays.
00227      *
00228      * @param temp    Temperature (Kelvin)
00229      * @param cp_R    Vector of Dimensionless heat capacities.
00230      *                (length m_kk).
00231      * @param h_RT    Vector of Dimensionless enthalpies.
00232      *                (length m_kk).
00233      * @param s_R     Vector of Dimensionless entropies.
00234      *                (length m_kk).
00235      */
00236     virtual void updatePropertiesTemp(const doublereal temp,
00237                               doublereal* cp_R, doublereal* h_RT,
00238                               doublereal* s_R) const {
00239       double tPoly[7];
00240       doublereal tt = 1.e-3*temp;
00241       tPoly[0] = tt;
00242       tPoly[1] = tt * tt;
00243       tPoly[2] = tPoly[1] * tt;
00244       tPoly[3] = 1.0/tPoly[1];
00245       tPoly[4] = std::log(tt);
00246       tPoly[5] = 1.0/GasConstant;
00247       tPoly[6] = 1.0/(GasConstant * temp);
00248       updateProperties(tPoly, cp_R, h_RT, s_R);
00249     }
00250
00251     //!This utility function reports back the type of
00252     //! parameterization and all of the parameters for the
00253     //! species, index.
00254     /*!
00255      * All parameters are output variables
00256      *
00257      * @param n         Species index
00258      * @param type      Integer type of the standard type
00259      * @param tlow      output - Minimum temperature
00260      * @param thigh     output - Maximum temperature
00261      * @param pref      output - reference pressure (Pa).
00262      * @param coeffs    Vector of coefficients used to set the
00263      *                  parameters for the standard state.
00264      */
00265     virtual void reportParameters(int &n, int &type,
00266                           doublereal &tlow, doublereal &thigh,
00267                           doublereal &pref,
00268                           doublereal* const coeffs) const {
00269       n = m_index;
00270       type = SHOMATE;
00271       tlow = m_lowT;
00272       thigh = m_highT;
00273       pref = m_Pref;
00274       for (int i = 0; i < 7; i++) {
00275         coeffs[i] = m_coeff[i];
00276       }
00277     }
00278
00279     //! Modify parameters for the standard state
00280     /*!
00281      * @param coeffs   Vector of coefficients used to set the
00282      *                 parameters for the standard state.
00283      */
00284     virtual void modifyParameters(doublereal* coeffs) {
00285       if (m_coeff.size() != 7) {
00286         throw CanteraError("modifyParameters",
00287                            "modifying something that hasn't been initialized");
00288       }
00289       std::copy(coeffs, coeffs + 7, m_coeff.begin());
00290     }
00291
00292 #ifdef H298MODIFY_CAPABILITY
00293
00294     //! Report the 298 K Heat of Formation of the standard state of one species (J kmol-1)
00295     /*!
00296      *   The 298K Heat of Formation is defined as the enthalpy change to create the standard state
00297      *   of the species from its constituent elements in their standard states at 298 K and 1 bar.
00298      *
00299      *   @param h298 If this is nonnull,  the current value of the Heat of Formation at 298K and 1 bar for
00300      *               species m_index is returned in h298[m_index].
00301      *   @return     Returns the current value of the Heat of Formation at 298K and 1 bar for
00302      *               species m_index.
00303      */
00304     virtual doublereal reportHf298(doublereal* const h298 = 0) const {
00305
00306       double tPoly[4];
00307       doublereal tt = 1.e-3*298.15;
00308       tPoly[0] = tt;
00309       tPoly[1] = tt * tt;
00310       tPoly[2] = tPoly[1] * tt;
00311       tPoly[3] = 1.0/tPoly[1];
00312
00313       doublereal A      = m_coeff[0];
00314       doublereal Bt     = m_coeff[1]*tPoly[0];
00315       doublereal Ct2    = m_coeff[2]*tPoly[1];
00316       doublereal Dt3    = m_coeff[3]*tPoly[2];
00317       doublereal Etm2   = m_coeff[4]*tPoly[3];
00318       doublereal F      = m_coeff[5];
00319
00320       doublereal h = tPoly[0]*(A + 0.5*Bt + OneThird*Ct2 + 0.25*Dt3 - Etm2) + F;
00321
00322       double hh =  1.e6 * h;
00323       if (h298) {
00324         h298[m_index] = 1.e6 * h;
00325       }
00326       return hh;
00327     }
00328
00329     //! Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1)
00330     /*!
00331      *   The 298K heat of formation is defined as the enthalpy change to create the standard state
00332      *   of the species from its constituent elements in their standard states at 298 K and 1 bar.
00333      *
00334      *   @param  k           Species k
00335      *   @param  Hf298New    Specify the new value of the Heat of Formation at 298K and 1 bar
00336      */
00337     virtual void modifyOneHf298(const int k, const doublereal Hf298New) {
00338       doublereal hnow = reportHf298();
00339       doublereal delH = Hf298New - hnow;
00340       m_coeff[5] += delH / 1.0E6;
00341     }
00342
00343 #endif
00344
00345   protected:
00346     //! Minimum temperature for which the parameterization is valid (Kelvin)
00347     doublereal m_lowT;
00348     //! Maximum temperature for which the parameterization is valid (Kelvin)
00349     doublereal m_highT;
00350     //! Reference pressure (Pa)
00351     doublereal m_Pref;
00352     //! Array of coeffcients
00353     array_fp m_coeff;
00354     //! Species Index
00355     int m_index;
00356
00357   private:
00358
00359   };
00360
00361   //! The Shomate polynomial parameterization for two temperature ranges
00362   //! for one species
00363   /*!
00364    *
00365    * Seven coefficients \f$(A,\dots,G)\f$ are used to represent
00366    * \f$c_p^0(T)\f$, \f$h^0(T)\f$, and \f$s^0(T) \f$ as
00367    * polynomials in the temperature, \f$T \f$, in one temperature region:
00368    *
00369    * \f[
00370    * \tilde{c}_p^0(T) = A + B t + C t^2 + D t^3 + \frac{E}{t^2}
00371    * \f]
00372    * \f[
00373    * \tilde{h}^0(T) = A t + \frac{B t^2}{2} + \frac{C t^3}{3}
00374    + \frac{D t^4}{4}  - \frac{E}{t}  + F.
00375    * \f]
00376    * \f[
00377    * \tilde{s}^0(T) = A\ln t + B t + \frac{C t^2}{2}
00378    + \frac{D t^3}{3} - \frac{E}{2t^2}  + G.
00379    * \f]
00380    *
00381    * In the above expressions, the thermodynamic polynomials are expressed
00382    * in dimensional units, but the temperature,\f$t \f$, is divided by 1000. The
00383    * following dimensions are assumed in the above expressions:
00384    *
00385    *    - \f$\tilde{c}_p^0(T)\f$ = Heat Capacity (J/gmol*K)
00386    *    - \f$\tilde{h}^0(T) \f$ = standard Enthalpy (kJ/gmol)
00387    *    - \f$\tilde{s}^0(T) \f$= standard Entropy (J/gmol*K)
00388    *    - \f$t \f$= temperature (K) / 1000.
00389    *
00391    *  http://webbook.nist.gov/
00392    *
00393    * Before being used within Cantera, the dimensions must be adjusted to those
00394    * used by Cantera (i.e., Joules and kmol).
00395    *
00396    * This function uses two temperature regions, each with a Shomate polynomial
00397    * representation to represent the thermo functions. There are 15 coefficients,
00398    * therefore, in this representation. The first coefficient is the midrange
00399    * temperature.
00400    *
00401    *
00402    * @ingroup spthermo
00403    */
00404   class ShomatePoly2 : public SpeciesThermoInterpType {
00405   public:
00406
00407     //! Empty constructor
00408     ShomatePoly2()
00409       : m_lowT(0.0),
00410         m_midT(0.0),
00411         m_highT (0.0),
00412         m_Pref(0.0),
00413         msp_low(0),
00414         msp_high(0),
00415         m_index(0) {
00416       m_coeff.resize(15);
00417     }
00418
00419     //! Constructor used in templated instantiations
00420     /*!
00421      * @param n            Species index
00422      * @param tlow         Minimum temperature
00423      * @param thigh        Maximum temperature
00424      * @param pref         reference pressure (Pa).
00425      * @param coeffs       Vector of coefficients used to set the
00426      *                     parameters for the standard state.
00427      *                     There are 15 coefficients for the 2-zone Shomate polynomial.
00428      *                     The first coefficient is the value of Tmid. The next 7
00429      *                     coefficients are the low temperature range Shomate coefficients.
00430      *                     The last 7 are the high temperature range Shomate coefficients.
00431      */
00432     ShomatePoly2(int n, doublereal tlow, doublereal thigh, doublereal pref,
00433                  const doublereal* coeffs) :
00434       m_lowT      (tlow),
00435       m_midT(0.0),
00436       m_highT     (thigh),
00437       m_Pref      (pref),
00438       msp_low(0),
00439       msp_high(0),
00440       m_index     (n)  {
00441       m_coeff.resize(15);
00442       std::copy(coeffs, coeffs + 15, m_coeff.begin());
00443       m_midT = coeffs[0];
00444       msp_low  = new ShomatePoly(n, tlow, m_midT, pref, coeffs+1);
00445       msp_high = new ShomatePoly(n, m_midT, thigh, pref, coeffs+8);
00446     }
00447
00448     //! Copy constructor
00449     /*!
00450      * @param b object to be copied.
00451      */
00452     ShomatePoly2(const ShomatePoly2& b) :
00453       m_lowT      (b.m_lowT),
00454       m_midT      (b.m_midT),
00455       m_highT     (b.m_highT),
00456       m_Pref      (b.m_Pref),
00457       msp_low(0),
00458       msp_high(0),
00459       m_coeff     (array_fp(15)),
00460       m_index     (b.m_index) {
00461       std::copy(b.m_coeff.begin(),
00462                 b.m_coeff.begin() + 15,
00463                 m_coeff.begin());
00464       msp_low  = new ShomatePoly(m_index, m_lowT, m_midT,
00465                                  m_Pref, &m_coeff[1]);
00466       msp_high = new ShomatePoly(m_index, m_midT, m_highT,
00467                                  m_Pref, &m_coeff[8]);
00468     }
00469
00470     //! Assignment operator
00471     /*!
00472      * @param b object to be copied.
00473      */
00474     ShomatePoly2& operator=(const ShomatePoly2& b) {
00475       if (&b != this) {
00476         m_lowT   = b.m_lowT;
00477         m_midT   = b.m_midT;
00478         m_highT  = b.m_highT;
00479         m_Pref   = b.m_Pref;
00480         m_index  = b.m_index;
00481         std::copy(b.m_coeff.begin(),
00482                   b.m_coeff.begin() + 15,
00483                   m_coeff.begin());
00484         if (msp_low) delete msp_low;
00485         if (msp_high) delete msp_high;
00486         msp_low  = new ShomatePoly(m_index, m_lowT, m_midT,
00487                                    m_Pref, &m_coeff[1]);
00488         msp_high = new ShomatePoly(m_index, m_midT, m_highT,
00489                                    m_Pref, &m_coeff[8]);
00490       }
00491       return *this;
00492     }
00493
00494     //! Destructor
00495     virtual ~ShomatePoly2(){
00496       delete msp_low;
00497       delete msp_high;
00498     }
00499
00500
00501     //! duplicator
00502     virtual SpeciesThermoInterpType *
00503     duplMyselfAsSpeciesThermoInterpType() const {
00504       ShomatePoly2* sp = new ShomatePoly2(*this);
00505       return (SpeciesThermoInterpType *) sp;
00506     }
00507
00508     //! Returns the minimum temperature that the thermo
00509     //! parameterization is valid
00510     virtual doublereal minTemp() const { return m_lowT;}
00511
00512     //! Returns the maximum temperature that the thermo
00513     //! parameterization is valid
00514     virtual doublereal maxTemp() const { return m_highT;}
00515
00516     //! Returns the reference pressure (Pa)
00517     virtual doublereal refPressure() const { return m_Pref; }
00518
00519     //! Returns an integer representing the type of parameterization
00520     virtual int reportType() const { return SHOMATE2; }
00521
00522      //! Returns an integer representing the species index
00523     virtual int speciesIndex() const { return m_index; }
00524
00525     //! Update the properties for this species, given a temperature polynomial
00526     /*!
00527      * This method is called with a pointer to an array containing the functions of
00528      * temperature needed by this  parameterization, and three pointers to arrays where the
00529      * computed property values should be written. This method updates only one value in
00530      * each array.
00531      *
00532      * Temperature Polynomial:
00533      *  tt[0] = t;
00534      *  tt[1] = t*t;
00535      *  tt[2] = m_t[1]*t;
00536      *  tt[3] = m_t[2]*t;
00537      *  tt[4] = 1.0/t;
00538      *  tt[5] = std::log(t);
00539      *
00540      * @param tt      vector of temperature polynomials
00541      * @param cp_R    Vector of Dimensionless heat capacities.
00542      *                (length m_kk).
00543      * @param h_RT    Vector of Dimensionless enthalpies.
00544      *                (length m_kk).
00545      * @param s_R     Vector of Dimensionless entropies.
00546      *                (length m_kk).
00547      */
00548     virtual void updateProperties(const doublereal* tt,
00549                           doublereal* cp_R, doublereal* h_RT,
00550                           doublereal* s_R) const {
00551       double T = 1000 * tt[0];
00552       if (T <= m_midT) {
00553         msp_low->updateProperties(tt, cp_R, h_RT, s_R);
00554       } else {
00555         msp_high->updateProperties(tt, cp_R, h_RT, s_R);
00556       }
00557
00558     }
00559
00560     //! Compute the reference-state property of one species
00561     /*!
00562      * Given temperature T in K, this method updates the values of
00563      * the non-dimensional heat capacity at constant pressure,
00564      * enthalpy, and entropy, at the reference pressure, Pref
00565      * of one of the species. The species index is used
00566      * to reference into the cp_R, h_RT, and s_R arrays.
00567      *
00568      * @param temp    Temperature (Kelvin)
00569      * @param cp_R    Vector of Dimensionless heat capacities.
00570      *                (length m_kk).
00571      * @param h_RT    Vector of Dimensionless enthalpies.
00572      *                (length m_kk).
00573      * @param s_R     Vector of Dimensionless entropies.
00574      *                (length m_kk).
00575      */
00576     virtual void updatePropertiesTemp(const doublereal temp,
00577                               doublereal* cp_R,
00578                               doublereal* h_RT,
00579                               doublereal* s_R) const {
00580       if (temp <= m_midT) {
00581         msp_low->updatePropertiesTemp(temp, cp_R, h_RT, s_R);
00582       } else {
00583         msp_high->updatePropertiesTemp(temp, cp_R, h_RT, s_R);
00584       }
00585     }
00586
00587     //!This utility function reports back the type of
00588     //! parameterization and all of the parameters for the
00589     //! species, index.
00590     /*!
00591      * All parameters are output variables
00592      *
00593      * @param n         Species index
00594      * @param type      Integer type of the standard type
00595      * @param tlow      output - Minimum temperature
00596      * @param thigh     output - Maximum temperature
00597      * @param pref      output - reference pressure (Pa).
00598      * @param coeffs    Vector of coefficients used to set the
00599      *                  parameters for the standard state.
00600      */
00601     virtual void reportParameters(int &n, int &type,
00602                           doublereal &tlow, doublereal &thigh,
00603                           doublereal &pref,
00604                           doublereal* const coeffs) const {
00605       n = m_index;
00606       type = SHOMATE2;
00607       tlow = m_lowT;
00608       thigh = m_highT;
00609       pref = m_Pref;
00610       for (int i = 0; i < 15; i++) {
00611         coeffs[i] = m_coeff[i];
00612       }
00613     }
00614
00615     //! Modify parameters for the standard state
00616     /*!
00617      * Here, we take the tact that we will just regenerate the
00618      * object.
00619      *
00620      * @param coeffs   Vector of coefficients used to set the
00621      *                 parameters for the standard state.
00622      */
00623     virtual void modifyParameters(doublereal* coeffs) {
00624       delete msp_low;
00625       delete msp_high;
00626       std::copy(coeffs, coeffs + 15, m_coeff.begin());
00627       m_midT = coeffs[0];
00628       msp_low  = new ShomatePoly(m_index, m_lowT, m_midT,  m_Pref, coeffs+1);
00629       msp_high = new ShomatePoly(m_index, m_midT, m_highT, m_Pref, coeffs+8);
00630     }
00631
00632 #ifdef H298MODIFY_CAPABILITY
00633
00634     virtual doublereal reportHf298(doublereal* const h298 = 0) const {
00635       doublereal h;
00636       if (298.15 <= m_midT) {
00637         h = msp_low->reportHf298(h298);
00638       } else {
00639         h = msp_high->reportHf298(h298);
00640       }
00641       if (h298) {
00642         h298[m_index] = h;
00643       }
00644       return h;
00645     }
00646
00647     virtual void modifyOneHf298(const int k, const doublereal Hf298New) {
00648       if (k != m_index) return;
00649
00650       doublereal h298now = reportHf298(0);
00651       doublereal delH = Hf298New - h298now;
00652       double h = msp_low->reportHf298(0);
00653       double hnew = h + delH;
00654       msp_low->modifyOneHf298(k, hnew);
00655       h  = msp_high->reportHf298(0);
00656       hnew = h + delH;
00657       msp_high->modifyOneHf298(k, hnew);
00658     }
00659
00660 #endif
00661
00662   protected:
00663     //! Minimum temperature the representation is valid(kelvin)
00664     doublereal m_lowT;
00665     //! Midrange temperature (kelvin)
00666     doublereal m_midT;
00667     //! Maximum temperature the representation is valid (kelvin)
00668     doublereal m_highT;
00669     //! Reference pressure (Pascal)
00670     doublereal m_Pref;
00671     //! Pointer to the Shomate polynomial for the low temperature region.
00672     ShomatePoly *msp_low;
00673     //! Pointer to the Shomate polynomial for the high temperature region.
00674     ShomatePoly *msp_high;
00675     //! Array of the original coefficients.
00676     array_fp m_coeff;
00677     //! Species index
00678     int m_index;
00679   };
00680 }
00681
00682 #endif

Generated by  1.6.3