OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
base_kinetics.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2013 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: base_kinetics.h
11 // - Description: Base Kinetics. It implements the interface for other kinetics classes
12 // and some common methods.
13 // - Developers: M. Moore, M. Bhaiya, M. Secanell and V. Zingan
14 //
15 //---------------------------------------------------------------------------
16 
17 #ifndef _FUELCELLSHOP__BASE__KINETICS_H
18 #define _FUELCELLSHOP__BASE__KINETICS_H
19 
20 // Include deal.II classes
21 #include <deal.II/base/parameter_handler.h>
22 #include <deal.II/base/point.h>
23 #include <deal.II/base/function.h>
24 #include <deal.II/lac/vector.h>
25 #include <deal.II/fe/fe_values.h>
26 
27 // Include STL
28 #include <cmath>
29 #include <iostream>
30 #include <map>
31 #include <algorithm>
32 
33 // Include OpenFCST routines:
34 #include <layers/base_layer.h>
37 #include <utils/fcst_constants.h>
39 
40 using namespace dealii;
41 
42 namespace FuelCellShop
43 {
44  namespace Kinetics
45  {
103  {
104  public:
105 
109  virtual ~BaseKinetics()
110  {};
111 
113 
118  static void declare_Kinetics_parameters (ParameterHandler &param)
119  {
120 
121  for (typename FuelCellShop::Kinetics::BaseKinetics::_mapFactory::iterator iterator = FuelCellShop::Kinetics::BaseKinetics::get_mapFactory()->begin();
123  iterator++)
124  {
125  iterator->second->declare_parameters(param);
126  }
127  }
128 
147  static boost::shared_ptr<FuelCellShop::Kinetics::BaseKinetics > create_Kinetics (ParameterHandler &param,
148  std::string kinetics_name)
149  {
150 
151  boost::shared_ptr<FuelCellShop::Kinetics::BaseKinetics > pointer;
152 
153  typename FuelCellShop::Kinetics::BaseKinetics::_mapFactory::iterator iterator = FuelCellShop::Kinetics::BaseKinetics::get_mapFactory()->find(kinetics_name);
154 
156  {
157  if (iterator->second)
158  {
159  pointer = iterator->second->create_replica();
160  }
161  else
162  {
163  FcstUtilities::log<<"Pointer not initialized"<<std::endl;
164  abort();
165  }
166  }
167  else
168  {
169  FcstUtilities::log<<"Concrete name does not exist"<<std::endl;
170  abort();
171  }
172 
173  pointer->initialize(param);
174 
175  return pointer;
176  }
178 
180 
181 
187  {
188  Assert( phi.get_variablename() == protonic_electrical_potential, ExcMessage("Wrong solution variable passed in BaseKinetics::set_electrolyte_potential.") );
189  phi_m = phi;
190  }
195  {
196  Assert( phi.get_variablename() == electronic_electrical_potential, ExcMessage("Wrong solution variable passed in BaseKinetics::set_solid_potential.") );
197  phi_s = phi;
198  }
202  void set_temperature(const SolutionVariable& temperature)
203  {
204  Assert( temperature.get_variablename() == temperature_of_REV, ExcMessage("Wrong solution variable passed in BaseKinetics::set_temperature") );
205  T = temperature;
206  }
214  void set_reactant_concentrations(const std::vector<SolutionVariable>& conc_vec)
215  {
216  Assert( conc_vec.size() > 0, ExcMessage("Atleast one reactant concentration should be passed inside BaseKinetics::set_reactant_concentrations. !!") );
217 
218  for ( unsigned int i=0; i<conc_vec.size(); ++i )
219  {
220  Assert( (conc_vec[i].get_variablename() != hydrogen_molar_fraction &&
221  conc_vec[i].get_variablename() != oxygen_molar_fraction &&
222  conc_vec[i].get_variablename() != water_molar_fraction), ExcMessage("Molar fractions can't be setup using BaseKinetics::set_reactant_concentrations.") );
223 
224  reactants_map[ conc_vec[i].get_variablename() ] = conc_vec[i];
225  }
226  }
227 
231  void set_derivative_flags(const std::vector<VariableNames>& flags)
232  {
233  derivative_flags = flags;
234  };
235 
241  {
242  catalyst = cat_in;
243  }
244 
251  {
252  electrolyte = electrolyte_in;
253  }
254 
260  virtual void set_reaction_kinetics(const ReactionNames name)
261  {
262  name_reaction_kinetics = name;
263  }
264 
266  void set_p_t(const double& P_Tot)
267  {
268  p_total = P_Tot;
269  }
271 
273 
277  {
278  return name_reaction_kinetics;
279  }
280 
283  {
284  return catalyst;
285 
286  }
287 
291  virtual void current_density (std::vector<double>&)
292  {
293  const std::type_info& info = typeid(*this);
294  FcstUtilities::log << "Pure function " << __FUNCTION__
295  << " called in Class "
296  << info.name() << std::endl;
297 
298  };
299 
306  virtual void derivative_current (std::map< VariableNames, std::vector<double> >&)
307  {
308  const std::type_info& info = typeid(*this);
309  FcstUtilities::log << "Pure function " << __FUNCTION__
310  << " called in Class "
311  << info.name() << std::endl;
312  }
313 
317  virtual void compute_coverages(const std::string& name_species,
318  std::vector<double>& coverage) const
319  {
320  const std::type_info& info = typeid(*this);
321  FcstUtilities::log << "Pure function " << __FUNCTION__
322  << " called in Class "
323  << info.name() << std::endl;
324  };
330  virtual void OH_coverage(std::vector<double>& ) const
331  {
332  const std::type_info& info = typeid(*this);
333  FcstUtilities::log << "Pure function " << __FUNCTION__
334  << " called in Class "
335  << info.name() << std::endl;
336  };
337 
343  virtual void O_coverage(std::vector<double>& ) const
344  {
345  const std::type_info& info = typeid(*this);
346  FcstUtilities::log << "Pure function " << __FUNCTION__
347  << " called in Class "
348  << info.name() << std::endl;
349  }
350 
352 
353  virtual bool has_coverage(const VariableNames& type){
354  return false;
355  }
356 
357 
358  protected:
359 
361 
362 
365  typedef std::map< std::string, BaseKinetics* > _mapFactory;
367 
369 
370 
374  {
375  static _mapFactory mapFactory;
376  return &mapFactory;
377  }
379 
381 
382 
387  virtual boost::shared_ptr<FuelCellShop::Kinetics::BaseKinetics > create_replica ()
388  {
389  const std::type_info& info = typeid(*this);
390  FcstUtilities::log << "Pure function " << __FUNCTION__
391  << " called in Class "
392  << info.name() << std::endl;
393  }
395 
397 
398 
402  {
403  //FcstUtilities::log << "Creating kinetics object of type ";
404 
405  catalyst = NULL;
406  electrolyte = NULL;
407 
408  // Universal constants
409  R = Constants::R();
410  F = Constants::F();
411  K = Constants::K();
412 
413  kin_param_initialized = false;
414  };
415 
419  virtual void declare_parameters (ParameterHandler&) const
420  {
421  const std::type_info& info = typeid(*this);
422  FcstUtilities::log << "Pure function " << __FUNCTION__
423  << " called in Class "
424  << info.name() << std::endl;
425 
426  };
427 
432  virtual void initialize (ParameterHandler&)
433  {
434  const std::type_info& info = typeid(*this);
435  FcstUtilities::log << "Pure function " << __FUNCTION__
436  << " called in Class "
437  << info.name() << std::endl;
438  };
440 
442 
443 
448  virtual void init_kin_param() = 0;
449 
454 
459 
464  std::vector<VariableNames> derivative_flags;
465 
469  unsigned int n_quad;
470 
482 
484 
485 
486  double R;
488  double F;
489  //Boltzmann constant
491  double K;
493 
495 
496 
497  double p_total;
498 
503  std::map< VariableNames, SolutionVariable > reactants_map;
504 
507 
509  SolutionVariable phi_s
510  ;
514 
515  }; // BaseKinetics
516  } // Kinetics
517 } // FuelCellShop
518 
519 #endif
std::map< VariableNames, SolutionVariable > reactants_map
Map of SolutionVariables storing a pointer to the solution vector storing the concentration of each o...
Definition: base_kinetics.h:503
BaseKinetics()
Constructor.
Definition: base_kinetics.h:401
unsigned int n_quad
Number of quadrature points in the cell.
Definition: base_kinetics.h:469
ReactionNames name_reaction_kinetics
Enumeration with the reaction name for which the class returns kinetic parameters.
Definition: base_kinetics.h:458
virtual ~BaseKinetics()
Destructor.
Definition: base_kinetics.h:109
virtual void initialize(ParameterHandler &)
Member function used to read in data and initialize the necessary data to compute the coefficients...
Definition: base_kinetics.h:432
void set_catalyst(FuelCellShop::Material::CatalystBase *cat_in)
Set a pointer to the catalyst that will be used.
Definition: base_kinetics.h:240
double F()
Faraday constant, .
Definition: fcst_constants.h:37
void set_p_t(const double &P_Tot)
Set the total gas pressure [Pascals] in the cell.
Definition: base_kinetics.h:266
VariableNames get_variablename() const
Function to get the VariableNames enumeration corresponding to this struct.
Definition: fcst_variables.h:170
static boost::shared_ptr< FuelCellShop::Kinetics::BaseKinetics > create_Kinetics(ParameterHandler &param, std::string kinetics_name)
Function called in create_CatalystLayer and used to select the appropriate BaseKinetics type that wil...
Definition: base_kinetics.h:147
double K
Boltzmann constant.
Definition: base_kinetics.h:491
VariableNames
The enumeration containing the names of some of the available FCST solution variables and their deriv...
Definition: system_management.h:63
This structure is used to encapsulate data from constant values and variable solution data that is us...
Definition: fcst_variables.h:86
double p_total
Total gas pressure [Pascals] in the cell for isobaric case.
Definition: base_kinetics.h:497
Definition: system_management.h:71
SolutionVariable phi_m
Struct storing a pointer to the solution vector for the electrolyte potential.
Definition: base_kinetics.h:506
This class implements the interface to compute the properties of a &quot;standard&quot; catalyst.
Definition: catalyst_base.h:65
void set_derivative_flags(const std::vector< VariableNames > &flags)
Set the variables for which you would like to compute the derivaitives.
Definition: base_kinetics.h:231
void set_temperature(const SolutionVariable &temperature)
Set temperature.
Definition: base_kinetics.h:202
virtual void derivative_current(std::map< VariableNames, std::vector< double > > &)
Function to return the derivative of the current density w.r.t solution variables.
Definition: base_kinetics.h:306
double R
Universal gas constant.
Definition: base_kinetics.h:486
SolutionVariable T
Struct stroing a pointer to the solution vector for the temperature.
Definition: base_kinetics.h:512
static void declare_Kinetics_parameters(ParameterHandler &param)
Function used to declare all the data necessary in the parameter files for all BaseKinetics children...
Definition: base_kinetics.h:118
virtual void declare_parameters(ParameterHandler &) const
Declare parameters for a parameter file.
Definition: base_kinetics.h:419
Definition: system_management.h:69
Definition: system_management.h:76
void set_electrolyte(FuelCellShop::Material::PolymerElectrolyteBase *electrolyte_in)
Member function used to set the electrolyte pointer to that used by the application.
Definition: base_kinetics.h:250
double R()
Universal gas constant, .
Definition: fcst_constants.h:32
virtual void OH_coverage(std::vector< double > &) const
Used to return the coverage of the intermediate species if they are computed.
Definition: base_kinetics.h:330
virtual void O_coverage(std::vector< double > &) const
Used to return the coverage of the intermediate species if they are computed.
Definition: base_kinetics.h:343
void set_electrolyte_potential(const SolutionVariable &phi)
Set the electrolyte phase potential.
Definition: base_kinetics.h:186
void set_reactant_concentrations(const std::vector< SolutionVariable > &conc_vec)
Set reactant concentrations at the catalyst/electrolyte interface.
Definition: base_kinetics.h:214
std::map< std::string, BaseKinetics * > _mapFactory
This object is used to store all objects of type BaseKinetics.
Definition: base_kinetics.h:365
FuelCellShop::Material::PolymerElectrolyteBase * electrolyte
Pointer to the electrolyte object created in the application that is used to calculate the properties...
Definition: base_kinetics.h:480
FCSTLogStream log
Object used to output data to file and, if file attached recorded to a file as well.
void set_solid_potential(const SolutionVariable &phi)
Set the solid phase potential.
Definition: base_kinetics.h:194
virtual boost::shared_ptr< FuelCellShop::Kinetics::BaseKinetics > create_replica()
This member function is used to create an object of type BaseKinetics.
Definition: base_kinetics.h:387
ReactionNames
Definition: system_management.h:177
This class implements the interface to compute the properties of a &quot;standard&quot; polymer electrolyte mem...
Definition: polymer_electrolyte_material_base.h:59
Definition: system_management.h:68
static _mapFactory * get_mapFactory()
Definition: base_kinetics.h:373
Virtual class used to provide the interface for all kinetic/reaction children.
Definition: base_kinetics.h:102
virtual void compute_coverages(const std::string &name_species, std::vector< double > &coverage) const
Used to return the coverage of the intermediate species if they are computed.
Definition: base_kinetics.h:317
double F
Universal Farday&#39;s constant.
Definition: base_kinetics.h:488
virtual void set_reaction_kinetics(const ReactionNames name)
Member function used to specify the reaction for which the kinetic parameters are needed...
Definition: base_kinetics.h:260
Definition: system_management.h:67
ReactionNames get_reaction_name() const
Returns the name of the reaction that this kinetics class is using.
Definition: base_kinetics.h:276
double K()
Boltzmann constant, .
Definition: fcst_constants.h:52
bool kin_param_initialized
Boolean variable to determine whether init_kin_param has been already called or not.
Definition: base_kinetics.h:453
Definition: system_management.h:72
virtual bool has_coverage(const VariableNames &type)
Definition: base_kinetics.h:353
FuelCellShop::Material::CatalystBase * get_cat() const
Function to get pointer to catalyst class.
Definition: base_kinetics.h:282
virtual void current_density(std::vector< double > &)
Function to return the value of the current [A/cm^2].
Definition: base_kinetics.h:291
FuelCellShop::Material::CatalystBase * catalyst
Pointer to the catalyst object that is created at the application level and passed to the kinetics cl...
Definition: base_kinetics.h:475
std::vector< VariableNames > derivative_flags
Flags for derivatives: These flags are used to request derivatives which are computed using the deriv...
Definition: base_kinetics.h:464