OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
agglomerate_CL.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 // C++ Interface: agglomerate_CL.h
3 //
4 // Description: Class characterizing the catalyst layer and defining effective properties
5 //
6 // Authors: Marc Secanell <secanell@ualberta.ca,
7 // Peter Dobson <pdobson@ualberta.ca>, (C) 2011
8 // University of Alberta
9 //
10 // Copyright: See COPYING file that comes with this distribution
11 //
12 //---------------------------------------------------------------------------
13 
14 #ifndef _FUELCELLSHOP__LAYER__AGGLOMERATE_CL__LAYER_H
15 #define _FUELCELLSHOP__LAYER__AGGLOMERATE_CL__LAYER_H
16 
17 #include <boost/smart_ptr.hpp>
18 
19 // Include deal.II classes
20 #include<base/parameter_handler.h>
21 #include<base/point.h>
22 #include <base/function.h>
23 #include <lac/vector.h>
24 #include <fe/fe_values.h>
25 
26 #include "base/timer.h"
27 
28 // Include FCST classes
29 #include "utils/fcst_constants.h"
30 #include "utils/fcst_utilities.h"
31 #include "utils/fcst_db.h"
32 
33 #include "layers/conventional_CL.h"
36 
37 
38 //Include STL
39 #include<cmath>
40 #include<iostream>
41 #include <stdexcept>
42 #include <map>
43 
44 namespace FuelCellShop
45 {
46  namespace Layer
47  {
60  template <int dim>
61  class AgglomerateCL :
62  public ConventionalCL<dim>
63  {
64  public:
65 
81  static const std::string concrete_name;
82 
84 
85 
90  AgglomerateCL ( );
91 
99  AgglomerateCL ( std::string name );
100 
104  ~AgglomerateCL();
105 
111  void declare_parameters ( ParameterHandler &param ) const
112  {
113  declare_parameters(this->name, param);
114  }
115 
121  void set_parameters ( const std::vector<std::string>& name_dvar,
122  const std::vector<double>& value_dvar,
123  ParameterHandler &param ) const
124  {
125  set_parameters(name_dvar, value_dvar, this->name, param);
126  }
127 
132  void initialize ( ParameterHandler &param );
133 
135 
137 
138 
141  inline double get_n () const
142  {
143  return n_agg;
144  }
145 
156  virtual void current_density ( std::vector<double>& current );
157 
170  virtual void current_density (std::vector<double>& current, std::vector<double>& effectiveness );
171 
177  virtual void derivative_current_density ( std::map< VariableNames, std::vector<double> >& );
178 
182  virtual void print_layer_properties() const;
183 
184  inline void return_mesh_final(std::vector<double>& temp, std::vector<double>& temp1)
185  {
186  temp = mesh_final;
187  temp1 = co2_final;
188  mesh_final.clear();
189  }
190 
191  inline void set_mesh(std::vector<double>& temp)
192  { mesh_final = temp;}
194 
195 
196 
197  protected:
199 
200 
203  //AgglomerateCL(const std::string& cl_section_name);
204 
209  /*AgglomerateCL(const std::string& name,
210  FuelCellShop::Material::PolymerElectrolyteBase*,
211  FuelCellShop::Material::CatalystSupportBase*,
212  FuelCellShop::Material::CatalystBase*);
213  */
241  void declare_parameters (const std::string& cl_section_name,
242  ParameterHandler &param) const;
243 
248  void set_parameters ( const std::vector<std::string>& name_dvar,
249  const std::vector<double>& value_dvar,
250  const std::string& cl_section_name,
251  ParameterHandler &param ) const;
253 
255 
256 
261  virtual boost::shared_ptr<FuelCellShop::Layer::CatalystLayer<dim> > create_replica (const std::string &cl_section_name)
262  {
263  return boost::shared_ptr<FuelCellShop::Layer::CatalystLayer<dim> > (new FuelCellShop::Layer::AgglomerateCL<dim> (cl_section_name));
264  }
266 
267 
268 
273 
275 
276 
279  void compute_void_fraction();
280 
284  void initialize_aggs();
285 
289  boost::shared_ptr<FuelCellShop::MicroScale::AgglomerateBase> get_agg();
290 
296  double compute_n() const;
297 
304  //double derivative_n_agg() const;
305 
307  double compute_thickness_agg ();
308 
318  double epsilon_N_agg ( const double delta_agg ) const;
319 
329  double depsilonN_dthickness_agg ( const double thickness_agg ) const;
330 
334  double micro_scale_current( boost::shared_ptr <FuelCellShop::MicroScale::AgglomerateBase> &_agg , std::map<VariableNames ,SolutionVariable>& solutionMap, const unsigned int& index, double& E_r);
335 
339  void choose_agglomerate(boost::shared_ptr <FuelCellShop::MicroScale::AgglomerateBase> &agg_);
340 
344  void solve_current_derivatives_average(std::map< VariableNames, std::vector<double> >& Dcurrent);
345 
349  void solve_current_derivatives_at_each_node(std::map< VariableNames, std::vector<double> >& Dcurrent);
350 
351  /*
352  * Function for checking if our initial guess data is "up to date" within a certain tolerance.
353  */
354  bool check_micro_scale_initial_guess(const double &x_O2, const double &phi_m, const double &phi_s,
355  const double lambda, const double radius, const double film_thickness,
356  const double porosity);
357 
358 
359  /*
360  * Function for updating micro_scale_initial_guess, returns true if successful.
361  */
362  bool get_micro_scale_initial_guess(const double &x_O2, const double &phi_m, const double &phi_s, const double lambda,
363  boost::shared_ptr <FuelCellShop::MicroScale::AgglomerateBase> &_agg, const double radius,
364  const double film_thickness, const double porosity);
365 
366  /*
367  * Function for updating the database with new data.
368  */
369  void commit_data_to_db(std::vector<std::vector<double>> agg_data, std::vector<std::string> agg_column_titles, const double &x_R,
370  const double &phi_m, const double &phi_s, const double lambda, const double radius, const double film_thickness, const double porosity);
372 
374 
375 
378 
380  std::string type_agg;
381 
383  std::string comp_agg;
384 
386  std::vector<double> agglomerateLoadingWeigths;
387 
389  bool water_agg;
390 
392  std::string solver_agg;
393 
396 
398  double r_agg;
399 
402 
404  double epsilon_agg;
405 
407  double n_agg;
408 
410  double pi;
411 
413  std::vector<double> mesh_final;
414 
416  std::vector<double> co2_final;
417 
419  double cond_factor;
420 
424  std::vector<boost::shared_ptr<FuelCellShop::MicroScale::AgglomerateBase>> aggs; //Up to three aggs needed for parallel computation
425 
429  std::vector<std::vector<double>> micro_scale_initial_guess;
430 
435 
436  //** Data for monitoring the relevance our current initial guess */
437  double IC_x_R;
438  double IC_phi_m;
439  double IC_phi_s;
440  double IC_lambda;
441  double IC_tolerance;
442  double IC_radius;
444  double IC_porosity;
446 
447  };
448 
449  } // Layer
450 
451 } // FuelCellShop
452 
453 #endif // _FUELCELLSHOP__LAYER__AGGLOMERATE_CL__LAYER_H
454