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 FCST classes
24 #include <utils/fcst_utilities.h>
25 #include <layers/conventional_CL.h>
27 
28 //Include STL
29 #include <stdexcept>
30 #include <map>
31 
32 
33 namespace FuelCellShop
34 {
35  namespace Layer
36  {
49  template <int dim>
50  class MultiScaleCL :
51  public ConventionalCL<dim>
52  {
53  public:
69  static const std::string concrete_name;
70 
71 
79  virtual void set_cell_id(const unsigned int& id){
80  cell_id_ = id;
81  }
82 
86  ~MultiScaleCL();
87 
89 
90 
101  virtual void current_density ( std::vector<double>& current );
102 
115  virtual void current_density (std::vector<double>& current, std::vector<double>& effectiveness );
116 
122  virtual void derivative_current_density ( std::map< VariableNames, std::vector<double> >& );
123 
127  virtual void print_layer_properties() const;
128 
129 
130  /*
131  * Public member function which returns a boost::shared pointer of template type T.
132  *
133  *
134  * \param T is the type of object you are requestiong, e.g., FuelCellShop::Material::CatalystSupportBase
135  *
136  * <h3>Usage</h3>
137  * To be used by MicroScale objects in order to get resources such as materials or
138  * kinetics. Currently the MicroScaleCL provides resources of the following types:
139  *
140  * -FuelCellShop::Kinetics::BaseKinetics
141  * -FuelCellShop::Material::CatalystBase
142  * -FuelCellShop::Material::PolymerElectrolyteBase
143  * -FuelCellShop::Material::CatalystSupportBase
144  *
145  * The above types may be used as template arguments for this function.
146  *
147  * @code
148  *
149  * //We wish to link the following kinetics pointer to the
150  * //kinetics object pointed to by the MultiScaleCL
151  *
152  * boost::shared_ptr< FuelCellShop::Kinetics::BaseKinetics > kinetics;
153  *
154  * //To get a kinetics pointer from an instance of MultiScaleCL we do
155  * //the following:
156  * kinetics = layer->get_resource<FuelCellShop::Kinetics::BaseKinetics>();
157  *
158  *
159  * @endcode
160  *
161  */
162  template<typename T>
163  inline boost::shared_ptr<T>
165 
166  boost::shared_ptr<void> ptr;
167 
168 
169  if(typeid(T) == typeid(FuelCellShop::Kinetics::BaseKinetics))
170  {
171  ptr = this->kinetics;
172  }
173  else if(typeid(T) == typeid(FuelCellShop::Material::CatalystBase))
174  {
175  ptr = this->catalyst;
176  }
177  else if(typeid(T) == typeid(FuelCellShop::Material::PolymerElectrolyteBase))
178  {
179  ptr = this->electrolyte;
180  }
181  else if(typeid(T) == typeid(FuelCellShop::Material::CatalystSupportBase))
182  {
183  ptr = this->catalyst_support;
184  }
185  else
186  {
187  std::string msg = std::string(typeid(*this).name()) + " does not have object type " + std::string(typeid(T).name());
188  throw std::runtime_error(msg);
189  }
190 
191  return boost::static_pointer_cast<T>(ptr);
192 
193  }
194 
195 
196  /*
197  * A list of properties that the MultiScaleCl shares publicly using
198  * the get_properties interface.
199  *
200  * Used by MicroScale objects
201  */
209  };
210 
211 
212  /*
213  * Public member function for getting properties of the MultiScaleCL
214  * needed by MicroScale object.
215  */
216  inline std::map<Properties, double> get_properties(){
217 
218  std::map<Properties, double> properties;
219 
220  properties[solid_fraction] = this->epsilon_S.at(this->local_material_id());
221  properties[void_fraction] = this->epsilon_V.at(this->local_material_id());
222  properties[ionomer_fraction] = this->epsilon_N.at(this->local_material_id());
223  //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
224  properties[active_area_scaled] = this->Av.at(this->local_material_id()) / (1.0 - this->epsilon_V.at(this->local_material_id()));
225  properties[pressure] = this->constant_solutions.at(total_pressure); // <- Not always the case that it is constant...
226  properties[cell_id] = double(cell_id_);
227  return properties;
228  }
229 
233  virtual SolutionMap get_coverages();
234 
235 
236 
237  protected:
238 
239 
241 
242 
246  MultiScaleCL ( );
247 
253  MultiScaleCL ( std::string name );
254 
255 
256 
261  void declare_parameters ( ParameterHandler &param ) const
262  {
263  declare_parameters(this->name, param);
264  }
265 
270  void initialize ( ParameterHandler &param );
271 
273 
275 
276 
279  //MultiScaleCL(const std::string& cl_section_name);
280 
285  /*MultiScaleCL(const std::string& name,
286  FuelCellShop::Material::PolymerElectrolyteBase*,
287  FuelCellShop::Material::CatalystSupportBase*,
288  FuelCellShop::Material::CatalystBase*);
289  */
309  void declare_parameters (const std::string& cl_section_name,
310  ParameterHandler &param) const;
311 
313 
315 
316 
321  virtual boost::shared_ptr<FuelCellShop::Layer::CatalystLayer<dim> > create_replica (const std::string &cl_section_name)
322  {
323  return boost::shared_ptr<FuelCellShop::Layer::CatalystLayer<dim> > (new FuelCellShop::Layer::MultiScaleCL<dim> (cl_section_name));
324  }
326 
328 
333 
335 
336 
339  void compute_void_fraction();
340 
344  void initialize_micro_scale(ParameterHandler &param);
345 
349  SolutionMap micro_scale_current(std::map<VariableNames ,SolutionVariable>& solutionMap, const unsigned int& sol_index, const unsigned int& thread_index);
350 
351 
355  void solve_current_derivatives_average(std::map< VariableNames, std::vector<double> >& Dcurrent);
356 
360  void solve_current_derivatives_at_each_node(std::map< VariableNames, std::vector<double> >& Dcurrent);
362 
369  std::map<unsigned int, std::vector<boost::shared_ptr<FuelCellShop::MicroScale::MicroScaleBase>>> micro;
370 
371  /*Solution map used for storing coverages */
373 
374  unsigned int cell_id_;
375 
376  };
377 
378  } // Layer
379 
380 } // FuelCellShop
381 
382 #endif
383 
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:50
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:1091
SolutionMap coverage_map
Definition: multi_scale_CL.h:372
virtual void set_cell_id(const unsigned int &id)
Function for setting current cell_id from applications.
Definition: multi_scale_CL.h:79
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:544
Definition: multi_scale_CL.h:203
std::map< unsigned int, double > epsilon_S
Solid volume fraction in the catalyst layer.
Definition: conventional_CL.h:548
VariableNames
The enumeration containing the names of some of the available FCST solution variables and their deriv...
Definition: system_management.h:63
Convenient storage object for SolutionVariables.
Definition: fcst_variables.h:457
boost::shared_ptr< T > get_resource()
Definition: multi_scale_CL.h:164
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:65
static MultiScaleCL< dim > const * PROTOTYPE
Definition: multi_scale_CL.h:331
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:69
std::map< unsigned int, double > epsilon_V
Void volume fraction (Porosity) of the catalyst layer.
Definition: conventional_CL.h:546
This class characterizes a catalyst layer and uses this information to compute effective transport pr...
Definition: conventional_CL.h:48
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:47
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:369
Definition: multi_scale_CL.h:207
std::map< unsigned int, double > Av
Active area of catalyst per unit volume of catalyst layer.
Definition: conventional_CL.h:564
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:59
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:1085
Virtual class used to provide the interface for all kinetic/reaction children.
Definition: base_kinetics.h:102
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:92
void declare_parameters(ParameterHandler &param) const
Declare all necessary parameters in order to compute the coefficients.
Definition: multi_scale_CL.h:261
bool average_cell_current
Boolean value to choose whether to average the current over the cell.
Definition: multi_scale_CL.h:364
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:1094
unsigned int cell_id_
Definition: multi_scale_CL.h:374
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:321
Definition: multi_scale_CL.h:208
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:1079
std::map< Properties, double > get_properties()
Definition: multi_scale_CL.h:216