antioch-0.4.0
chemical_species.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // Antioch - A Gas Dynamics Thermochemistry Library
5 //
6 // Copyright (C) 2014-2016 Paul T. Bauman, Benjamin S. Kirk,
7 // Sylvain Plessis, Roy H. Stonger
8 //
9 // Copyright (C) 2013 The PECOS Development Team
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the Version 2.1 GNU Lesser General
13 // Public License as published by the Free Software Foundation.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
23 // Boston, MA 02110-1301 USA
24 //
25 //-----------------------------------------------------------------------el-
26 //
27 // $Id$
28 //
29 //--------------------------------------------------------------------------
30 //--------------------------------------------------------------------------
31 
32 #ifndef ANTIOCH_CHEMICAL_SPECIES_H
33 #define ANTIOCH_CHEMICAL_SPECIES_H
34 
35 // Antioch
38 
39 // C++
40 #include <string>
41 #include <vector>
42 #include <iostream>
43 
44 namespace Antioch
45 {
47 
53  template<typename CoeffType=double>
55  {
56  public:
57 
59  ChemicalSpecies( const std::string &name,
60  const CoeffType mol_wght,
61  const CoeffType h_form,
62  const CoeffType n_tr_dofs,
63  const int charge );
64 
66 
73 
76 
78  const std::string& species() const;
79 
81  CoeffType molar_mass() const;
82 
84 
89  CoeffType gas_constant() const;
90 
92  CoeffType formation_enthalpy() const;
93 
95  CoeffType n_tr_dofs() const;
96 
98  int charge() const;
99 
101  bool has_vibrational_modes() const;
102 
104  unsigned int n_vibrational_modes() const;
105 
107  const std::vector<CoeffType>& theta_v() const;
108 
110  const std::vector<unsigned int>& ndg_v() const;
111 
113  const std::vector<CoeffType>& theta_e() const;
114 
116  const std::vector<unsigned int>& ndg_e() const;
117 
119  void add_vibrational_data(const CoeffType theta_v,
120  const CoeffType ndg_v);
121 
123  void add_electronic_data(const CoeffType theta_e,
124  const CoeffType ndg_e);
125 
127 
130  void print(std::ostream &os = std::cout) const;
131 
133 
136  friend std::ostream& operator<<( std::ostream& os,
137  const ChemicalSpecies<CoeffType>& species )
138  {
139  species.print(os);
140  return os;
141  }
142 
143  protected:
144 
146  const std::string _name;
147 
149  const CoeffType _mol_wght;
150 
152  const CoeffType _R;
153 
155  const CoeffType _h_form;
156 
158  const CoeffType _n_tr_dofs;
159 
161  const int _charge;
162 
164  std::vector<CoeffType> _theta_v;
165 
167  std::vector<unsigned int> _ndg_v;
168 
170  std::vector<CoeffType> _theta_e;
171 
173  std::vector<unsigned int> _ndg_e;
174 
175  }; // class ChemicalSpecies
176 
177 
178  /* ------------------------- Friend Functions ------------------------- */
179 
180 
181 
182  /* ------------------------- Inline Functions ------------------------- */
183 
184  template<typename CoeffType>
185  inline
186  const std::string& ChemicalSpecies<CoeffType>::species() const
187  { return _name; }
188 
189  template<typename CoeffType>
190  inline
192  { return _mol_wght; }
193 
194  template<typename CoeffType>
195  inline
197  { return _R; }
198 
199  template<typename CoeffType>
200  inline
202  { return _h_form; }
203 
204  template<typename CoeffType>
205  inline
207  { return _n_tr_dofs; }
208 
209  template<typename CoeffType>
210  inline
212  { return _charge; }
213 
214  template<typename CoeffType>
215  inline
217  { return !_theta_v.empty(); }
218 
219  template<typename CoeffType>
220  inline
222  {
223  antioch_assert_equal_to(_theta_v.size(), _ndg_v.size());
224  return _theta_v.size();
225  }
226 
227  template<typename CoeffType>
228  inline
229  const std::vector<CoeffType>& ChemicalSpecies<CoeffType>::theta_v() const
230  { return _theta_v; }
231 
232  template<typename CoeffType>
233  inline
234  const std::vector<unsigned int>& ChemicalSpecies<CoeffType>::ndg_v() const
235  { return _ndg_v; }
236 
237  template<typename CoeffType>
238  inline
239  const std::vector<CoeffType>& ChemicalSpecies<CoeffType>::theta_e() const
240  { return _theta_e; }
241 
242  template<typename CoeffType>
243  inline
244  const std::vector<unsigned int>& ChemicalSpecies<CoeffType>::ndg_e() const
245  { return _ndg_e; }
246 
247 
248  template<typename CoeffType>
249  inline
251  const CoeffType ndg_v)
252  {
253  _theta_v.push_back(theta_v);
254  _ndg_v.push_back(ndg_v);
255  }
256 
257  template<typename CoeffType>
258  inline
260  const CoeffType ndg_e)
261  {
262  _theta_e.push_back(theta_e);
263  _ndg_e.push_back(ndg_e);
264  }
265 
266  template<typename CoeffType>
267  inline
269  const CoeffType mol_wght,
270  const CoeffType h_form,
271  const CoeffType n_tr_dofs,
272  const int charge )
273  : _name (name),
274  _mol_wght (mol_wght),
275  _R (Constants::R_universal<CoeffType>()/mol_wght),
276  _h_form (h_form),
277  _n_tr_dofs (n_tr_dofs),
278  _charge (charge)
279  {
280  return;
281  }
282 
283 
284  template<typename CoeffType>
285  inline
287  : _name("Err"),
288  _mol_wght(0),
289  _R(0),
290  _h_form(0),
291  _n_tr_dofs(0),
292  _charge(0)
293  {
294  antioch_error();
295  return;
296  }
297 
298 
299  template<typename CoeffType>
300  inline
302  {
303  return;
304  }
305 
306 
307  template<typename CoeffType>
308  inline
309  void ChemicalSpecies<CoeffType>::print (std::ostream &os) const
310  {
311  os << " -----------------------------\n"
312  << "| Species " << this->species() << '\n'
313  << " -----------------------------\n"
314  << std::scientific
315  << " Mol Wgt = " << this->molar_mass() << '\n'
316  << " R = " << this->gas_constant() << '\n'
317  << " h0 = " << this->formation_enthalpy() << '\n'
318  << " n_tr = " << this->n_tr_dofs() << '\n'
319  << " charge = " << this->charge() << '\n';
320 
321  for (unsigned int l=0; l<this->theta_v().size(); l++)
322  os << " theta_v_" << l << " = " << this->theta_v()[l]
323  << ", ndg = " << this->ndg_v()[l] << "\n";
324 
325  for (unsigned int l=0; l<this->theta_e().size(); l++)
326  os << " theta_e_" << l << " = " << this->theta_e()[l]
327  << ", ndg = " << this->ndg_e()[l] << "\n";
328 
329  os << '\n';
330 
331  return;
332  }
333 
334 
335 } // end namespace Antioch
336 
337 #endif // ANTIOCH_CHEMICAL_SPECIES_H
void print(std::ostream &os=std::cout) const
Formatted print.
CoeffType R_universal()
Universal Gas Constant, R, expressed in J/(mol-K)
bool has_vibrational_modes() const
Returns true if the chemical species has vibrational degrees.
std::vector< unsigned int > _ndg_v
Degeneracies for each vibrational mode.
unsigned int n_vibrational_modes() const
Returns true if the chemical species has vibrational degrees of freedom.
CoeffType formation_enthalpy() const
Returns formation enthalpy in units of [J/kg].
std::vector< CoeffType > _theta_v
Characteristic vibrational temperature in units of [K].
#define antioch_assert_equal_to(expr1, expr2)
const CoeffType _R
Gas constant in units of [J/kg-K].
const CoeffType _h_form
Formation enthalpy in units of [J/kg].
const std::string & species() const
Returns a descriptive name for this species.
void add_vibrational_data(const CoeffType theta_v, const CoeffType ndg_v)
Supply vibrational data.
ChemicalSpecies()
Default constructor.
const int _charge
Electrical charge number.
#define antioch_error()
const std::vector< CoeffType > & theta_v() const
Characteristic vibrational temperature [K].
const std::vector< unsigned int > & ndg_v() const
Degeneracies for each vibrational mode.
Class to encapsulate data for each chemical species.
int charge() const
Returns electrical charge number.
std::vector< CoeffType > _theta_e
Characteristic electronic temperature in units of [K].
const CoeffType _n_tr_dofs
Number of translational degrees of freedom.
CoeffType n_tr_dofs() const
Returns number of translational degrees of freedom.
const std::vector< unsigned int > & ndg_e() const
Degeneracies for each electronic modes.
std::vector< unsigned int > _ndg_e
Degeneracies for each electronic mode.
CoeffType gas_constant() const
Returns the species ideal gas constant in [J/kg-K].
The parameters are reduced parameters.
void add_electronic_data(const CoeffType theta_e, const CoeffType ndg_e)
Supply electronic data.
const std::string _name
Name of chemical species.
CoeffType molar_mass() const
Returns the molar mass in (kg/mol)
const CoeffType _mol_wght
Molecular weight (or molar mass) in units of [kg/mol].
friend std::ostream & operator<<(std::ostream &os, const ChemicalSpecies< CoeffType > &species)
Formatted print.
const std::vector< CoeffType > & theta_e() const
Characteristic electronic excitation temperatures [K].

Generated on Thu Jul 7 2016 11:09:45 for antioch-0.4.0 by  doxygen 1.8.8