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 //
14 //---------------------------------------------------------------------------
15 
16 #ifndef _FUELCELL__APP_PEMFC__H
17 #define _FUELCELL__APP_PEMFC__H
18 //-- OpenFCST
21 #include <layers/design_MPL.h>
22 #include <materials/PureGas.h>
23 #include <materials/PureLiquid.h>
25 #include <layers/homogeneous_CL.h>
26 #include <layers/nafion_membrane.h>
27 #include <materials/GasMixture.h>
31 
38 
42 
43 
46 namespace FuelCell
47 {
48 
49  namespace InitialSolution
50  {
56  template <int dim>
57  class AppPemfcIC
58  :
59  public Function<dim>
60  {
61  public:
69  ~AppPemfcIC ();
70 
75  void vector_value (const Point<dim> &p,
76  Vector<double> &v) const;
77 
78  private:
81 
83  boost::shared_ptr< FuelCellShop::Geometry::GridBase<dim> > grid;
84  };
85 
86  } //end namespace InitialSolution
87 
88 
89  namespace Application
90  {
91  //---------------------------------------------------------------------------
92  //---------------------------------------------------------------------------
93  //---------------------------------------------------------------------------
113  template <int dim>
114  class AppPemfc
115  :
117  {
118 
119  public:
120 
127  AppPemfc (boost::shared_ptr<FuelCell::ApplicationCore::ApplicationData> data = boost::shared_ptr<FuelCell::ApplicationCore::ApplicationData> ());
128 
132  ~AppPemfc ();
139  virtual void declare_parameters(ParameterHandler& param);
140 
147  virtual void set_parameters(const std::vector<std::string>& name_dvar,
148  const std::vector<double>& value_dvar,
149  ParameterHandler& param){};
150 
156  virtual void initialize(ParameterHandler& param);
157 
161  virtual void initialize_solution (FEVector& initial_guess,
162  std::shared_ptr<Function<dim> > initial_function = std::shared_ptr<Function<dim> >());
177  virtual void cell_matrix(MatrixVector& cell_matrices,
178  const typename DoFApplication<dim>::CellInfo& cell);
188  virtual void cell_residual(FuelCell::ApplicationCore::FEVector& cell_vector,
189  const typename DoFApplication<dim>::CellInfo& cell);
190 
191 
198  virtual void dirichlet_bc(std::map<unsigned int, double>& boundary_values) const;
199 
206  virtual void check_responses();
207 
211  virtual void cell_responses (std::vector<double>& resp,
212  const typename DoFApplication<dim>::CellInfo& info,
218  virtual void global_responses (std::vector<double>& resp,
220 
226  virtual void cell_dresponses_dl(std::vector<std::vector<double> >& /*cell_df_dl*/,
227  const typename DoFApplication<dim>::CellInfo& /*info*/,
228  const FuelCell::ApplicationCore::FEVector& /*sol*/) {};
229 
235  virtual void global_dresponses_dl(std::vector<std::vector<double> >& df_dl,
242  virtual void cell_dresponses_du(std::vector<FuelCell::ApplicationCore::FEVector >& /*cell_df_du*/,
243  const typename DoFApplication<dim>::CellInfo& /*info*/,
244  std::vector<std::vector<double> >& /*src*/) {};
245 
251  virtual void global_dresponses_du(std::vector<FuelCell::ApplicationCore::FEVector >& df_du,
253 
254 
259  virtual double evaluate (const FuelCell::ApplicationCore::FEVectors& src);
260 
265  virtual void data_out(const std::string &basename,
267 
268 
272  void data_out(std::string basename, const FuelCell::ApplicationCore::FEVectors vectors, std::vector< std::string > solution_names);
273 
274  protected:
275 
277 
278 
284  std::vector<std::string> equation_names;
290  std::vector<std::string> component_names;
292 
294 
295 
299 
301 
302 
306  //FuelCellShop::Material::Nafion electrolyte;
307 
311  //FuelCellShop::Material::CarbonBlack catalyst_support;
312 
316  //FuelCellShop::Material::Platinum catalyst;
317 
322 
327 
332 
337 
339 
341 
342 
345  boost::shared_ptr<FuelCellShop::Layer::GasDiffusionLayer<dim> > AGDL;
346 
350  boost::shared_ptr<FuelCellShop::Layer::MicroPorousLayer<dim> > AMPL;
351 
355  boost::shared_ptr<FuelCellShop::Layer::CatalystLayer<dim> > ACL;
356 
360  boost::shared_ptr<FuelCellShop::Layer::MembraneLayer<dim> > ML;
361 
362 
366  boost::shared_ptr<FuelCellShop::Layer::CatalystLayer<dim> > CCL;
367 
371  boost::shared_ptr<FuelCellShop::Layer::MicroPorousLayer<dim> > CMPL;
372 
376  boost::shared_ptr<FuelCellShop::Layer::GasDiffusionLayer<dim> > CGDL;
378 
380 
381 
388 
390 
391 
395 
400 
405 
409 
414 
420 
422  std::vector<std::string> design_var;
423 
425  std::vector<double> design_var_value;
426 
427  private:
428 
429  double l_channel;
430 
431  double l_land;
432 
438  void set_default_parameters_for_application(ParameterHandler &param)
439  {
440  param.enter_subsection("System management");
441  {
442  param.set("Number of solution variables","5");
443  param.enter_subsection("Solution variables");
444  {
445  param.set("Solution variable 1","oxygen_molar_fraction");
446  param.set("Solution variable 2","water_molar_fraction");
447  param.set("Solution variable 3","protonic_electrical_potential");
448  param.set("Solution variable 4","electronic_electrical_potential");
449  param.set("Solution variable 5","membrane_water_content");
450  }
451  param.leave_subsection();
452 
453  param.enter_subsection("Equations");
454  {
455  param.set("Equation 1","Ficks Transport Equation - oxygen");
456  param.set("Equation 2","Ficks Transport Equation - water");
457  param.set("Equation 3","Proton Transport Equation");
458  param.set("Equation 4","Electron Transport Equation");
459  param.set("Equation 5","Membrane Water Content Transport Equation");
460  }
461  param.leave_subsection();
462  }
463  param.leave_subsection();
464  param.enter_subsection("Discretization");
465  {
466  param.set("Element","FESystem[FE_Q(1)^5]");
467  }
468  param.leave_subsection();
469  }
470 
471  };
472 
473  }
474 
475 }
476 
477 #endif //_FUELCELL__APPPEMFC_H
FuelCellShop::Equation::FicksTransportEquation< dim > ficks_water_nitrogen
Definition: app_pemfc.h:407
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:331
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:350
FuelCellShop::Material::WaterVapor water
Object used to calculate the properties of the electrolyte in the catalyst layer. ...
Definition: app_pemfc.h:321
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:242
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:336
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:422
Class used to store, read from file and define the operating conditions for a fuel cell...
Definition: operating_conditions.h:118
FuelCellShop::Equation::ElectronTransportEquation< dim > electron_transport
ElectronTransportEquation object.
Definition: app_pemfc.h:404
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:226
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:413
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:101
FuelCellShop::PostProcessing::HORCurrentDensityResponse< dim > HORCurrent
Post-processing object to compute the HOR current density.
Definition: app_pemfc.h:384
FuelCellShop::Equation::FicksTransportEquation< dim > ficks_water_hydrogen
Definition: app_pemfc.h:408
virtual double evaluate(const FuelCell::ApplicationCore::FEVectors &src)
Post-processing.
This class deals with Proton Transport Equation.
Definition: proton_transport_equation.h:132
Class used to calculate the current density at the anode catalyst layer.
Definition: response_current_density.h:180
double l_land
Width of the landing.
Definition: app_pemfc.h:431
FuelCell::OperatingConditions * OC
Operating conditions class object.
Definition: app_pemfc.h:80
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:371
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:114
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:128
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:394
This class deals with Membrane Water Content Transport Equation.
Definition: lambda_transport_equation.h:128
std::vector< std::string > equation_names
Structure where we store the problem we want to solve.
Definition: app_pemfc.h:284
double l_channel
Width of the channel.
Definition: app_pemfc.h:429
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:438
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:366
Class used to calculate the amount of water sorbed inside the catalyst layer.
Definition: response_water_sorption.h:106
This class is created for the objects handed to the mesh loops.
Definition: mesh_loop_info_objects.h:544
This class describes properties of pure oxygen.
Definition: PureGas.h:974
FuelCellShop::PostProcessing::ORRCurrentDensityResponse< dim > ORRCurrent
Post-processing object to compute the ORR current density.
Definition: app_pemfc.h:382
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:345
virtual void declare_parameters(ParameterHandler &param)
Declare all parameters that are needed for:
OperatingConditions OC
Initial operating conditions class.
Definition: app_pemfc.h:297
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:1027
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:321
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)
Set up how many equations are needed and read in parameters for the parameter handler in order to ini...
FuelCellShop::Equation::FicksTransportEquation< dim > ficks_oxygen_nitrogen
Definition: app_pemfc.h:406
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:37
FuelCellShop::Equation::LambdaTransportEquation< dim > lambda_transport
LambdaTransportEquation object.
Definition: app_pemfc.h:399
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:360
FuelCellShop::PostProcessing::WaterSorptionResponse< dim > WaterSorption
Post-processing object to compute the water sorption in the CL.
Definition: app_pemfc.h:386
FuelCellShop::Equation::SorptionSourceTerms< dim > sorption_source_terms
SorptionSourceTerms object.
Definition: app_pemfc.h:418
FuelCell Geometry information class.
Definition: geometry.h:92
std::vector< std::string > component_names
Structure where we store the name of each component in our problem.
Definition: app_pemfc.h:290
boost::shared_ptr< FuelCellShop::Geometry::GridBase< dim > > grid
Geometry class object.
Definition: app_pemfc.h:83
virtual void cell_matrix(MatrixVector &cell_matrices, const typename DoFApplication< dim >::CellInfo &cell)
Integration of local bilinear form.
This class is used when solving the problem using Newton&#39;s method to provide an initial solution...
Definition: app_pemfc.h:57
BlockVector< double > FEVector
The vector class used by applications.
Definition: application_data.h:46
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:49
This class deals with Fick&#39;s Transport Equation.
Definition: ficks_transport_equation.h:132
This class describes properties of pure hydrogen.
Definition: PureGas.h:1081
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:376
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:348
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:326
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:355
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:425
Class used to calculate the ORR current density and coverages (if provided in the kinetic model) by t...
Definition: response_current_density.h:59
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:1134
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:147