OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
double_trap_kinetics.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2010-13 by Energy Systems Design Laboratory, University of Alberta
6 //
7 // This software is distributed under the MIT License.
8 // For more information, see the README file in /doc/LICENSE
9 //
10 // - Class: double_trap_kinetics.h
11 // - Description: DoubleTrap Kinetics implements the double trap model proposed by
12 // Wang et al. and re-developed by Moore et al.
13 // - Developers: M. Moore, M. Bhaiya, M. Secanell, P. Wardlaw
14 // - $Id: double_trap_kinetics.h 2605 2014-08-15 03:36:44Z secanell $
15 //
16 //---------------------------------------------------------------------------
17 
18 #ifndef _FUELCELLSHOP__DOUBLETRAP_KINETICS_H
19 #define _FUELCELLSHOP__DOUBLETRAP_KINETICS_H
20 
21 // Include openFCST routines:
23 #include <utils/fcst_constants.h>
24 
25 // Include deal.II classes
26 #include <deal.II/base/parameter_handler.h>
27 #include <deal.II/base/point.h>
28 #include <deal.II/base/function.h>
29 #include <deal.II/lac/vector.h>
30 #include <deal.II/fe/fe_values.h>
31 
32 //Include STL
33 #include <cmath>
34 #include <iostream>
35 
36 using namespace dealii;
37 
38 namespace FuelCellShop
39 {
40  namespace Kinetics
41  {
69  public BaseKinetics
70  {
71  public:
73 
74 
85  static const std::string concrete_name;
87 
89 
90 
95  DoubleTrapKinetics(const bool);
107  virtual void declare_parameters(ParameterHandler &param) const;
108 
113  virtual void initialize(ParameterHandler &param);
114 
116 
118 
119 
122  virtual void current_density (std::vector<double>& );
123 
130  virtual void derivative_current (std::map< VariableNames, std::vector<double> >& );
132 
134 
135 
136  inline void OH_coverage(std::vector<double>& temp) const
137  {
138  temp = theta_OH;
139  }
140 
142  inline void O_coverage(std::vector<double>& temp) const
143  {
144  temp = theta_O;
145  }
146 
148  inline void G_DA_rate(std::vector<double>& temp) const
149  {
150  double C;
151  if (reactants_map.at(oxygen_concentration)[0] < 0.0)
152  C = 1.0e-12;
153  else
154  C = pow(((reactants_map.at(oxygen_concentration)[0])/c_ref_oxygen),0.5);
155 
156  std::vector<double> t;
157 
158  for(unsigned int i =0; i < intrinsic_rates[0].size(); i++)
159  t.push_back(C*intrinsic_rates[0][i]);
160 
161  temp = t;//free_energies[0];
162  }
163 
165  inline void g_da_rate(std::vector<double>& temp) const
166  {
167  std::vector<double> t;
168 
169  for(unsigned int i =0; i < intrinsic_rates[1].size(); i++)
170  t.push_back(intrinsic_rates[1][i]*theta_O[i]);
171 
172  temp = t;//free_energies[1];
173  }
174 
176  inline void G_RA_rate(std::vector<double>& temp) const
177  {
178  double C;
179  if (reactants_map.at(oxygen_concentration)[0] < 0.0)
180  C = 1.0e-12;
181  else
182  C = pow(((reactants_map.at(oxygen_concentration)[0])/c_ref_oxygen),0.5);
183 
184  double Ch;
185  if(reactants_map.count(proton_concentration)){
186  Ch=(reactants_map.at(proton_concentration)[0])/c_ref_protons;
187  }
188  else
189  Ch = 1.0;
190 
191 
192  std::vector<double> t;
193  for(unsigned int i =0; i < intrinsic_rates[2].size(); i++)
194  t.push_back(C*Ch*intrinsic_rates[2][i]);
195 
196  temp = t;//free_energies[2];
197  }
198 
200  inline void g_ra_rate(std::vector<double>& temp) const
201  {
202  std::vector<double> t;
203  for(unsigned int i =0; i < intrinsic_rates[3].size(); i++)
204  t.push_back(theta_OH[i]*intrinsic_rates[3][i]);//free_energies[3];
205 
206  temp = t;
207  }
208 
210  inline void G_RT_rate(std::vector<double>& temp) const
211  {
212 
213  double Ch;
214  if(reactants_map.count(proton_concentration)){
215  Ch=(reactants_map.at(proton_concentration)[0])/c_ref_protons;
216  }
217  else
218  Ch = 1.0;
219 
220  std::vector<double> t;
221  for(unsigned int i =0; i < intrinsic_rates[4].size(); i++)
222  t.push_back(theta_O[i]*Ch*intrinsic_rates[4][i]);//free_energies[4];
223 
224  temp = t;
225  }
226 
228  inline void g_rt_rate(std::vector<double>& temp) const
229  {
230  std::vector<double> t;
231  for(unsigned int i =0; i < intrinsic_rates[5].size(); i++)
232  t.push_back(theta_OH[i]*intrinsic_rates[5][i]);
233 
234  temp = t;//free_energies[5];
235  }
236 
238  inline void G_RD_rate(std::vector<double>& temp) const
239  {
240  double Ch;
241  if(reactants_map.count(proton_concentration)){
242  Ch=(reactants_map.at(proton_concentration)[0])/c_ref_protons;
243  }
244  else
245  Ch = 1.0;
246 
247  std::vector<double> t;
248  for(unsigned int i =0; i < intrinsic_rates[6].size(); i++)
249  t.push_back(Ch*theta_OH[i]*intrinsic_rates[6][i]);//free_energies[6];
250 
251  temp = t;
252  }
253 
255  inline void g_rd_rate(std::vector<double>& temp) const
256  {
257  std::vector<double> t;
258  for(unsigned int i =0; i < intrinsic_rates[5].size(); i++)
259  t.push_back(intrinsic_rates[7][i]*(1.0 -theta_OH[i] -theta_O[i]));
260 
261  temp = t;//free_energies[7];
262  }
263 
270  void compute_energies();
272 
274 
275 
279  virtual void set_reaction_kinetics(const ReactionNames & name)
280  {
281  if (name == ORR)
282  {
283  name_reaction_kinetics = name;
284  }
285  else
286  {
287  const std::type_info& info = typeid(*this);
288  FcstUtilities::log << "Only ORR reaction is to be implemented in " << __FUNCTION__ << " called in Class " << info.name() << std::endl;
289  exit(1);
290  }
291  }
293 
294 
295  virtual bool has_coverage(const VariableNames& type){
296 
297  if((type == VariableNames::OH_coverage)or (type == VariableNames::O_coverage))
298  return true;
299 
300  return false;
301  }
302 
303  protected:
304 
306 
307 
312  virtual boost::shared_ptr<FuelCellShop::Kinetics::BaseKinetics > create_replica ()
313  {
314  return boost::shared_ptr<FuelCellShop::Kinetics::BaseKinetics > (new FuelCellShop::Kinetics::DoubleTrapKinetics () );
315  }
321 
322  private:
324 
325 
330  inline double negative_concentration_correction(unsigned int index) const
331  {
332  double correction(1.0);
333 
334  if (reactants_map.at(oxygen_concentration)[index] <= 0.0)
335  correction = 0.0;
336 
337  return correction;
338  }
339 
347  inline double oxygen_concentration_ratio(unsigned int index) const
348  {
349  double ratio;
350  double exponential = 0.5;
351 
352  if (reactants_map.at(oxygen_concentration)[index] < 0.0)
353  ratio = 0.0;
354  else
355  ratio = pow((reactants_map.at(oxygen_concentration)[index]/c_ref_oxygen), exponential);
356 
357  return ratio;
358  }
359 
367  inline double proton_concentration_ratio(unsigned int index) const
368  {
369  double ratio = 1.0;
370 
371  if(reactants_map.count(proton_concentration))
372  ratio =(reactants_map.at(proton_concentration)[index])/c_ref_protons;
373 
374  return ratio;
375  }
379  virtual void init_kin_param()
380  {
381  Assert( !kin_param_initialized, ExcInternalError() );
382  Assert( catalyst != NULL, ExcMessage("Catalyst object not initialized in the DoubleTrapKinetics object.") );
383  Assert( catalyst->get_reaction_name() == ORR, ExcMessage("Catalyst object in the DoubleTrapKinetics not set to ORR reaction name.") );
384  Assert( phi_m.is_initialized() && phi_s.is_initialized() && T.is_initialized(), ExcMessage("Either phi_m/phi_s/T is not set in the DoubleTrapKinetics object.") );
385  Assert( reactants_map.find(oxygen_concentration) != reactants_map.end(), ExcMessage("Oxygen concentration is not set in the DoubleTrapKinetics object.") );
386 
387  std::vector<VariableNames> names(1, oxygen_concentration);
388  names.push_back(proton_concentration);
389  std::map< VariableNames, double > cref_map;
390  catalyst->reference_concentration(names, cref_map);
391 
392  c_ref_oxygen = cref_map[oxygen_concentration];
393  c_ref_protons = cref_map[proton_concentration];
394  kin_param_initialized = true;
395  }
396 
398  void d_OH_coverage_du (std::map< VariableNames, std::vector<double> >& ) const;
399 
401  void d_O_coverage_du (std::map< VariableNames, std::vector<double> >& ) const;
402 
406  void drate_du(std::vector<std::vector<double> >&, const VariableNames& ) const;
407 
419  std::vector<std::vector<double> > free_energies;
420 
431  double G_DA_0, G_RA_0, G_RT_0, G_RD_0;
432 
442  double G_O, G_OH;
443 
448  std::vector<std::vector<double> > intrinsic_rates;
449 
451  std::vector<double> theta_OH, theta_O;
452 
457  double prefactor;
458 
460  double c_ref_oxygen;
461 
464 
466  double alpha;
468  };
469  } //Kinetics
470 } //FuelCellShop
471 
472 #endif //_FUELCELLSHOP__DOUBLETRAP_KINETICS_H
Definition: system_management.h:86
double proton_concentration_ratio(unsigned int index) const
If needed, compute the proton concentration ratio, i.e., where is the variable exponential.
Definition: double_trap_kinetics.h:367
void G_RA_rate(std::vector< double > &temp) const
Returns the rate of the forward RA step.
Definition: double_trap_kinetics.h:176
void g_da_rate(std::vector< double > &temp) const
Returns the rate of the backward DA step.
Definition: double_trap_kinetics.h:165
virtual void set_reaction_kinetics(const ReactionNames &name)
Member function used to set the reaction name in the DoubleTrap kinetics object.
Definition: double_trap_kinetics.h:279
virtual bool has_coverage(const VariableNames &type)
Definition: double_trap_kinetics.h:295
void g_rt_rate(std::vector< double > &temp) const
Returns the rate of the backward RT step.
Definition: double_trap_kinetics.h:228
double negative_concentration_correction(unsigned int index) const
If any of the oxygen concentrations are negative, make the ORR reaction negative. ...
Definition: double_trap_kinetics.h:330
VariableNames
The enumeration containing the names of some of the available FCST solution variables and their deriv...
Definition: system_management.h:63
double alpha
Stores the transfer coefficient.
Definition: double_trap_kinetics.h:466
std::vector< std::vector< double > > intrinsic_rates
Values of the intrinsic rates for each reaction ( ).
Definition: double_trap_kinetics.h:448
std::vector< std::vector< double > > free_energies
Values of the free activation energies for each reaction ( ).
Definition: double_trap_kinetics.h:419
static DoubleTrapKinetics const * PROTOTYPE
Create prototype for the layer.
Definition: double_trap_kinetics.h:319
double c_ref_oxygen
Stores the reference concentration of oxygen.
Definition: double_trap_kinetics.h:460
Definition: system_management.h:84
Definition: system_management.h:83
std::vector< double > theta_OH
Stores the value of the coverage of the OH and O intermediates.
Definition: double_trap_kinetics.h:451
Definition: system_management.h:180
virtual void init_kin_param()
Method used to initialize reference concentration of oxygen for the reaction, and number of quadratur...
Definition: double_trap_kinetics.h:379
void O_coverage(std::vector< double > &temp) const
Returns the value of the coverage of the O intermediate.
Definition: double_trap_kinetics.h:142
void g_ra_rate(std::vector< double > &temp) const
Returns the rate of the backward RA step.
Definition: double_trap_kinetics.h:200
void G_DA_rate(std::vector< double > &temp) const
Returns the rate of the forward DA step.
Definition: double_trap_kinetics.h:148
double G_OH
Definition: double_trap_kinetics.h:442
FCSTLogStream log
Object used to output data to file and, if file attached recorded to a file as well.
ReactionNames
Definition: system_management.h:177
Definition: system_management.h:80
Virtual class used to provide the interface for all kinetic/reaction children.
Definition: base_kinetics.h:102
double G_RT_0
Definition: double_trap_kinetics.h:431
void G_RT_rate(std::vector< double > &temp) const
Returns the rate of the forward RT step.
Definition: double_trap_kinetics.h:210
void OH_coverage(std::vector< double > &temp) const
Returns the value of the coverage of the OH intermediate.
Definition: double_trap_kinetics.h:136
static const std::string concrete_name
Concrete name used for objects of this class.
Definition: double_trap_kinetics.h:85
double prefactor
prefactor is the reference prefactor that sets the scale for the current produced.
Definition: double_trap_kinetics.h:457
void G_RD_rate(std::vector< double > &temp) const
Returns the rate of the forward RD step.
Definition: double_trap_kinetics.h:238
void g_rd_rate(std::vector< double > &temp) const
Returns the rate of the backward RD step.
Definition: double_trap_kinetics.h:255
Definition: system_management.h:90
virtual boost::shared_ptr< FuelCellShop::Kinetics::BaseKinetics > create_replica()
This member function is used to create an object of type gas diffusion layer.
Definition: double_trap_kinetics.h:312
double c_ref_protons
Stores the reference concentration of protons.
Definition: double_trap_kinetics.h:463
double oxygen_concentration_ratio(unsigned int index) const
Compute the oxygen concentration ratio, i.e., where is the variable exponential.
Definition: double_trap_kinetics.h:347
This class contains the implementation of the double trap kinetic model as described in the following...
Definition: double_trap_kinetics.h:68