OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
reaction_source_terms.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2006-2015 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: reaction_source_terms.h
11 // - Description: This class is used to assemble both cell matrix and cell residual
12 // for reaction source terms in the catalyst layers for various equation classes
13 // - Developers: Madhur Bhaiya, Marc Secanell, Valentin N. Zingan
14 // - Id: $Id$
15 //
16 // ----------------------------------------------------------------------------
17 
18 #ifndef _FCST_FUELCELLSHOP_EQUATION_REACTION_SOURCE_TERMS_H_
19 #define _FCST_FUELCELLSHOP_EQUATION_REACTION_SOURCE_TERMS_H_
20 
21 #include "utils/fcst_constants.h"
22 
25 
26 #include "layers/catalyst_layer.h"
27 
31 
32 namespace FuelCellShop
33 {
34  namespace Equation
35  {
36 
38 
39 
45  DeclException2(VariableNotFoundForKinetics,
46  std::string,
47  std::string,
48  << "For " << arg1 << " kinetics source terms, \"" << arg2 << "\" is not found as one of the solution variables.");
49 
51 
59  template<int dim>
60  class ReactionSourceTerms : public EquationBase<dim>
61  {
62  public:
63 
65 
66 
71 
75  virtual ~ReactionSourceTerms();
76 
80  virtual void declare_parameters(ParameterHandler& param) const;
81 
85  virtual void initialize(ParameterHandler& param);
86 
92  {
93  cathode_kinetics = kinetics;
94  }
95 
101  {
102  anode_kinetics = kinetics;
103  }
104 
106 
108 
109 
116 
123 
125 
127 
128 
137  virtual void adjust_internal_cell_couplings( std::vector< couplings_map >& dst,
138  const std::vector< FuelCellShop::Material::PureGas* >& gases = std::vector< FuelCellShop::Material::PureGas* >() );
139 
144  virtual void print_equation_info() const;
145 
150  inline bool get_irrev_heat_ccl() const
151  {
152  return irrev_heat_ccl;
153  }
154 
159  inline bool get_irrev_heat_acl() const
160  {
161  return irrev_heat_acl;
162  }
163 
168  inline bool get_rev_heat() const
169  {
170  return rev_heat;
171  }
172 
177  inline double get_factor_rev_heat_ccl() const
178  {
179  return factor_rev_heat_ccl;
180  }
181 
187  inline bool get_water_vap_heat_ccl() const
188  {
189  return water_vap_heat_ccl;
190  }
191 
196  {
197  return cathode_kinetics;
198  }
199 
204  {
205  return anode_kinetics;
206  }
207 
209 
210  protected:
211 
213 
214 
224 
234 
241 
264  const std::string& eq_name,
265  const FEValuesBase<dim>& test_fe,
266  const std::vector< std::vector<double> >& test_shape_functions,
267  const double& sourceterm_factor);
268 
270 
272 
273 
279 
285 
290  bool rev_heat;
291 
296 
302 
308 
310 
312 
313 
318 
323 
325 
327 
328 
335 
342 
344 
346 
347 
352 
357 
362 
367 
368 
373 
378 
383 
387  double F;
388 
392  double M_water;
393 
395 
397 
398 
406  std::vector< std::vector<double> > phi_T_cell;
407 
415  std::vector< std::vector<double> > phi_xOxygen_cell;
416 
424  std::vector< std::vector<double> > phi_phiS_cell;
425 
433  std::vector< std::vector<double> > phi_phiM_cell;
434 
442  std::vector< std::vector<double> > phi_xWater_cell;
443 
451  std::vector< std::vector<double> > phi_s_cell;
452 
457  std::vector<double> current_cell;
458 
466  std::vector<double> heat_cell;
467 
472  std::vector<double> dcurrent_dphiS_cell;
473 
478  std::vector<double> dcurrent_dphiM_cell;
479 
483  std::vector<double> dcurrent_dT_cell;
484 
489  std::vector<double> dcurrent_dxOxygen_cell;
490 
495  std::vector<double> dcurrent_dxWater_cell;
496 
501  std::vector<double> dheat_dphiS_cell;
502 
507  std::vector<double> dheat_dphiM_cell;
508 
513  std::vector<double> dheat_dT_cell;
514 
519  std::vector<double> dheat_dxOxygen_cell;
520 
525  std::vector<double> dheat_dxWater_cell;
526 
533 
539 
545 
551 
558 
565 
567 
569 
570 
578 
586 
591  unsigned int last_iter_cell;
592 
594 
596 
597 
599  // METHODS //
601 
613  template<typename INFO>
614  void make_assemblers_generic_constant_data(const INFO& InFo,
616 
621 
627 
633  virtual void make_matrix_block_indices();
634 
640  virtual void make_residual_indices();
641 
643  // DATA 1 //
645 
649  unsigned int n_species;
650 
654  unsigned int indexO2;
655 
659  unsigned int indexH2;
660 
664  unsigned int indexH2O;
665 
667  // DATA 2 //
669 
673  double multiplierO2;
674 
678  double multiplierH2;
679 
684 
686  // DATA 3 //
688 
692  std::vector<double> molar_mass;
693 
695  // DATA 4 //
697 
701  std::vector< FEValuesExtractors::Scalar > density_extractors;
702 
706  FEValuesExtractors::Scalar electronic_electrical_potential_extractor;
707 
711  FEValuesExtractors::Scalar protonic_electrical_potential_extractor;
712 
714  // DATA 5 //
716 
722  std::vector<double> T_mixture;
723 
725  // DATA 7 //
727 
733  std::vector<double> ORR_current_density;
734 
742 
750 
758 
760  // DATA 8 //
762 
768  std::vector<double> HOR_current_density;
769 
777 
785 
793 
795  // DATA 9 //
797 
803  std::vector< std::vector<double> > density_old;
804 
811 
818 
820  // DATA 10 //
822 
831  std::vector< std::vector< std::vector<double> > > phi_density;
832 
840  std::vector< std::vector<double> > phi_electronic_electrical_potential;
841 
849  std::vector< std::vector<double> > phi_protonic_electrical_potential;
850 
852  // DATA 11 //
854 
858  std::string eq_generic_prefix;
859 
863  std::vector<std::string> eq_postfixes;
864 
868  std::vector<std::string> var_postfixes;
869 
873  std::string eq_name;
874 
878  std::string var_name;
879 
881 
882 };
883 
884 } // Equation
885 
886 } // FuelCellShop
887 
888 #endif
std::vector< double > dheat_dphiS_cell
Derivative of heat produced w.r.t.
Definition: reaction_source_terms.h:501
std::vector< std::string > eq_postfixes
For internal use only.
Definition: reaction_source_terms.h:863
double factor_saturationtranseq_cell
Factor for.
Definition: reaction_source_terms.h:564
virtual void assemble_cell_residual(FuelCell::ApplicationCore::FEVector &cell_residual, const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
Assemble local cell residual.
double M_water
Molar weight of water in grams/mole.
Definition: reaction_source_terms.h:392
virtual void initialize(ParameterHandler &param)
Initialize parameters.
double factor_watertranseq_cell
Factor for.
Definition: reaction_source_terms.h:557
FuelCellShop::Kinetics::BaseKinetics * get_anode_kinetics() const
Accessor for anode catalyst layer FuelCellShop::Kinetics::BaseKinetics pointer.
Definition: reaction_source_terms.h:203
std::string var_name
For internal use only.
Definition: reaction_source_terms.h:878
virtual void make_assemblers_generic_constant_data()
This function computes Local CG FEM based assemblers - constant data (generic).
std::vector< std::vector< double > > phi_s_cell
shape functions.
Definition: reaction_source_terms.h:451
FuelCellShop::Kinetics::BaseKinetics * anode_kinetics
Pointer to Anode Kinetics object, initialized in the constructor.
Definition: reaction_source_terms.h:322
std::vector< double > DHOR_current_density_Dhydrogen_concentration
HOR current density derivative with respect to hydrogen concentration (gas, NOT gas-liquid) in the qu...
Definition: reaction_source_terms.h:776
std::vector< double > T_mixture
Constant temperature of species mixture in the quadrature points of a cell, .
Definition: reaction_source_terms.h:722
virtual void print_equation_info() const
This function prints out the info for this class.
bool cell_matrix_counter
Counter set to TRUE when cell_matrix is being assembled.
Definition: reaction_source_terms.h:577
std::vector< double > dcurrent_dphiM_cell
Derivative of current w.r.t.
Definition: reaction_source_terms.h:478
unsigned int n_species
Number of species, .
Definition: reaction_source_terms.h:649
FuelCellShop::Equation::ReactionHeat * cathode_reactionheat
Pointer to Cathode ReactionHeat object.
Definition: reaction_source_terms.h:334
std::vector< double > DHOR_current_density_Dprotonic_electrical_potential
HOR current density derivative with respect to protonic electrical potential in the quadrature points...
Definition: reaction_source_terms.h:792
std::vector< double > dcurrent_dxOxygen_cell
Derivative of current w.r.t.
Definition: reaction_source_terms.h:489
virtual void assemble_cell_matrix(FuelCell::ApplicationCore::MatrixVector &cell_matrices, const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
Assemble local cell matrix.
std::vector< std::vector< double > > phi_xWater_cell
shape functions.
Definition: reaction_source_terms.h:442
std::vector< std::vector< double > > phi_protonic_electrical_potential
Protonic electrical potential shape functions.
Definition: reaction_source_terms.h:849
std::vector< double > current_cell
Current produced [A/cm^3] at all quadrature points in the cell.
Definition: reaction_source_terms.h:457
bool water_vapour_phase
This boolean data member indicates that whether the water is produced in vapour phase (i...
Definition: reaction_source_terms.h:301
double factor_protontranseq_cell
Factor for.
Definition: reaction_source_terms.h:538
FuelCell::SystemManagement * system_management
Pointer to the external YourApplication&lt;dim&gt;::system_management object.
Definition: equation_base.h:817
FuelCellShop::Equation::ReactionHeat * anode_reactionheat
Pointer to Anode Reactionheat object.
Definition: reaction_source_terms.h:341
VariableInfo x_oxygen
VariableInfo structure corresponding to &quot;oxygen_molar_fraction&quot;.
Definition: reaction_source_terms.h:351
std::vector< std::vector< std::vector< double > > > phi_density
Density shape functions.
Definition: reaction_source_terms.h:831
bool rev_heat
This boolean data member indicates that the reversible (entropic) heat source due to net reaction for...
Definition: reaction_source_terms.h:290
virtual void make_assemblers_cell_constant_data(const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info)
This function computes.
std::vector< std::vector< double > > density_old
Density of each species in the quadrature points of a cell at a previous Newton iteration.
Definition: reaction_source_terms.h:803
double factor_oxygentranseq_cell
Factor for.
Definition: reaction_source_terms.h:550
bool get_rev_heat() const
Method to get whether the reversible (entropic) heating due to net reaction forming liquid water prod...
Definition: reaction_source_terms.h:168
unsigned int indexH2
Keeps hydrogen set of fluid transport equations.
Definition: reaction_source_terms.h:659
std::vector< double > DORR_current_density_Doxygen_concentration
ORR current density derivative with respect to oxygen concentration (gas, NOT gas-liquid) in the quad...
Definition: reaction_source_terms.h:741
unsigned int last_iter_cell
Variable used to store the index in cell_info-&gt;global_data of the previous Newton solution The soluti...
Definition: reaction_source_terms.h:591
double multiplierH2
Hydrogen source multiplier, .
Definition: reaction_source_terms.h:678
std::vector< double > DHOR_current_density_Delectronic_electrical_potential
HOR current density derivative with respect to electronic electrical potential in the quadrature poin...
Definition: reaction_source_terms.h:784
FuelCellShop::Kinetics::BaseKinetics * get_cathode_kinetics() const
Accessor for cathode catalyst layer FuelCellShop::Kinetics::BaseKinetics pointer. ...
Definition: reaction_source_terms.h:195
FEValuesExtractors::Scalar electronic_electrical_potential_extractor
Electronic electrical potential extractor.
Definition: reaction_source_terms.h:706
VariableInfo phi_s
VariableInfo structure corresponding to &quot;electronic_electrical_potential&quot;.
Definition: reaction_source_terms.h:361
double F
Universal Faraday&#39;s constant.
Definition: reaction_source_terms.h:387
This class is created for the objects handed to the mesh loops.
Definition: mesh_loop_info_objects.h:625
void make_assemblers_cell_variable_data2(const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
As before but for fluid transport equations.
std::vector< double > ORR_current_density
ORR current density in the quadrature points of a cell at a previous Newton iteration.
Definition: reaction_source_terms.h:733
std::vector< std::vector< double > > phi_xOxygen_cell
shape functions.
Definition: reaction_source_terms.h:415
std::vector< MatrixBlock< FullMatrix< double > > > MatrixVector
The matrix vector used in the mesh loops.
Definition: matrix_block.h:102
std::vector< double > molar_mass
Molar mass of pure gas, .
Definition: reaction_source_terms.h:692
virtual void declare_parameters(ParameterHandler &param) const
Declare parameters.
bool cell_residual_counter
Counter set to TRUE when cell_residual is being assembled.
Definition: reaction_source_terms.h:585
std::vector< double > dheat_dT_cell
Derivative of heat produced w.r.t.
Definition: reaction_source_terms.h:513
std::vector< double > dcurrent_dxWater_cell
Derivative of current w.r.t.
Definition: reaction_source_terms.h:495
std::vector< double > dcurrent_dT_cell
Derivative of current w.r.t.
Definition: reaction_source_terms.h:483
DeclException2(VariableShouldExistForEquation, std::string, std::string,<< "The user-defined variable with name \""<< arg1<< "\" should be one of the solution variables for equation with name \""<< arg2<< "\"")
Exception thrown when a particular variable required by the equation class, does not exist in the use...
VariableInfo s_liquid_water
VariableInfo structure corresponding to &quot;liquid_water_saturation&quot;.
Definition: reaction_source_terms.h:382
std::vector< std::string > var_postfixes
For internal use only.
Definition: reaction_source_terms.h:868
std::vector< double > heat_cell
Heat produced due to electrochemical reaction [W/cm^2] at all quadrature points in the cell...
Definition: reaction_source_terms.h:466
double factor_electrontranseq_cell
Factor for.
Definition: reaction_source_terms.h:544
std::vector< double > DORR_current_density_Delectronic_electrical_potential
ORR current density derivative with respect to electronic electrical potential in the quadrature poin...
Definition: reaction_source_terms.h:749
double multiplierH2O
Water vapor source multiplier, .
Definition: reaction_source_terms.h:683
std::vector< double > HOR_current_density
HOR current density in the quadrature points of a cell at a previous Newton iteration.
Definition: reaction_source_terms.h:768
Virtual class used to provide the interface for all kinetic/reaction children.
Definition: base_kinetics.h:107
std::string eq_name
For internal use only.
Definition: reaction_source_terms.h:873
std::vector< FEValuesExtractors::Scalar > density_extractors
Density extractors.
Definition: reaction_source_terms.h:701
std::vector< double > dcurrent_dphiS_cell
Derivative of current w.r.t.
Definition: reaction_source_terms.h:472
FEValuesExtractors::Scalar protonic_electrical_potential_extractor
Protonic electrical potential extractor.
Definition: reaction_source_terms.h:711
double factor_rev_heat_ccl
This represents the fraction of reversible heat released corresponding to half-cell reaction of ORR...
Definition: reaction_source_terms.h:295
bool irrev_heat_acl
This boolean data member indicates that the ir-reversible heating due to HOR, inside the anode cataly...
Definition: reaction_source_terms.h:284
virtual void make_residual_indices()
This function fills out the max number of residual_indices which need to be updated due to the source...
unsigned int indexO2
Keeps oxygen set of fluid transport equations.
Definition: reaction_source_terms.h:654
double multiplierO2
Oxygen source multiplier, .
Definition: reaction_source_terms.h:673
This class assembles the reaction source terms for all other transport equations, if there&#39;s any...
Definition: reaction_source_terms.h:60
This class contains generic data and methods heavily used by all derived equation classes...
Definition: equation_base.h:199
bool water_vap_heat_ccl
This boolean data member indicates that the heat sink due to evaporation of water produced during the...
Definition: reaction_source_terms.h:307
std::vector< double > dheat_dphiM_cell
Derivative of heat produced w.r.t.
Definition: reaction_source_terms.h:507
std::vector< double > protonic_electrical_potential_old
Protonic electrical potential in the quadrature points of a cell at a previous Newton iteration...
Definition: reaction_source_terms.h:817
IMPORTANT: Add all new solution variables and equations here !
Definition: system_management.h:271
double active_area_cell
Active area [cm^2/cm^3] of the cell.
Definition: reaction_source_terms.h:532
This simple structure stores certain information regarding a particular variable for the equation (al...
Definition: equation_base.h:121
FuelCellShop::Kinetics::BaseKinetics * cathode_kinetics
Pointer to Cathode Kinetics object, initialized in the constructor.
Definition: reaction_source_terms.h:317
VariableInfo lambda
VariableInfo structure corresponding to &quot;membrane_water_content&quot;.
Definition: reaction_source_terms.h:366
bool get_irrev_heat_acl() const
Method to get whether the ir-reversible heating due to HOR, inside the anode catalyst layer is ON or ...
Definition: reaction_source_terms.h:159
virtual void assemble_matrix_for_equation(FuelCell::ApplicationCore::MatrixVector &cell_matrices, const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info, const std::string &eq_name, const FEValuesBase< dim > &test_fe, const std::vector< std::vector< double > > &test_shape_functions, const double &sourceterm_factor)
This function is specifically created for assembly of cell matrices for the following equations...
unsigned int indexH2O
Keeps water vapor set of fluid transport equations.
Definition: reaction_source_terms.h:664
double get_factor_rev_heat_ccl() const
Method to get the fraction of reversible heat released corresponding to half-cell reaction of ORR...
Definition: reaction_source_terms.h:177
void make_assemblers_cell_constant_data2(const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info)
As before but for fluid transport equations.
virtual void make_assemblers_cell_variable_data(const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
This function computes.
bool get_water_vap_heat_ccl() const
Method to get whether the heat sink due to evaoration of water produced during the ORR inside the ath...
Definition: reaction_source_terms.h:187
std::vector< std::vector< double > > phi_T_cell
shape functions.
Definition: reaction_source_terms.h:406
std::string eq_generic_prefix
For internal use only.
Definition: reaction_source_terms.h:858
VariableInfo t_rev
VariableInfo structure corresponding to &quot;temperature_of_REV&quot;.
Definition: reaction_source_terms.h:377
std::vector< double > DORR_current_density_Dprotonic_electrical_potential
ORR current density derivative with respect to protonic electrical potential in the quadrature points...
Definition: reaction_source_terms.h:757
std::vector< double > dheat_dxOxygen_cell
Derivative of heat produced w.r.t.
Definition: reaction_source_terms.h:519
VariableInfo phi_m
VariableInfo structure corresponding to &quot;protonic_electrical_potential&quot;.
Definition: reaction_source_terms.h:372
BlockVector< double > FEVector
The vector class used by applications.
Definition: application_data.h:39
std::vector< std::vector< double > > phi_phiM_cell
shape functions.
Definition: reaction_source_terms.h:433
void set_cathode_kinetics(FuelCellShop::Kinetics::BaseKinetics *kinetics)
Set the pointer to cathode kinetics in the object.
Definition: reaction_source_terms.h:91
std::vector< double > electronic_electrical_potential_old
Electronic electrical potential in the quadrature points of a cell at a previous Newton iteration...
Definition: reaction_source_terms.h:810
Virtual class used to characterize a generic layer interface.
Definition: base_layer.h:58
VariableInfo x_water
VariableInfo structure corresponding to &quot;water_molar_fraction&quot;.
Definition: reaction_source_terms.h:356
std::vector< std::vector< double > > phi_electronic_electrical_potential
Electronic electrical potential shape functions.
Definition: reaction_source_terms.h:840
This class is used to compute non-linear reaction heat source terms in a catalyst layer...
Definition: reaction_heat.h:94
ReactionSourceTerms(FuelCell::SystemManagement &system_management)
Constructor.
virtual void adjust_internal_cell_couplings(std::vector< couplings_map > &dst, const std::vector< FuelCellShop::Material::PureGas * > &gases=std::vector< FuelCellShop::Material::PureGas * >())
This function is used to adjust std::vector &lt; internal_cell_couplings &gt;, which is generated after get...
void set_anode_kinetics(FuelCellShop::Kinetics::BaseKinetics *kinetics)
Set the pointer to anode kinetics in the object.
Definition: reaction_source_terms.h:100
bool get_irrev_heat_ccl() const
Method to get whether the ir-reversible heating due to ORR, inside the cathode catalyst layer is ON o...
Definition: reaction_source_terms.h:150
std::vector< double > dheat_dxWater_cell
Derivative of heat produced w.r.t.
Definition: reaction_source_terms.h:525
virtual void make_matrix_block_indices()
This function fills out the max number of matrix_block_indices which need to be updated due to the so...
bool irrev_heat_ccl
This boolean data member indicates that the ir-reversible heating due to ORR, inside the cathode cata...
Definition: reaction_source_terms.h:278
std::vector< std::vector< double > > phi_phiS_cell
shape functions.
Definition: reaction_source_terms.h:424