OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
multi_scale_CL.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2014 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: multi_scale_CL.h
11 // - Description: Class characterizing the catalyst layer and defining effective properties
12 // - Developers: M. Secanell, Peter Dobson, Philip Wardlaw, Michael Moore, Madhur Bhaiya
13 // - $Id: multi_scale_CL.h 2605 2014-08-15 03:36:44Z secanell $
14 //
15 //---------------------------------------------------------------------------
16 
17 #ifndef _FUELCELLSHOP__LAYER__MULTISCALE_CL__LAYER_H
18 #define _FUELCELLSHOP__LAYER__MULTISCALE_CL__LAYER_H
19 
20 //Include Boost classes
21 #include <boost/smart_ptr.hpp>
22 
23 // Include deal.II classes
24 #include<base/parameter_handler.h>
25 #include <base/function.h>
26 
27 // Include FCST classes
28 #include "utils/fcst_constants.h"
29 #include "utils/fcst_utilities.h"
30 #include "layers/conventional_CL.h"
32 
33 //Include STL
34 #include <cmath>
35 #include <iostream>
36 #include <stdexcept>
37 #include <map>
38 
39 
40 namespace FuelCellShop
41 {
42  namespace Layer
43  {
56  template <int dim>
57  class MultiScaleCL :
58  public ConventionalCL<dim>
59  {
60  public:
76  static const std::string concrete_name;
77 
78 
86  virtual void set_cell_id(const unsigned int& id){
87  cell_id_ = id;
88  }
89 
90 
91 
92 
96  ~MultiScaleCL();
97 
99 
100 
111  virtual void current_density ( std::vector<double>& current );
112 
125  virtual void current_density (std::vector<double>& current, std::vector<double>& effectiveness );
126 
132  virtual void derivative_current_density ( std::map< VariableNames, std::vector<double> >& );
133 
137  virtual void print_layer_properties() const;
138 
139 
140  /*
141  * Public member function which returns a boost::shared pointer of template type T.
142  *
143  *
144  * \param T is the type of object you are requestiong, e.g., FuelCellShop::Material::CatalystSupportBase
145  *
146  * <h3>Usage</h3>
147  * To be used by MicroScale objects in order to get resources such as materials or
148  * kinetics. Currently the MicroScaleCL provides resources of the following types:
149  *
150  * -FuelCellShop::Kinetics::BaseKinetics
151  * -FuelCellShop::Material::CatalystBase
152  * -FuelCellShop::Material::PolymerElectrolyteBase
153  * -FuelCellShop::Material::CatalystSupportBase
154  *
155  * The above types may be used as template arguments for this function.
156  *
157  * @code
158  *
159  * //We wish to link the following kinetics pointer to the
160  * //kinetics object pointed to by the MultiScaleCL
161  *
162  * boost::shared_ptr< FuelCellShop::Kinetics::BaseKinetics > kinetics;
163  *
164  * //To get a kinetics pointer from an instance of MultiScaleCL we do
165  * //the following:
166  * kinetics = layer->get_resource<FuelCellShop::Kinetics::BaseKinetics>();
167  *
168  *
169  * @endcode
170  *
171  */
172  template<typename T>
173  inline boost::shared_ptr<T>
175 
176  boost::shared_ptr<void> ptr;
177 
178 
179  if(typeid(T) == typeid(FuelCellShop::Kinetics::BaseKinetics))
180  {
181  ptr = this->kinetics;
182  }
183  else if(typeid(T) == typeid(FuelCellShop::Material::CatalystBase))
184  {
185  ptr = this->catalyst;
186  }
187  else if(typeid(T) == typeid(FuelCellShop::Material::PolymerElectrolyteBase))
188  {
189  ptr = this->electrolyte;
190  }
191  else if(typeid(T) == typeid(FuelCellShop::Material::CatalystSupportBase))
192  {
193  ptr = this->catalyst_support;
194  }
195  else
196  {
197  std::string msg = std::string(typeid(*this).name()) + " does not have object type " + std::string(typeid(T).name());
198  throw std::runtime_error(msg);
199  }
200 
201  return boost::static_pointer_cast<T>(ptr);
202 
203  }
204 
205 
206  /*
207  * A list of properties that the MultiScaleCl shares publicly using
208  * the get_properties interface.
209  *
210  * Used by MicroScale objects
211  */
219  };
220 
221 
222  /*
223  * Public member function for getting properties of the MultiScaleCL
224  * needed by MicroScale object.
225  */
226  inline std::map<Properties, double> get_properties(){
227 
228  std::map<Properties, double> properties;
229 
230  properties[solid_fraction] = this->epsilon_S.at(this->local_material_id());
231  properties[void_fraction] = this->epsilon_V.at(this->local_material_id());
232  properties[ionomer_fraction] = this->epsilon_N.at(this->local_material_id());
233  //The following active area scaling is part of the scaling described by equation 2.90 of Philip Wardlaw's MSc. thesis, and previously by Peter Dobson
234  properties[active_area_scaled] = this->Av.at(this->local_material_id()) / (1.0 - this->epsilon_V.at(this->local_material_id()));
235  properties[pressure] = this->constant_solutions.at(total_pressure);
236  properties[cell_id] = double(cell_id_);
237  return properties;
238  }
239 
243  virtual SolutionMap get_coverages();
244 
245 
246 
247  protected:
248 
249 
251 
252 
256  MultiScaleCL ( );
257 
263  MultiScaleCL ( std::string name );
264 
265 
266 
271  void declare_parameters ( ParameterHandler &param ) const
272  {
273  declare_parameters(this->name, param);
274  }
275 
280  void initialize ( ParameterHandler &param );
281 
283 
284 
285 
286 
287 
288 
289 
290 
291 
292 
294 
295 
298  //MultiScaleCL(const std::string& cl_section_name);
299 
304  /*MultiScaleCL(const std::string& name,
305  FuelCellShop::Material::PolymerElectrolyteBase*,
306  FuelCellShop::Material::CatalystSupportBase*,
307  FuelCellShop::Material::CatalystBase*);
308  */
328  void declare_parameters (const std::string& cl_section_name,
329  ParameterHandler &param) const;
330 
332 
334 
335 
340  virtual boost::shared_ptr<FuelCellShop::Layer::CatalystLayer<dim> > create_replica (const std::string &cl_section_name)
341  {
342  return boost::shared_ptr<FuelCellShop::Layer::CatalystLayer<dim> > (new FuelCellShop::Layer::MultiScaleCL<dim> (cl_section_name));
343  }
345 
347 
352 
354 
355 
358  void compute_void_fraction();
359 
363  void initialize_micro_scale(ParameterHandler &param);
364 
368  SolutionMap micro_scale_current(std::map<VariableNames ,SolutionVariable>& solutionMap, const unsigned int& sol_index, const unsigned int& thread_index);
369 
370 
374  void solve_current_derivatives_average(std::map< VariableNames, std::vector<double> >& Dcurrent);
375 
379  void solve_current_derivatives_at_each_node(std::map< VariableNames, std::vector<double> >& Dcurrent);
381 
388  std::map<unsigned int, std::vector<boost::shared_ptr<FuelCellShop::MicroScale::MicroScaleBase>>> micro;
389 
390  /*Solution map used for storing coverages */
392 
393  unsigned int cell_id_;
394 
395  };
396 
397  } // Layer
398 
399 } // FuelCellShop
400 
401 #endif
402 
virtual SolutionMap get_coverages()
Method for getting coverages from micro scale objects Overloaded here since kinetics cannot be used d...
This class characterizes a catalyst layer and uses this information to compute effective transport pr...
Definition: multi_scale_CL.h:57
boost::shared_ptr< FuelCellShop::Material::CatalystBase > catalyst
Pointer to the catalyst object created in the application that is used to store the properties of the...
Definition: catalyst_layer.h:1001
SolutionMap coverage_map
Definition: multi_scale_CL.h:391
virtual void set_cell_id(const unsigned int &id)
Function for setting current cell_id from applications.
Definition: multi_scale_CL.h:86
void compute_void_fraction()
Compute porosity and volume fraction of solid and ionomer in the catalyst layer.
void initialize_micro_scale(ParameterHandler &param)
Creates the microscale objects populating the microscale object.
std::map< unsigned int, double > epsilon_N
Volume fraction of Nafion in the cathode catalyst layer.
Definition: conventional_CL.h:504
Definition: multi_scale_CL.h:213
std::map< unsigned int, double > epsilon_S
Solid volume fraction in the catalyst layer.
Definition: conventional_CL.h:508
VariableNames
The enumeration containing the names of some of the available FCST solution variables and their deriv...
Definition: system_management.h:62
Convenient storage object for SolutionVariables.
Definition: fcst_variables.h:447
boost::shared_ptr< T > get_resource()
Definition: multi_scale_CL.h:174
virtual void derivative_current_density(std::map< VariableNames, std::vector< double > > &)
This member function will use a FuelCellShop::Kinetics class in order to compute the derivative of th...
This class implements the interface to compute the properties of a &quot;standard&quot; catalyst.
Definition: catalyst_base.h:69
static MultiScaleCL< dim > const * PROTOTYPE
Definition: multi_scale_CL.h:350
const std::string name
Name of the layer.
Definition: base_layer.h:336
virtual void current_density(std::vector< double > &current)
This member function will use a FuelCellShop::Kinetics class in order to compute the current density ...
static const std::string concrete_name
Concrete name used for objects of this class.
Definition: multi_scale_CL.h:76
std::map< unsigned int, double > epsilon_V
Void volume fraction (Porosity) of the catalyst layer.
Definition: conventional_CL.h:506
This class characterizes a catalyst layer and uses this information to compute effective transport pr...
Definition: conventional_CL.h:61
std::map< VariableNames, double > constant_solutions
Map storing values of solution variables constant in a particular application.
Definition: base_layer.h:352
This class implements the interface to compute the properties of a &quot;standard&quot; catalyst support...
Definition: catalyst_support_base.h:49
void solve_current_derivatives_at_each_node(std::map< VariableNames, std::vector< double > > &Dcurrent)
Private member functions for solving for current derivatives in a per node approach.
void solve_current_derivatives_average(std::map< VariableNames, std::vector< double > > &Dcurrent)
Private member functions for solving for current derivatives in an averaging approach.
std::map< unsigned int, std::vector< boost::shared_ptr< FuelCellShop::MicroScale::MicroScaleBase > > > micro
Vector of shared_ptr microscale objects used for calculating current density and current density deri...
Definition: multi_scale_CL.h:388
Definition: multi_scale_CL.h:217
std::map< unsigned int, double > Av
Active area of catalyst per unit volume of catalyst layer.
Definition: conventional_CL.h:524
virtual void print_layer_properties() const
Print out composition and micro-structural properties of the catalyst layer.
This class implements the interface to compute the properties of a &quot;standard&quot; polymer electrolyte mem...
Definition: polymer_electrolyte_material_base.h:62
boost::shared_ptr< FuelCellShop::Material::CatalystSupportBase > catalyst_support
Pointer to the catalyst support object created in the application that is used to calculate the carbo...
Definition: catalyst_layer.h:995
Virtual class used to provide the interface for all kinetic/reaction children.
Definition: base_kinetics.h:107
SolutionMap micro_scale_current(std::map< VariableNames, SolutionVariable > &solutionMap, const unsigned int &sol_index, const unsigned int &thread_index)
Private member functions for solving current density given an microscale.
Definition: system_management.h:91
void declare_parameters(ParameterHandler &param) const
Declare all necessary parameters in order to compute the coefficients.
Definition: multi_scale_CL.h:271
bool average_cell_current
Boolean value to choose whether to average the current over the cell.
Definition: multi_scale_CL.h:383
void initialize(ParameterHandler &param)
Member function used to read in data and initialize the necessary data to compute the coefficients...
boost::shared_ptr< FuelCellShop::Kinetics::BaseKinetics > kinetics
Pointer to a kinetics object.
Definition: catalyst_layer.h:1004
unsigned int cell_id_
Definition: multi_scale_CL.h:393
unsigned int local_material_id() const
Return the local material id of the layer, performs a check.
Definition: base_layer.h:215
MultiScaleCL()
Prototype Constructor.
virtual boost::shared_ptr< FuelCellShop::Layer::CatalystLayer< dim > > create_replica(const std::string &cl_section_name)
This member function is used to create an object of type gas diffusion layer.
Definition: multi_scale_CL.h:340
Definition: multi_scale_CL.h:218
boost::shared_ptr< FuelCellShop::Material::PolymerElectrolyteBase > electrolyte
Pointer to the electrolyte object created in the application that is used to calculate the properties...
Definition: catalyst_layer.h:989
std::map< Properties, double > get_properties()
Definition: multi_scale_CL.h:226