CG  Version 25
MaterialProperties.h
Go to the documentation of this file.
1 #ifndef MATERIAL_PROPERTIES_H
2 #define MATERIAL_PROPERTIES_H
3 
4 #include "A++.h"
5 
6 // include "realPrecision.h"
7 
9 {
10 public:
11  enum material
12  {
13  O2=0,
14  O,
15  N2,
16  CO,
17  CO2,
18  A,
19  H,
20  H2,
21  H2O,
22  CH4,
24  F,
25  F2,
26  HF,
27  numberOfMaterials // counts items in this enum
28  };
29 
30  enum Units
31  {
32  ee=0,
33  msi,
35  };
36 
37 
38  // NOTE: only si (MKS) units currently supported
39  MaterialProperties( const Units unitsToUse=si );
41 
42  inline double cp( const material & m, const double t ) const;
43  inline double h( const material & m, const double t ) const;
44  inline double hMinusRef( const material & m, const double t ) const;
45  inline double hF( const material & m, const double t ) const;
46  inline double s( const material & m, const double t ) const;
47  inline double lnKp( const material & m, const double t ) const;
48  inline double logKp( const material & m, const double t ) const;
49  inline double Kp( const material & m, const double t ) const;
50  inline double mw (const material & m) const;
51 
52 private:
53 
54  double coeff[numberOfMaterials][2][5]; // materials, 2 temperature ranges, 5 coefficients for cp
55  double h0[numberOfMaterials][2]; // h0
56  double hRef[numberOfMaterials]; // h(tRef)
57  double deltaH[numberOfMaterials]; // deltaH formation
58  double sRef[numberOfMaterials]; // phi(tRef)
59  double phi0[numberOfMaterials][2];
60 
61  double lCoeff[numberOfMaterials][2][6]; // coeff's for lnKp
62 
63  double t0; // coefficients change at this value
64 
65 public:
66  double R;
67  double tRef;
70 
71  Units units; // 0=EE, 1=modified SI using calories, 2=SI using Joules
72 
73 };
74 
75 
77 cp( const material & m, const double t ) const
78  // return \bar{c}_p^0 : mole based, units of R, J/(mole-K) if si (MKS)
79  // t : temperature in K
80 {
81  const double *c = t<t0 ? &(coeff[m][0][0]) : &(coeff[m][1][0]);
82  return (c[0]+t*(c[1]+t*(c[2]+t*(c[3]+t*c[4]))))*R;
83 }
84 
86 h( const material & m, const double t ) const
87  // return \bar{H}^0 : mole based, units of RT, J/(mole) if si (MKS)
88  // t : temperature in K
89 {
90  int mt = t<t0 ? 0 : 1;
91  const double *c = &(coeff[m][mt][0]);
92  return (h0[m][mt] + t*(c[0]+t*(.5*c[1]+t*(c[2]/3.+t*(c[3]*.25+t*c[4]*.2)))))*R;
93 }
94 
96 hMinusRef( const material & m, const double t ) const
97  // return \bar{H}^0-hRef
98  // t : temperature in K
99 {
100  return h(m,t)-hRef[m];
101 }
102 
104 hF( const material & m, const double t ) const
105  // return \bar{H}^0-hRef + DeltaH_f,ref
106  // t : temperature in K
107 {
108  return h(m,t)-hRef[m]+deltaH[m];
109 }
110 
112 s( const material & m, const double t ) const
113  // return \bar{s}^0
114  // t : temperature in K
115 {
116  int mt = t<t0 ? 0 : 1;
117  const double *c = &(coeff[m][mt][0]);
118  return (phi0[m][mt] + log(t)*c[0]+t*(c[1]+t*(.5*c[2]+t*(c[3]/3.+t*c[4]*.25))))*R;
119 }
120 
122 lnKp( const material & m, const double t ) const
123  // return ln(K_p)
124  // t : temperature in K
125  // ln(K_p) = -(1/RT) sum_i (\nu_i^''-\nu_i^')( h_i-T*s_i )
126 {
127  int mt;
128  switch( m )
129  {
130  case H2O:
131  // H2O : (1)*H2O + (-1)H2 - (.5)O2 = 0
132  return ( (t*s(H2O,t)-h(H2O,t)) - (t*s(H2,t)-h(H2,t)) - .5*(t*s(O2,t)-h(O2,t)) )/(R*t);
133  case H2:
134  case O2:
135  case F2:
136  return 0.;
137  case F:
138  case HF:
139  case H:
140  {
141  mt = t<t0 ? 0 : 1;
142  const double *c = &(lCoeff[m][mt][0]);
143  return (c[0]+t*(c[1]+t*(c[2]+t*(c[3]+t*(c[4]+t*c[5])))))*R/t;
144  }
145  }
146  // default:
147  return (t*s(m,t)-h(m,t))/(R*t);
148 }
149 
151 logKp( const material & m, const double t ) const
152  // return log_10(K_p)
153  // t : temperature in K
154  // ln(K_p) = -(1/RT) sum_i (\nu_i^''-\nu_i^')( h_i-T*s_i )
155 {
156  return lnKp(m,t)*log10(exp(1.));
157 }
158 
160 Kp( const material & m, const double t ) const
161  // Return Kp
162  // **** Note that these Kp are based on reference state of pressure of 1 atmosphere
163  // Thus for some Kp you may want to comnvert from atmospheres to N/m^2
164 {
165  return exp(lnKp(m,t));
166 }
167 
169 mw (const material & m) const
170  // molecular weight (kg/mole)
171 {
172  switch( m )
173  {
174  case H2O:
175  return .018016; // 18.016/gramsPerKilogram;
176  case H2:
177  return .002016; // 2.016/gramsPerKilogram;
178  case O2:
179  return .032; // 32.0/gramsPerKilogram;
180  case F2:
181  return .038; // 38.0/gramsPerKilogram;
182  case F:
183  return .019; // 19.0/gramsPerKilogram;
184  case HF:
185  return .020008; // 20.008/gramsPerKilogram;
186  case H:
187  return .001008; // 1.008/gramsPerKilogram;
188  default:
189  printf("mw:ERROR: unknown material\n");
190  throw "error";
191  }
192 }
193 
194 
195 
196 #endif