ConstCpPoly.cpp

Go to the documentation of this file.
00001 /**
00002  *  @file ConstCpPoly.cpp
00003  * Declarations for the \link Cantera::SpeciesThermoInterpType SpeciesThermoInterpType \endlink object that
00004  * employs a constant heat capacity assumption (see \ref spthermo and
00005  * \link Cantera::ConstCpPoly ConstCpPoly \endlink).
00006  */
00007 /*
00008  * $Author: hkmoffa $
00009  * $Revision: 279 $
00010  * $Date: 2009-12-05 14:08:43 -0500 (Sat, 05 Dec 2009) $
00011  */
00012 
00013 // Copyright 2001  California Institute of Technology
00014 
00015 
00016 
00017 #include "ConstCpPoly.h"
00018 
00019 #include <cmath>
00020 
00021 namespace Cantera {
00022 
00023   ConstCpPoly::ConstCpPoly() 
00024     :  m_t0(0.0),
00025        m_cp0_R(0.0),
00026        m_h0_R(0.0),
00027        m_s0_R(0.0),
00028        m_logt0(0.0),
00029        m_lowT(0.0),
00030        m_highT(0.0),
00031        m_Pref(0.0),
00032        m_index(0) {
00033   }
00034     
00035   ConstCpPoly::ConstCpPoly(int n, doublereal tlow, doublereal thigh, 
00036                            doublereal pref,
00037                            const doublereal* coeffs) :
00038     m_lowT      (tlow),
00039     m_highT     (thigh),
00040     m_Pref      (pref),
00041     m_index     (n) {
00042     m_t0 = coeffs[0];
00043     m_h0_R = coeffs[1]  / GasConstant;
00044     m_s0_R = coeffs[2]  / GasConstant;
00045     m_cp0_R = coeffs[3] / GasConstant;
00046     m_logt0 = log(m_t0);
00047   }
00048 
00049   ConstCpPoly::ConstCpPoly(const ConstCpPoly& b) :
00050     m_t0        (b.m_t0),
00051     m_cp0_R     (b.m_cp0_R),
00052     m_h0_R      (b.m_h0_R),
00053     m_s0_R      (b.m_s0_R),
00054     m_logt0     (b.m_logt0),
00055     m_lowT      (b.m_lowT),
00056     m_highT     (b.m_highT),
00057     m_Pref      (b.m_Pref),
00058     m_index     (b.m_index)
00059   {
00060   }    
00061 
00062   ConstCpPoly& ConstCpPoly::operator=(const ConstCpPoly& b) {
00063     if (&b != this) {
00064       m_t0    = b.m_t0;
00065       m_cp0_R = b.m_cp0_R;
00066       m_h0_R  = b.m_h0_R;
00067       m_s0_R  = b.m_s0_R;
00068       m_logt0 = b.m_logt0;
00069       m_lowT  = b.m_lowT;
00070       m_highT = b.m_highT;
00071       m_Pref  = b.m_Pref;
00072       m_index = b.m_index;
00073     }
00074     return *this;
00075   }
00076     
00077   ConstCpPoly::~ConstCpPoly(){}
00078 
00079   SpeciesThermoInterpType *
00080   ConstCpPoly::duplMyselfAsSpeciesThermoInterpType() const {
00081     ConstCpPoly* newCCP = new ConstCpPoly(*this);
00082     return (SpeciesThermoInterpType*) newCCP;
00083   }
00084 
00085   doublereal ConstCpPoly::minTemp() const {
00086     return m_lowT;
00087   }
00088   doublereal ConstCpPoly::maxTemp() const { 
00089     return m_highT;
00090   }
00091   doublereal ConstCpPoly::refPressure() const { 
00092     return m_Pref;
00093   }
00094       
00095   void ConstCpPoly::updateProperties(const doublereal* tt, 
00096                                      doublereal* cp_R,
00097                                      doublereal* h_RT,
00098                                      doublereal* s_R) const {
00099     double t = *tt;
00100     doublereal logt = log(t);
00101     doublereal rt = 1.0/t;
00102     cp_R[m_index] = m_cp0_R;
00103     h_RT[m_index] = rt*(m_h0_R + (t - m_t0) * m_cp0_R);
00104     s_R[m_index]  = m_s0_R + m_cp0_R * (logt - m_logt0);
00105   }
00106 
00107   void ConstCpPoly::updatePropertiesTemp(const doublereal temp, 
00108                                          doublereal* cp_R,
00109                                          doublereal* h_RT,
00110                                          doublereal* s_R) const {
00111     doublereal logt = log(temp);
00112     doublereal rt = 1.0/temp;
00113     cp_R[m_index] = m_cp0_R;
00114     h_RT[m_index] = rt*(m_h0_R + (temp - m_t0) * m_cp0_R);
00115     s_R[m_index]  = m_s0_R + m_cp0_R * (logt - m_logt0);
00116   }
00117 
00118   void ConstCpPoly::reportParameters(int &n, int &type,
00119                                      doublereal &tlow, doublereal &thigh,
00120                                      doublereal &pref,
00121                                      doublereal* const coeffs) const {
00122     n = m_index;
00123     type = CONSTANT_CP;
00124     tlow = m_lowT;
00125     thigh = m_highT;
00126     pref = m_Pref;
00127     coeffs[0] = m_t0;
00128     coeffs[1] = m_h0_R * GasConstant;
00129     coeffs[2] = m_s0_R * GasConstant;
00130     coeffs[3] = m_cp0_R * GasConstant;
00131   }
00132 
00133   void ConstCpPoly::modifyParameters(doublereal* coeffs) {
00134     m_t0 = coeffs[0];
00135     m_h0_R = coeffs[1]  / GasConstant;
00136     m_s0_R = coeffs[2]  / GasConstant;
00137     m_cp0_R = coeffs[3] / GasConstant;
00138     m_logt0 = log(m_t0);
00139   }
00140 
00141 #ifdef H298MODIFY_CAPABILITY
00142 
00143   doublereal ConstCpPoly::reportHf298(doublereal* const h298) const {
00144     double temp = 298.15;
00145     doublereal h = GasConstant * (m_h0_R + (temp - m_t0) * m_cp0_R);
00146     if (h298) {
00147       h298[m_index] = h;
00148     }
00149     return h;
00150   }
00151   
00152   void ConstCpPoly::modifyOneHf298(const int k, const doublereal Hf298New) {
00153     if (k != m_index) return;
00154     doublereal hnow = reportHf298();
00155     doublereal delH = Hf298New - hnow;
00156     m_h0_R += delH / GasConstant;
00157   }
00158   
00159 #endif
00160 
00161 }
00162 
00163 
Generated by  doxygen 1.6.3