OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
app_pemfc_nonisothermal.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 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_nonisothermal.h 21-05-2013
11 // - Description: Class designed to solve a non-isothermal PEMFC model.
12 // - Developers: Madhur Bhaiya
13 // - Id: $Id: app_pemfc_nonisothermal.h 2605 2014-08-15 03:36:44Z secanell $
14 //
15 //---------------------------------------------------------------------------
16 
17 #ifndef _FUELCELL__APP_PEMFC_NONISOTHERMAL__H
18 #define _FUELCELL__APP_PEMFC_NONISOTHERMAL__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/full_matrix.h"
28 #include "lac/solver_cg.h"
29 #include "lac/solver_gmres.h"
30 #include "lac/precondition.h"
31 #include "lac/precondition_block.h"
32 #include "lac/block_matrix_array.h"
33 #include "lac/sparse_ilu.h"
34 #include "lac/sparse_direct.h"
35 
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 
45 #include "boost/shared_ptr.hpp"
46 
47 // Include FuelCell classes
48 #include "fcst_constants.h"
50 #include "solver_utils.h"
51 #include "linear_solvers.h"
52 
53 #include "operating_conditions.h"
54 #include "geometries.h"
55 
56 #include "gas_diffusion_layer.h"
57 #include "micro_porous_layer.h"
58 #include "catalyst_layer.h"
59 #include "membrane_layer.h"
60 #include "PureGas.h"
61 
62 // Equation Classes
64 #include "reaction_source_terms.h"
68 #include "sorption_source_terms.h"
70 
77 
78 //Include STL
79 #include <fstream>
80 #include <iostream>
81 #include <sstream>
82 #include <cmath>
83 #include <vector>
84 #include <algorithm>
85 
86 
87 namespace FuelCell
88 {
89  namespace InitialSolution
90  {
96  template <int dim>
98  :
99  public Function<dim>
100  {
101  public:
106  boost::shared_ptr< FuelCellShop::Geometry::GridBase<dim> > grid,
107  FuelCell::SystemManagement* system_mgmt);
112 
117  void vector_value (const Point<dim> &p,
118  Vector<double> &v) const;
119 
120  private:
123 
125  boost::shared_ptr< FuelCellShop::Geometry::GridBase<dim> > grid;
126 
128  };
129  } //end namespace InitialSolution
130 
131 
132  namespace Application
133  {
134  //---------------------------------------------------------------------------
135  //---------------------------------------------------------------------------
136  //---------------------------------------------------------------------------
156  template <int dim>
158  :
160  {
161  public:
162 
164 
165 
172  AppPemfcNIThermal (boost::shared_ptr<FuelCell::ApplicationCore::ApplicationData> data =
173  boost::shared_ptr<FuelCell::ApplicationCore::ApplicationData> ());
174 
185  virtual void declare_parameters(ParameterHandler& param);
186 
193  virtual void set_parameters(const std::vector<std::string>& name_dvar,
194  const std::vector<double>& value_dvar,
195  ParameterHandler& param) {};
196 
201  void _initialize(ParameterHandler& param);
202 
206  virtual void initialize(ParameterHandler& param);
207 
211  virtual void initialize_solution (FEVector& initial_guess,
212  std::shared_ptr<Function<dim> > initial_function = std::shared_ptr<Function<dim> >());
214 
216 
217 
223  virtual void cell_matrix(FuelCell::ApplicationCore::MatrixVector& cell_matrices,
224  const typename DoFApplication<dim>::CellInfo& cell);
234  virtual void cell_residual(FuelCell::ApplicationCore::FEVector& cell_vector,
235  const typename DoFApplication<dim>::CellInfo& cell);
236 
240  virtual void bdry_matrix(FuelCell::ApplicationCore::MatrixVector& bdry_matrices,
241  const typename DoFApplication<dim>::FaceInfo& bdry_info);
242 
246  virtual void bdry_residual(FuelCell::ApplicationCore::FEVector& bdry_vector,
247  const typename DoFApplication<dim>::FaceInfo& bdry_info);
249 
256  virtual void dirichlet_bc(std::map<unsigned int, double>& boundary_values) const;
257 
264  virtual void check_responses();
265 
269  virtual void cell_responses (std::vector<double>& resp,
270  const typename DoFApplication<dim>::CellInfo& info,
276  virtual void global_responses (std::vector<double>& resp,
278 
284  virtual void cell_dresponses_dl(std::vector<std::vector<double> >& /*cell_df_dl*/,
285  const typename DoFApplication<dim>::CellInfo& /*info*/,
286  const FuelCell::ApplicationCore::FEVector& /*sol*/) {};
287 
293  virtual void global_dresponses_dl(std::vector<std::vector<double> >& df_dl,
300  virtual void cell_dresponses_du(std::vector<FuelCell::ApplicationCore::FEVector >& /*cell_df_du*/,
301  const typename DoFApplication<dim>::CellInfo& /*info*/,
302  std::vector<std::vector<double> >& /*src*/) {};
303 
309  virtual void global_dresponses_du(std::vector<FuelCell::ApplicationCore::FEVector >& df_du,
311 
312 
317  virtual double evaluate (const FuelCell::ApplicationCore::FEVectors& src);
318 
323  virtual void data_out(const std::string& filename,
325 
326  protected:
327 
329 
330 
334 
336 
337 
342 
347 
352 
358 
360 
361  boost::shared_ptr< FuelCellShop::Layer::GasDiffusionLayer<dim> > AGDL;
362  boost::shared_ptr< FuelCellShop::Layer::GasDiffusionLayer<dim> > CGDL;
363  boost::shared_ptr< FuelCellShop::Layer::MicroPorousLayer<dim> > AMPL;
364  boost::shared_ptr< FuelCellShop::Layer::MicroPorousLayer<dim> > CMPL;
365  boost::shared_ptr< FuelCellShop::Layer::CatalystLayer<dim> > ACL;
366  boost::shared_ptr< FuelCellShop::Layer::CatalystLayer<dim> > CCL;
367  boost::shared_ptr< FuelCellShop::Layer::MembraneLayer<dim> > ML;
368 
369 
371 
372 
376 
381 
386 
391 
396 
401 
403 
405 
408 
410 
412 
414 
416 
418 
420 
422 
424 
427 
429  std::vector<std::string> design_var;
430 
432  std::vector<double> design_var_value;
433 
434  private:
435 
436  double l_channel;
437 
438  double l_land;
439 
443  double time_k;
444 
450  void set_default_parameters_for_application(ParameterHandler &param)
451  {
452  param.enter_subsection("System management");
453  {
454  param.set("Number of solution variables","5");
455  param.enter_subsection("Solution variables");
456  {
457  param.set("Solution variable 1","oxygen_molar_fraction");
458  param.set("Solution variable 2","water_molar_fraction");
459  param.set("Solution variable 3","protonic_electrical_potential");
460  param.set("Solution variable 4","electronic_electrical_potential");
461  param.set("Solution variable 5","membrane_water_content");
462  param.set("Solution variable 6","temperature_of_REV");
463  }
464  param.leave_subsection();
465 
466  param.enter_subsection("Equations");
467  {
468  param.set("Equation 1","Ficks Transport Equation - oxygen");
469  param.set("Equation 2","Ficks Transport Equation - water");
470  param.set("Equation 3","Proton Transport Equation");
471  param.set("Equation 4","Electron Transport Equation");
472  param.set("Equation 5","Membrane Water Content Transport Equation");
473  param.set("Equation 6","Thermal Transport Equation");
474  }
475  param.leave_subsection();
476  }
477  param.leave_subsection();
478  param.enter_subsection("Discretization");
479  {
480  param.set("Element","FESystem[FE_Q(1)^6]");
481  }
482  param.leave_subsection();
483  }
484  };
485  }
486 }
487 
488 #endif //_FUELCELL__AppPemfcNIThermal_H
This class is used to solve the physical pheonoma on a complete membrane electrode assembly...
Definition: app_pemfc_nonisothermal.h:157
virtual void declare_parameters(ParameterHandler &param)
Declare all parameters that are needed for:
virtual void cell_matrix(FuelCell::ApplicationCore::MatrixVector &cell_matrices, const typename DoFApplication< dim >::CellInfo &cell)
Integration of local bilinear form.
Class used to store, read from file and define the operating conditions for a fuel cell...
Definition: operating_conditions.h:110
FuelCellShop::Material::Oxygen oxygen
The cathode contains oxygen, so we need to create an object oxygen in order to compute viscosity...
Definition: app_pemfc_nonisothermal.h:346
FuelCellShop::Equation::ReactionSourceTerms< dim > reaction_source_terms
ReactionSourceTerms object.
Definition: app_pemfc_nonisothermal.h:395
FuelCellShop::Material::Hydrogen hydrogen
The anode contains hydrogen, so we need to create an object hydrogen in order to compute viscosity...
Definition: app_pemfc_nonisothermal.h:356
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_nonisothermal.h:432
FuelCellShop::PostProcessing::SorptionHeatResponse< dim > sorptionHeat
Definition: app_pemfc_nonisothermal.h:419
FuelCell::OperatingConditions * OC
Operating conditions class object.
Definition: app_pemfc_nonisothermal.h:122
This class assembles source terms corresponding to sorption/desorption of water inside the catalyst l...
Definition: sorption_source_terms.h:103
virtual void dirichlet_bc(std::map< unsigned int, double > &boundary_values) const
Member function used to set dirichlet boundary conditions.
double l_channel
Width of the channel.
Definition: app_pemfc_nonisothermal.h:436
FuelCellShop::PostProcessing::ProtonOhmicHeatResponse< dim > protonOhmicHeat
Definition: app_pemfc_nonisothermal.h:415
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...
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
boost::shared_ptr< FuelCellShop::Layer::MicroPorousLayer< dim > > CMPL
Cathode MPL Layer.
Definition: app_pemfc_nonisothermal.h:364
virtual void check_responses()
This class is called by responses to make sure that all responses requested are implemented in either...
boost::shared_ptr< FuelCellShop::Layer::CatalystLayer< dim > > ACL
Anode Catalyst Layer.
Definition: app_pemfc_nonisothermal.h:365
Class used to calculate the heat generated due to HOR inside the anode catalyst layer.
Definition: response_reaction_heat.h:300
virtual void data_out(const std::string &filename, const FuelCell::ApplicationCore::FEVectors &src)
Reimplementation of the routine in the base class BaseApplication in namespace AppFrame so that the r...
virtual void cell_residual(FuelCell::ApplicationCore::FEVector &cell_vector, const typename DoFApplication< dim >::CellInfo &cell)
Integration of the rhs of the equations.
virtual double evaluate(const FuelCell::ApplicationCore::FEVectors &src)
Post-processing.
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...
Class used to calculate the protonic ohmic heat generated in the proton conducting layers...
Definition: response_ohmic_heat.h:278
AppPemfcNIThermal(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
This class deals with Thermal Transport Equation.
Definition: thermal_transport_equation.h:190
boost::shared_ptr< FuelCellShop::Layer::GasDiffusionLayer< dim > > CGDL
Cathhode GDL Layer.
Definition: app_pemfc_nonisothermal.h:362
This class deals with Membrane Water Content Transport Equation.
Definition: lambda_transport_equation.h:133
boost::shared_ptr< FuelCellShop::Layer::MicroPorousLayer< dim > > AMPL
Anode MPL Layer.
Definition: app_pemfc_nonisothermal.h:363
FuelCellShop::PostProcessing::ElectronOhmicHeatResponse< dim > electronOhmicHeat
Definition: app_pemfc_nonisothermal.h:417
FuelCellShop::PostProcessing::ORRReactionHeatResponse< dim > catReactionHeat
Definition: app_pemfc_nonisothermal.h:421
FuelCellShop::Equation::NewFicksTransportEquation< dim > ficks_water_hydrogen
Definition: app_pemfc_nonisothermal.h:406
FuelCell::OperatingConditions OC
Operating conditions.
Definition: app_pemfc_nonisothermal.h:332
This class deals with Ficks Transport Equation.
Definition: new_ficks_transport_equation.h:132
FuelCellShop::Equation::SorptionSourceTerms< dim > sorption_source_terms
SorptionSourceTerms object.
Definition: app_pemfc_nonisothermal.h:400
Class used to calculate the amount of water sorbed inside the catalyst layer.
Definition: response_water_sorption.h:120
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_nonisothermal.h:300
virtual void bdry_residual(FuelCell::ApplicationCore::FEVector &bdry_vector, const typename DoFApplication< dim >::FaceInfo &bdry_info)
Assemble local boundary residual.
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_nonisothermal.h:450
This class is created for the objects handed to the mesh loops.
Definition: mesh_loop_info_objects.h:625
boost::shared_ptr< FuelCellShop::Layer::GasDiffusionLayer< dim > > AGDL
Anode GDL Layer.
Definition: app_pemfc_nonisothermal.h:361
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.
This class describes properties of pure oxygen.
Definition: PureGas.h:980
FuelCellShop::PostProcessing::WaterSorptionResponse< dim > waterSorption
Definition: app_pemfc_nonisothermal.h:425
boost::shared_ptr< FuelCellShop::Layer::CatalystLayer< dim > > CCL
Cathode Catalyst Layer.
Definition: app_pemfc_nonisothermal.h:366
std::vector< MatrixBlock< FullMatrix< double > > > MatrixVector
The matrix vector used in the mesh loops.
Definition: matrix_block.h:102
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_nonisothermal.h:429
FuelCellShop::Material::WaterVapor water
The cathode/anode contains water vapour, so we need to create an object water in order to compute vis...
Definition: app_pemfc_nonisothermal.h:341
This class describes properties of pure nitrogen.
Definition: PureGas.h:1039
double l_land
Width of the landing.
Definition: app_pemfc_nonisothermal.h:438
Class used to calculate the heat generated due to ORR inside the cathode catalyst layer...
Definition: response_reaction_heat.h:119
virtual void bdry_matrix(FuelCell::ApplicationCore::MatrixVector &bdry_matrices, const typename DoFApplication< dim >::FaceInfo &bdry_info)
Assemble local boundary matrix.
FuelCellShop::Equation::ElectronTransportEquation< dim > electron_transport
ElectronTransportEquation object.
Definition: app_pemfc_nonisothermal.h:390
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
boost::shared_ptr< FuelCellShop::Geometry::GridBase< dim > > grid
Geometry class object.
Definition: app_pemfc_nonisothermal.h:125
virtual void initialize_solution(FEVector &initial_guess, std::shared_ptr< Function< dim > > initial_function=std::shared_ptr< Function< dim > >())
Initialize nonlinear solution.
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_nonisothermal.h:284
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::NewFicksTransportEquation< dim > ficks_oxygen_nitrogen
Definition: app_pemfc_nonisothermal.h:402
FuelCellShop::Equation::ProtonTransportEquation< dim > proton_transport
ProtonTransportEquation object.
Definition: app_pemfc_nonisothermal.h:380
IMPORTANT: Add all new solution variables and equations here !
Definition: system_management.h:271
double time_k
Time constant for sorption isotherm [1/s].
Definition: app_pemfc_nonisothermal.h:443
void _initialize(ParameterHandler &param)
Set up how many equations are needed and read in parameters for the parameter handler in order to ini...
FuelCell Geometry information class.
Definition: geometry.h:91
FuelCellShop::Equation::LambdaTransportEquation< dim > lambda_transport
LambdaTransportEquation object.
Definition: app_pemfc_nonisothermal.h:385
Class used to calculate the electronic ohmic heat generated in the electron conducting layers...
Definition: response_ohmic_heat.h:122
AppPemfcNIThermalIC(FuelCell::OperatingConditions *OC, boost::shared_ptr< FuelCellShop::Geometry::GridBase< dim > > grid, FuelCell::SystemManagement *system_mgmt)
Constructor.
Class used to calculate the heat generated due to sorption of water inside the catalyst layer...
Definition: response_sorption_heat.h:118
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_nonisothermal.h:193
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...
FuelCellShop::PostProcessing::ORRCurrentDensityResponse< dim > ORRCurrent
Definition: app_pemfc_nonisothermal.h:411
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
FuelCellShop::PostProcessing::HORReactionHeatResponse< dim > anReactionHeat
Definition: app_pemfc_nonisothermal.h:423
This class describes properties of pure hydrogen.
Definition: PureGas.h:1098
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.
FuelCellShop::Equation::NewFicksTransportEquation< dim > ficks_water_nitrogen
Definition: app_pemfc_nonisothermal.h:404
FuelCellShop::Equation::ThermalTransportEquation< dim > thermal_transport
ThermalTransportEquation object.
Definition: app_pemfc_nonisothermal.h:375
boost::shared_ptr< FuelCellShop::Layer::MembraneLayer< dim > > ML
Membrane Layer.
Definition: app_pemfc_nonisothermal.h:367
boost::shared_ptr< ApplicationData > data
Object for auxiliary data.
Definition: application_base.h:342
This class is used when solving the problem using Newton&#39;s method to provide an initial solution...
Definition: app_pemfc_nonisothermal.h:97
FuelCellShop::Material::Nitrogen nitrogen
The cathode contains nitrogen as solvent, so we need to create an object nitrogen in order to compute...
Definition: app_pemfc_nonisothermal.h:351
virtual void initialize(ParameterHandler &param)
Call the other initialize routines from the inherited classes.
Class used to calculate the ORR current density and coverages (if provided in the kinetic model) by t...
Definition: response_current_density.h:74
FuelCell::SystemManagement * system
Definition: app_pemfc_nonisothermal.h:127
FuelCellShop::PostProcessing::HORCurrentDensityResponse< dim > HORCurrent
Definition: app_pemfc_nonisothermal.h:413
This class describes properties of pure WaterVapor.
Definition: PureGas.h:1157