OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
app_pemfc.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2009-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: app_pemfc.h
11 // - Description:
12 // - Developers: M. Secanell, P. Dobson, M. Bhaiya
13 // - $Id: app_pemfc.h 2605 2014-08-15 03:36:44Z secanell $
14 //
15 //---------------------------------------------------------------------------
16 
17 #ifndef _FUELCELL__APP_PEMFC__H
18 #define _FUELCELL__APP_PEMFC__H
19 
20 // Include deal.II classes
21 #include <base/parameter_handler.h>
22 #include <base/function_lib.h>
23 #include <base/function.h>
24 #include <base/quadrature_lib.h>
25 
26 #include <lac/block_vector.h>
27 #include <lac/solver_cg.h>
28 #include <lac/solver_gmres.h>
29 #include <lac/precondition.h>
30 #include <lac/precondition_block.h>
31 #include <lac/block_matrix_array.h>
32 #include <lac/sparse_ilu.h>
33 #include <lac/sparse_direct.h>
34 
35 #include <grid/grid_generator.h>
36 #include <grid/tria_accessor.h>
37 #include <grid/tria_iterator.h>
38 #include <grid/tria_boundary_lib.h>
39 
40 #include <fe/fe_values.h>
41 
42 #include <numerics/vector_tools.h>
43 #include <numerics/matrix_tools.h>
44 #include <numerics/error_estimator.h>
45 #include <boost/shared_ptr.hpp>
46 
47 // Include appframe classes
49 
51 #include "solver_utils.h"
52 #include "newton_w_line_search.h"
53 #include "newton_w_3pp.h"
54 #include "linear_solvers.h"
55 
56 #include "operating_conditions.h"
57 #include "design_MPL.h"
58 #include "PureGas.h"
59 #include "PureLiquid.h"
60 #include "design_fibrous_GDL.h"
61 #include "homogeneous_CL.h"
62 #include "nafion_membrane.h"
63 #include "GasMixture.h"
64 #include "geometries.h"
65 #include "geometry.h"
66 #include "fcst_constants.h"
67 #include "tafel_kinetics.h"
68 #include "double_trap_kinetics.h"
69 #include "dual_path_kinetics.h"
70 //#include "appshop_cell.h"
71 //#include "appshop_residual.h"
72 
73 // Equation Classes
74 #include "reaction_source_terms.h"
78 #include "sorption_source_terms.h"
80 
81 // Post-processing
85 
86 //Include STL
87 #include <fstream>
88 #include <iostream>
89 #include <sstream>
90 #include <cmath>
91 #include <vector>
92 
95 namespace FuelCell
96 {
97 
98  namespace InitialSolution
99  {
105  template <int dim>
107  :
108  public Function<dim>
109  {
110  public:
118  ~AppPemfcIC ();
119 
124  void vector_value (const Point<dim> &p,
125  Vector<double> &v) const;
126 
127  private:
130 
132  boost::shared_ptr< FuelCellShop::Geometry::GridBase<dim> > grid;
133  };
134 
135  } //end namespace InitialSolution
136 
137 
138  namespace Application
139  {
140  //---------------------------------------------------------------------------
141  //---------------------------------------------------------------------------
142  //---------------------------------------------------------------------------
162  template <int dim>
163  class AppPemfc
164  :
166  {
167 
168  public:
169 
176  AppPemfc (boost::shared_ptr<FuelCell::ApplicationCore::ApplicationData> data = boost::shared_ptr<FuelCell::ApplicationCore::ApplicationData> ());
177 
181  ~AppPemfc ();
188  virtual void declare_parameters(ParameterHandler& param);
189 
196  virtual void set_parameters(const std::vector<std::string>& name_dvar,
197  const std::vector<double>& value_dvar,
198  ParameterHandler& param){};
199 
204  void _initialize(ParameterHandler& param);
205 
209  virtual void initialize(ParameterHandler& param);
210 
214  virtual void initialize_solution (FEVector& initial_guess,
215  std::shared_ptr<Function<dim> > initial_function = std::shared_ptr<Function<dim> >());
230  virtual void cell_matrix(MatrixVector& cell_matrices,
231  const typename DoFApplication<dim>::CellInfo& cell);
241  virtual void cell_residual(FuelCell::ApplicationCore::FEVector& cell_vector,
242  const typename DoFApplication<dim>::CellInfo& cell);
243 
244 
251  virtual void dirichlet_bc(std::map<unsigned int, double>& boundary_values) const;
252 
259  virtual void check_responses();
260 
264  virtual void cell_responses (std::vector<double>& resp,
265  const typename DoFApplication<dim>::CellInfo& info,
271  virtual void global_responses (std::vector<double>& resp,
273 
279  virtual void cell_dresponses_dl(std::vector<std::vector<double> >& /*cell_df_dl*/,
280  const typename DoFApplication<dim>::CellInfo& /*info*/,
281  const FuelCell::ApplicationCore::FEVector& /*sol*/) {};
282 
288  virtual void global_dresponses_dl(std::vector<std::vector<double> >& df_dl,
295  virtual void cell_dresponses_du(std::vector<FuelCell::ApplicationCore::FEVector >& /*cell_df_du*/,
296  const typename DoFApplication<dim>::CellInfo& /*info*/,
297  std::vector<std::vector<double> >& /*src*/) {};
298 
304  virtual void global_dresponses_du(std::vector<FuelCell::ApplicationCore::FEVector >& df_du,
306 
307 
312  virtual double evaluate (const FuelCell::ApplicationCore::FEVectors& src);
313 
318  virtual void data_out(const std::string &basename,
320 
321 
325  void data_out(std::string basename, const FuelCell::ApplicationCore::FEVectors vectors, std::vector< std::string > solution_names);
326 
327  protected:
328 
330 
331 
337  std::vector<std::string> equation_names;
343  std::vector<std::string> component_names;
345 
347 
348 
352 
354 
355 
359  //FuelCellShop::Material::Nafion electrolyte;
360 
364  //FuelCellShop::Material::CarbonBlack catalyst_support;
365 
369  //FuelCellShop::Material::Platinum catalyst;
370 
375 
380 
385 
390 
392 
394 
395 
398  boost::shared_ptr<FuelCellShop::Layer::GasDiffusionLayer<dim> > AGDL;
399 
403  boost::shared_ptr<FuelCellShop::Layer::MicroPorousLayer<dim> > AMPL;
404 
408  boost::shared_ptr<FuelCellShop::Layer::CatalystLayer<dim> > ACL;
409 
413  boost::shared_ptr<FuelCellShop::Layer::MembraneLayer<dim> > ML;
414 
415 
419  boost::shared_ptr<FuelCellShop::Layer::CatalystLayer<dim> > CCL;
420 
424  boost::shared_ptr<FuelCellShop::Layer::MicroPorousLayer<dim> > CMPL;
425 
429  boost::shared_ptr<FuelCellShop::Layer::GasDiffusionLayer<dim> > CGDL;
431 
433 
434 
441 
443 
444 
448 
453 
458 
462 
467 
473 
475  std::vector<std::string> design_var;
476 
478  std::vector<double> design_var_value;
479 
480  private:
481 
482  double l_channel;
483 
484  double l_land;
485 
491  void set_default_parameters_for_application(ParameterHandler &param)
492  {
493  param.enter_subsection("System management");
494  {
495  param.set("Number of solution variables","5");
496  param.enter_subsection("Solution variables");
497  {
498  param.set("Solution variable 1","oxygen_molar_fraction");
499  param.set("Solution variable 2","water_molar_fraction");
500  param.set("Solution variable 3","protonic_electrical_potential");
501  param.set("Solution variable 4","electronic_electrical_potential");
502  param.set("Solution variable 5","membrane_water_content");
503  }
504  param.leave_subsection();
505 
506  param.enter_subsection("Equations");
507  {
508  param.set("Equation 1","Ficks Transport Equation - oxygen");
509  param.set("Equation 2","Ficks Transport Equation - water");
510  param.set("Equation 3","Proton Transport Equation");
511  param.set("Equation 4","Electron Transport Equation");
512  param.set("Equation 5","Membrane Water Content Transport Equation");
513  }
514  param.leave_subsection();
515  }
516  param.leave_subsection();
517  param.enter_subsection("Discretization");
518  {
519  param.set("Element","FESystem[FE_Q(1)^5]");
520  }
521  param.leave_subsection();
522  }
523 
524  };
525 
526  }
527 
528 }
529 
530 #endif //_FUELCELL__APPPEMFC_H
FuelCellShop::Material::Nitrogen nitrogen
The cathode contains water vapour, so we need to create an object water in order to compute viscosity...
Definition: app_pemfc.h:384
boost::shared_ptr< FuelCellShop::Layer::MicroPorousLayer< dim > > AMPL
The object AMPL layer will contain all the information relevant to the the anode micro-porous layer...
Definition: app_pemfc.h:403
FuelCellShop::Material::WaterVapor water
Object used to calculate the properties of the electrolyte in the catalyst layer. ...
Definition: app_pemfc.h:374
virtual void cell_dresponses_du(std::vector< FuelCell::ApplicationCore::FEVector > &, const typename DoFApplication< dim >::CellInfo &, std::vector< std::vector< double > > &)
This class is used to evaluate the derivative of all the functionals that require looping over cells ...
Definition: app_pemfc.h:295
FuelCellShop::Material::Hydrogen hydrogen
The anode contains hydrogen, so we need to create an object water in order to compute viscosity...
Definition: app_pemfc.h:389
std::vector< std::string > design_var
Stores the design variable names so that the name can be appended to the .vtk file name...
Definition: app_pemfc.h:475
Class used to store, read from file and define the operating conditions for a fuel cell...
Definition: operating_conditions.h:110
FuelCellShop::Equation::ElectronTransportEquation< dim > electron_transport
ElectronTransportEquation object.
Definition: app_pemfc.h:457
virtual void cell_residual(FuelCell::ApplicationCore::FEVector &cell_vector, const typename DoFApplication< dim >::CellInfo &cell)
Integration of the rhs of the equations.
virtual void cell_dresponses_dl(std::vector< std::vector< double > > &, const typename DoFApplication< dim >::CellInfo &, const FuelCell::ApplicationCore::FEVector &)
This class is used to evaluate the derivative of all the functionals that require looping over cells ...
Definition: app_pemfc.h:279
virtual void global_dresponses_du(std::vector< FuelCell::ApplicationCore::FEVector > &df_du, const FuelCell::ApplicationCore::FEVector &src)
This class is used to evaluate the sensitivities of all responses that do not require looping over ce...
FuelCellShop::Equation::ReactionSourceTerms< dim > reaction_source_terms
ReactionSourceTerms object.
Definition: app_pemfc.h:466
virtual void check_responses()
This class is called by responses to make sure that all responses requested are implemented in either...
This class assembles source terms corresponding to sorption/desorption of water inside the catalyst l...
Definition: sorption_source_terms.h:103
FuelCellShop::PostProcessing::HORCurrentDensityResponse< dim > HORCurrent
Post-processing object to compute the HOR current density.
Definition: app_pemfc.h:437
FuelCellShop::Equation::NewFicksTransportEquation< dim > ficks_oxygen_nitrogen
Definition: app_pemfc.h:459
virtual double evaluate(const FuelCell::ApplicationCore::FEVectors &src)
Post-processing.
This class deals with Proton Transport Equation.
Definition: proton_transport_equation.h:138
Class used to calculate the current density at the anode catalyst layer.
Definition: response_current_density.h:181
double l_land
Width of the landing.
Definition: app_pemfc.h:484
FuelCell::OperatingConditions * OC
Operating conditions class object.
Definition: app_pemfc.h:129
boost::shared_ptr< FuelCellShop::Layer::MicroPorousLayer< dim > > CMPL
The object CMPL layer will contain all the information relevant to the the cathode micro-porous layer...
Definition: app_pemfc.h:424
FuelCellShop::Equation::NewFicksTransportEquation< dim > ficks_water_nitrogen
Definition: app_pemfc.h:460
virtual void global_responses(std::vector< double > &resp, const FuelCell::ApplicationCore::FEVector &sol)
This class is used to evaluate all responses that do not require looping over cells.
This class is used to solve the physical pheonoma on a complete membrane electrode assembly...
Definition: app_pemfc.h:163
AppPemfc(boost::shared_ptr< FuelCell::ApplicationCore::ApplicationData > data=boost::shared_ptr< FuelCell::ApplicationCore::ApplicationData >())
Constructor.
This class deals with Electron Transport Equation.
Definition: electron_transport_equation.h:130
virtual void data_out(const std::string &basename, const FuelCell::ApplicationCore::FEVectors &src)
Reimplementation of the routine in the base class BaseApplication in namespace AppFrame so that the r...
FuelCellShop::Equation::ProtonTransportEquation< dim > proton_transport
ProtonTransportEquation object.
Definition: app_pemfc.h:447
This class deals with Membrane Water Content Transport Equation.
Definition: lambda_transport_equation.h:133
std::vector< std::string > equation_names
Structure where we store the problem we want to solve.
Definition: app_pemfc.h:337
double l_channel
Width of the channel.
Definition: app_pemfc.h:482
void set_default_parameters_for_application(ParameterHandler &param)
Function to modify the default values of the data file in order to make sure that the equations match...
Definition: app_pemfc.h:491
This class deals with Ficks Transport Equation.
Definition: new_ficks_transport_equation.h:132
boost::shared_ptr< FuelCellShop::Layer::CatalystLayer< dim > > CCL
The object CCL layer will contain all the information relevant to the the catalyst layer...
Definition: app_pemfc.h:419
Class used to calculate the amount of water sorbed inside the catalyst layer.
Definition: response_water_sorption.h:120
FuelCellShop::Equation::NewFicksTransportEquation< dim > ficks_water_hydrogen
Definition: app_pemfc.h:461
This class is created for the objects handed to the mesh loops.
Definition: mesh_loop_info_objects.h:625
This class describes properties of pure oxygen.
Definition: PureGas.h:980
FuelCellShop::PostProcessing::ORRCurrentDensityResponse< dim > ORRCurrent
Post-processing object to compute the ORR current density.
Definition: app_pemfc.h:435
boost::shared_ptr< FuelCellShop::Layer::GasDiffusionLayer< dim > > AGDL
The object AGDL layer will contain all the information relevant to the the anode GDL.
Definition: app_pemfc.h:398
virtual void declare_parameters(ParameterHandler &param)
Declare all parameters that are needed for:
OperatingConditions OC
Initial operating conditions class.
Definition: app_pemfc.h:350
std::vector< MatrixBlock< FullMatrix< double > > > MatrixVector
The matrix vector used in the mesh loops.
Definition: matrix_block.h:102
AppPemfcIC(FuelCell::OperatingConditions *OC, boost::shared_ptr< FuelCellShop::Geometry::GridBase< dim > > grid)
Constructor.
This class describes properties of pure nitrogen.
Definition: PureGas.h:1039
std::map< unsigned int, double > boundary_values
Variable to store boundary values, so they only need to be computed once per mesh refinement...
Definition: block_matrix_application.h:324
virtual void cell_responses(std::vector< double > &resp, const typename DoFApplication< dim >::CellInfo &info, const FuelCell::ApplicationCore::FEVector &sol)
Compute the value of all objective function and constraints.
virtual void initialize_solution(FEVector &initial_guess, std::shared_ptr< Function< dim > > initial_function=std::shared_ptr< Function< dim > >())
Initialize nonlinear solution.
virtual void initialize(ParameterHandler &param)
Call the other initialize routines from the inherited classes.
virtual void global_dresponses_dl(std::vector< std::vector< double > > &df_dl, const FuelCell::ApplicationCore::FEVector &sol)
This class is used to evaluate the sensitivities of all responses that do not require looping over ce...
This class assembles the reaction source terms for all other transport equations, if there&#39;s any...
Definition: reaction_source_terms.h:60
FuelCellShop::Equation::LambdaTransportEquation< dim > lambda_transport
LambdaTransportEquation object.
Definition: app_pemfc.h:452
boost::shared_ptr< FuelCellShop::Layer::MembraneLayer< dim > > ML
The object PEM layer will contain all the information relevant to the the polymer electrolyte membran...
Definition: app_pemfc.h:413
FuelCellShop::PostProcessing::WaterSorptionResponse< dim > WaterSorption
Post-processing object to compute the water sorption in the CL.
Definition: app_pemfc.h:439
FuelCellShop::Equation::SorptionSourceTerms< dim > sorption_source_terms
SorptionSourceTerms object.
Definition: app_pemfc.h:471
FuelCell Geometry information class.
Definition: geometry.h:91
std::vector< std::string > component_names
Structure where we store the name of each component in our problem.
Definition: app_pemfc.h:343
boost::shared_ptr< FuelCellShop::Geometry::GridBase< dim > > grid
Geometry class object.
Definition: app_pemfc.h:132
virtual void cell_matrix(MatrixVector &cell_matrices, const typename DoFApplication< dim >::CellInfo &cell)
Integration of local bilinear form.
void _initialize(ParameterHandler &param)
Set up how many equations are needed and read in parameters for the parameter handler in order to ini...
This class is used when solving the problem using Newton&#39;s method to provide an initial solution...
Definition: app_pemfc.h:106
BlockVector< double > FEVector
The vector class used by applications.
Definition: application_data.h:39
The data type used in function calls of Application.
Definition: fe_vectors.h:59
Application handling matrices and assembling the linear system to solve the sensitivity equations...
Definition: optimization_block_matrix_application.h:62
This class describes properties of pure hydrogen.
Definition: PureGas.h:1098
boost::shared_ptr< FuelCellShop::Layer::GasDiffusionLayer< dim > > CGDL
The object CGDL layer will contain all the information relevant to the the cathode GDL...
Definition: app_pemfc.h:429
virtual void dirichlet_bc(std::map< unsigned int, double > &boundary_values) const
Member function used to set dirichlet boundary conditions.
boost::shared_ptr< ApplicationData > data
Object for auxiliary data.
Definition: application_base.h:342
FuelCellShop::Material::Oxygen oxygen
The cathode contains water vapour, so we need to create an object water in order to compute viscosity...
Definition: app_pemfc.h:379
boost::shared_ptr< FuelCellShop::Layer::CatalystLayer< dim > > ACL
The object ACL layer will contain all the information relevant to the the anode catalyst layer...
Definition: app_pemfc.h:408
std::vector< double > design_var_value
Stores the values of the design variables so that the number can be appended to the ...
Definition: app_pemfc.h:478
Class used to calculate the ORR current density and coverages (if provided in the kinetic model) by t...
Definition: response_current_density.h:74
void vector_value(const Point< dim > &p, Vector< double > &v) const
This is the member function that computes the value of the initial solution for a given point...
This class describes properties of pure WaterVapor.
Definition: PureGas.h:1157
virtual void set_parameters(const std::vector< std::string > &name_dvar, const std::vector< double > &value_dvar, ParameterHandler &param)
Function called by optimization loop in order to set the values in the ParameterHandler to the new de...
Definition: app_pemfc.h:196