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 // - $Id: base_kinetics.h 2605 2014-08-15 03:36:44Z secanell $
15 //
16 //---------------------------------------------------------------------------
17 
18 #ifndef _FUELCELLSHOP__BASE__KINETICS_H
19 #define _FUELCELLSHOP__BASE__KINETICS_H
20 
21 // Include deal.II classes
22 #include <base/parameter_handler.h>
23 #include <base/point.h>
24 #include <base/function.h>
25 #include <lac/vector.h>
26 #include <fe/fe_values.h>
27 
28 // Include STL
29 #include <cmath>
30 #include <iostream>
31 #include <map>
32 #include <algorithm>
33 
34 // Include OpenFCST routines:
35 #include "base_layer.h"
36 #include "catalyst_base.h"
38 #include "fcst_constants.h"
39 #include "system_management.h"
40 
41 using namespace dealii;
42 
43 namespace FuelCellShop
44 {
45  namespace Kinetics
46  {
108  {
109  public:
110 
112 
117  static void declare_Kinetics_parameters (ParameterHandler &param)
118  {
119 
120  for (typename FuelCellShop::Kinetics::BaseKinetics::_mapFactory::iterator iterator = FuelCellShop::Kinetics::BaseKinetics::get_mapFactory()->begin();
122  iterator++)
123  {
124  iterator->second->declare_parameters(param);
125  }
126  }
127 
146  static boost::shared_ptr<FuelCellShop::Kinetics::BaseKinetics > create_Kinetics (ParameterHandler &param,
147  std::string kinetics_name)
148  {
149 
150  boost::shared_ptr<FuelCellShop::Kinetics::BaseKinetics > pointer;
151 
152  typename FuelCellShop::Kinetics::BaseKinetics::_mapFactory::iterator iterator = FuelCellShop::Kinetics::BaseKinetics::get_mapFactory()->find(kinetics_name);
153 
155  {
156  if (iterator->second)
157  {
158  pointer = iterator->second->create_replica();
159  }
160  else
161  {
162  FcstUtilities::log<<"Pointer not initialized"<<std::endl;
163  abort();
164  }
165  }
166  else
167  {
168  FcstUtilities::log<<"Concrete name does not exist"<<std::endl;
169  abort();
170  }
171 
172  pointer->initialize(param);
173 
174  return pointer;
175  }
177 
179 
180 
186  {
187  Assert( phi.get_variablename() == protonic_electrical_potential, ExcMessage("Wrong solution variable passed in BaseKinetics::set_electrolyte_potential.") );
188  phi_m = phi;
189  }
194  {
195  Assert( phi.get_variablename() == electronic_electrical_potential, ExcMessage("Wrong solution variable passed in BaseKinetics::set_solid_potential.") );
196  phi_s = phi;
197  }
201  void set_temperature(const SolutionVariable& temperature)
202  {
203  Assert( temperature.get_variablename() == temperature_of_REV, ExcMessage("Wrong solution variable passed in BaseKinetics::set_temperature") );
204  T = temperature;
205  }
209  void set_reactant_concentrations(const std::vector<SolutionVariable>& conc_vec)
210  {
211  Assert( conc_vec.size() > 0, ExcMessage("Atleast one reactant concentration should be passed inside BaseKinetics::set_reactant_concentrations. !!") );
212 
213  for ( unsigned int i=0; i<conc_vec.size(); ++i )
214  {
215  Assert( (conc_vec[i].get_variablename() != hydrogen_molar_fraction &&
216  conc_vec[i].get_variablename() != oxygen_molar_fraction &&
217  conc_vec[i].get_variablename() != water_molar_fraction), ExcMessage("Molar fractions can't be setup using BaseKinetics::set_reactant_concentrations.") );
218 
219  reactants_map[ conc_vec[i].get_variablename() ] = conc_vec[i];
220  }
221  }
222 
226  void set_derivative_flags(const std::vector<VariableNames>& flags)
227  {
228  derivative_flags = flags;
229  };
230 
236  {
237  catalyst = cat_in;
238  }
239 
246  {
247  electrolyte = electrolyte_in;
248  }
249 
255  virtual void set_reaction_kinetics(const ReactionNames name)
256  {
257  name_reaction_kinetics = name;
258  }
259 
261  void set_p_t(const double& P_Tot)
262  {
263  p_total = P_Tot;
264  }
266 
268 
272  {
273  return name_reaction_kinetics;
274  }
275 
278  {
279  return catalyst;
280 
281  }
282 
286  virtual void current_density (std::vector<double>&)
287  {
288  const std::type_info& info = typeid(*this);
289  FcstUtilities::log << "Pure function " << __FUNCTION__
290  << " called in Class "
291  << info.name() << std::endl;
292 
293  };
294 
301  virtual void derivative_current (std::map< VariableNames, std::vector<double> >&)
302  {
303  const std::type_info& info = typeid(*this);
304  FcstUtilities::log << "Pure function " << __FUNCTION__
305  << " called in Class "
306  << info.name() << std::endl;
307  }
308 
312  virtual void compute_coverages(const std::string& name_species,
313  std::vector<double>& coverage) const
314  {
315  const std::type_info& info = typeid(*this);
316  FcstUtilities::log << "Pure function " << __FUNCTION__
317  << " called in Class "
318  << info.name() << std::endl;
319  };
325  virtual void OH_coverage(std::vector<double>& ) const
326  {
327  const std::type_info& info = typeid(*this);
328  FcstUtilities::log << "Pure function " << __FUNCTION__
329  << " called in Class "
330  << info.name() << std::endl;
331  };
332 
338  virtual void O_coverage(std::vector<double>& ) const
339  {
340  const std::type_info& info = typeid(*this);
341  FcstUtilities::log << "Pure function " << __FUNCTION__
342  << " called in Class "
343  << info.name() << std::endl;
344  }
345 
347 
348  virtual bool has_coverage(const VariableNames& type){
349  return false;
350  }
351 
352 
353  protected:
354 
356 
357 
360  typedef std::map< std::string, BaseKinetics* > _mapFactory;
362 
364 
365 
369  {
370  static _mapFactory mapFactory;
371  return &mapFactory;
372  }
374 
376 
377 
382  virtual boost::shared_ptr<FuelCellShop::Kinetics::BaseKinetics > create_replica ()
383  {
384  const std::type_info& info = typeid(*this);
385  FcstUtilities::log << "Pure function " << __FUNCTION__
386  << " called in Class "
387  << info.name() << std::endl;
388  }
390 
392 
393 
397  {
398  //FcstUtilities::log << "Creating kinetics object of type ";
399 
400  catalyst = NULL;
401  electrolyte = NULL;
402 
403  // Universal constants
404  R = Constants::R();
405  F = Constants::F();
406  K = Constants::K();
407 
408  kin_param_initialized = false;
409  };
410 
414  virtual ~BaseKinetics()
415  {};
416 
420  virtual void declare_parameters (ParameterHandler&) const
421  {
422  const std::type_info& info = typeid(*this);
423  FcstUtilities::log << "Pure function " << __FUNCTION__
424  << " called in Class "
425  << info.name() << std::endl;
426 
427  };
428 
433  virtual void initialize (ParameterHandler&)
434  {
435  const std::type_info& info = typeid(*this);
436  FcstUtilities::log << "Pure function " << __FUNCTION__
437  << " called in Class "
438  << info.name() << std::endl;
439  };
441 
443 
444 
449  virtual void init_kin_param() = 0;
450 
455 
460 
465  std::vector<VariableNames> derivative_flags;
466 
470  unsigned int n_quad;
471 
483 
485 
486 
487  double R;
489  double F;
490  //Boltzmann constant
492  double K;
494 
496 
497 
498  double p_total;
499 
504  std::map< VariableNames, SolutionVariable > reactants_map;
505 
508 
510  SolutionVariable phi_s
511  ;
515 
517 
518 
527  double th;
528 
530  }; // BaseKinetics
531  } // Kinetics
532 } // FuelCellShop
533 
534 #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:504
BaseKinetics()
Constructor.
Definition: base_kinetics.h:396
unsigned int n_quad
Number of quadrature points in the cell.
Definition: base_kinetics.h:470
ReactionNames name_reaction_kinetics
Enumeration with the reaction name for which the class returns kinetic parameters.
Definition: base_kinetics.h:459
virtual ~BaseKinetics()
Destructor.
Definition: base_kinetics.h:414
virtual void initialize(ParameterHandler &)
Member function used to read in data and initialize the necessary data to compute the coefficients...
Definition: base_kinetics.h:433
void set_catalyst(FuelCellShop::Material::CatalystBase *cat_in)
Set a pointer to the catalyst that will be used.
Definition: base_kinetics.h:235
double F()
Faraday constant, .
Definition: fcst_constants.h:38
void set_p_t(const double &P_Tot)
Set the total gas pressure [Pascals] in the cell.
Definition: base_kinetics.h:261
VariableNames get_variablename() const
Function to get the VariableNames enumeration corresponding to this struct.
Definition: fcst_variables.h:163
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:146
double K
Boltzmann constant.
Definition: base_kinetics.h:492
VariableNames
The enumeration containing the names of some of the available FCST solution variables and their deriv...
Definition: system_management.h:62
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:498
Definition: system_management.h:70
SolutionVariable phi_m
Struct storing a pointer to the solution vector for the electrolyte potential.
Definition: base_kinetics.h:507
double th
A thresholding value of the GAS-LIQUID concentration of (cathode) or (anode) by passing which the ...
Definition: base_kinetics.h:527
This class implements the interface to compute the properties of a &quot;standard&quot; catalyst.
Definition: catalyst_base.h:69
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:226
void set_temperature(const SolutionVariable &temperature)
Set temperature.
Definition: base_kinetics.h:201
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:301
double R
Universal gas constant.
Definition: base_kinetics.h:487
SolutionVariable T
Struct stroing a pointer to the solution vector for the temperature.
Definition: base_kinetics.h:513
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:117
virtual void declare_parameters(ParameterHandler &) const
Declare parameters for a parameter file.
Definition: base_kinetics.h:420
Definition: system_management.h:68
Definition: system_management.h:75
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:245
double R()
Universal gas constant, .
Definition: fcst_constants.h:33
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:325
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:338
void set_electrolyte_potential(const SolutionVariable &phi)
Set the electrolyte phase potential.
Definition: base_kinetics.h:185
void set_reactant_concentrations(const std::vector< SolutionVariable > &conc_vec)
Set reactant concentrations.
Definition: base_kinetics.h:209
std::map< std::string, BaseKinetics * > _mapFactory
This object is used to store all objects of type BaseKinetics.
Definition: base_kinetics.h:360
FuelCellShop::Material::PolymerElectrolyteBase * electrolyte
Pointer to the electrolyte object created in the application that is used to calculate the properties...
Definition: base_kinetics.h:481
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:193
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:382
ReactionNames
Definition: system_management.h:148
This class implements the interface to compute the properties of a &quot;standard&quot; polymer electrolyte mem...
Definition: polymer_electrolyte_material_base.h:62
Definition: system_management.h:67
static _mapFactory * get_mapFactory()
Definition: base_kinetics.h:368
Virtual class used to provide the interface for all kinetic/reaction children.
Definition: base_kinetics.h:107
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:312
double F
Universal Farday&#39;s constant.
Definition: base_kinetics.h:489
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:255
Definition: system_management.h:66
ReactionNames get_reaction_name() const
Returns the name of the reaction that this kinetics class is using.
Definition: base_kinetics.h:271
double K()
Boltzmann constant, .
Definition: fcst_constants.h:53
bool kin_param_initialized
Boolean variable to determine whether init_kin_param has been already called or not.
Definition: base_kinetics.h:454
Definition: system_management.h:71
virtual bool has_coverage(const VariableNames &type)
Definition: base_kinetics.h:348
FuelCellShop::Material::CatalystBase * get_cat() const
Function to get pointer to catalyst class.
Definition: base_kinetics.h:277
virtual void current_density(std::vector< double > &)
Function to return the value of the current [A/cm^2].
Definition: base_kinetics.h:286
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:476
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:465