OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
response_water_sorption.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2014 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: response_water_sorption.h
11 // - Description: This file defines response class computing amount of water sorbed in the catalyst layers.
12 // - Developers: Marc Secanell Gallart and Madhur Bhaiya
13 // - $Id:
14 //
15 // ----------------------------------------------------------------------------
16 
17 #ifndef _FUELCELLSHOP__RESPONSE_WATER_SORPTION_H
18 #define _FUELCELLSHOP__RESPONSE_WATER_SORPTION_H
19 
20 //Include STL
21 #include <exception> // std::exception
22 
23 // Include OpenFCST routines:
25 #include <layers/catalyst_layer.h>
27 
28 using namespace dealii;
29 
30 namespace FuelCellShop
31 {
32 
33  namespace PostProcessing
34  {
35 
105  template <int dim>
107  {
108  public:
110 
113  :
114  BaseResponse<dim>(sm),
115  sorption_source(sst)
116  {}
117 
119 
123  void initialize(ParameterHandler& param)
124  {
125  if ( this->system_management->solution_in_userlist("membrane_water_content") )
126  {
127  lambda.solution_index = this->system_management->solution_name_to_index("membrane_water_content");
128  lambda.fetype_index = this->system_management->block_info->base_element[lambda.solution_index];
129  lambda.indices_exist = true;
130  }
131  else
132  throw std::runtime_error("membrane_water_content variable required for WaterSorptionResponse");
133 
134  if ( this->system_management->solution_in_userlist("water_molar_fraction") )
135  {
136  x_w.solution_index = this->system_management->solution_name_to_index("water_molar_fraction");
137  x_w.fetype_index = this->system_management->block_info->base_element[x_w.solution_index];
138  x_w.indices_exist = true;
139  }
140  else
141  throw std::runtime_error("water_molar_fraction variable required for WaterSorptionResponse");
142 
143  if ( this->system_management->solution_in_userlist("temperature_of_REV") )
144  {
145  tRev.solution_index = this->system_management->solution_name_to_index("temperature_of_REV");
146  tRev.fetype_index = this->system_management->block_info->base_element[tRev.solution_index];
147  tRev.indices_exist = true;
148  }
149 
150  time_k = sorption_source->get_time_constant();
151  }
153 
155 
156 
172  std::map<FuelCellShop::PostProcessing::ResponsesNames, double>& respMap) const
173  {
174  respMap.clear();
175 
176  // Make sure you are in a CL
177  const std::type_info& base_layer = layer->get_base_type();
178  const std::type_info& CatalystLayer = typeid(FuelCellShop::Layer::CatalystLayer<dim>);
179  AssertThrow(base_layer == CatalystLayer,
180  ExcMessage("WaterSorptionResponse can only be used with a CatalystLayer object"));
181 
182  // Get number of quadrature points in the cell:
183  unsigned int n_q_points_cell = (info.fe(lambda.fetype_index)).n_quadrature_points;
184 
185  // Find where the solution is stored in info:
186  unsigned int solIndex = info.global_data->find_vector("Solution");
187 
188  // Create CL:
190 
191  double rhoDry = catalyst_layer->get_electrolyte()->get_density();
192  double EW = catalyst_layer->get_electrolyte()->get_EW();
193  catalyst_layer->get_electrolyte()->set_water_molar_fraction( FuelCellShop::SolutionVariable(&info.values[solIndex][x_w.solution_index], water_molar_fraction) );
194  if (tRev.indices_exist)
195  catalyst_layer->get_electrolyte()->set_temperature( FuelCellShop::SolutionVariable(&info.values[solIndex][tRev.solution_index], temperature_of_REV) );
196 
197  std::vector<double> lambdaValue( info.values[solIndex][lambda.solution_index] );
198 
199  std::vector<double> lambdaEq(n_q_points_cell, 0.0);
200  catalyst_layer->get_electrolyte()->sorption_isotherm(lambdaEq);
201 
202  for (unsigned int q = 0; q < n_q_points_cell; ++q){
203  double JxW = info.fe(lambda.fetype_index).JxW(q);
204  respMap[FuelCellShop::PostProcessing::ResponsesNames::sorbed_water] += ( ( ((time_k*rhoDry)/EW)*(lambdaEq[q] - lambdaValue[q]) ) * JxW );
205  }
206  }
212  void compute_responses(std::vector< FuelCellShop::SolutionVariable > solution_variables,
213  const typename DoFApplication<dim>::CellInfo& info,
215  std::map<FuelCellShop::PostProcessing::ResponsesNames, double>& resp) const
216  {
217  throw std::runtime_error("WaterSorptionResponse::compute_responses(solution_variables, info, layer, resp) not implemented");
218  }
219  //
220  private:
225 
230  double time_k;
231 
237 
243 
249  };
250 
251  }
252 }
253 
254 #endif
WaterSorptionResponse(const FuelCell::SystemManagement &sm, const FuelCellShop::Equation::SorptionSourceTerms< dim > *sst)
Definition: response_water_sorption.h:111
const unsigned int dim
Definition: fcst_constants.h:23
This class assembles source terms corresponding to sorption/desorption of water inside the catalyst l...
Definition: sorption_source_terms.h:101
double get_EW() const
Get Equivalent Weight (grams of dry polymer electrolyte per moles of ) of the polymer electrolyte mat...
Definition: polymer_electrolyte_material_base.h:445
FuelCellShop::Equation::VariableInfo x_w
VariableInfo structure corresponding to the &quot;water_molar_fraction&quot;.
Definition: response_water_sorption.h:242
SmartPointer< const FEVectors > global_data
The smart pointer to the FEVectors object called global_data.
Definition: mesh_loop_info_objects.h:674
This structure is used to encapsulate data from constant values and variable solution data that is us...
Definition: fcst_variables.h:86
void set_water_molar_fraction(const FuelCellShop::SolutionVariable &x_in)
Set the solution variable, water vapor molar fraction .
Definition: polymer_electrolyte_material_base.h:523
Virtual class used to develop a common interface to a set of functions used to evaluate functionals t...
Definition: base_response.h:131
virtual void sorption_isotherm(std::vector< double > &) const
Compute the equilibrium water content, , inside the polymer electrolyte for vapor-equilibriated case...
Definition: polymer_electrolyte_material_base.h:139
Definition: system_management.h:76
double get_density() const
Get the density [gm/cm^3] of the dry polymer electrolyte material.
Definition: polymer_electrolyte_material_base.h:427
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
void initialize(ParameterHandler &param)
Initialize class parameters.
Definition: response_water_sorption.h:123
virtual const std::type_info & get_base_type() const
This member function return the name of the type of layer, i.e.
Definition: base_layer.h:177
void compute_responses(const typename DoFApplication< dim >::CellInfo &info, FuelCellShop::Layer::BaseLayer< dim > *const layer, std::map< FuelCellShop::PostProcessing::ResponsesNames, double > &respMap) const
This member function computes the water adsorbed/desorbed from the electrolyte in the catalyst layer...
Definition: response_water_sorption.h:170
virtual FuelCellShop::Material::PolymerElectrolyteBase * get_electrolyte() const
Method to provide access to pointer of the electrolyte object of the catalyst layer.
Definition: catalyst_layer.h:898
Definition: system_management.h:68
void compute_responses(std::vector< FuelCellShop::SolutionVariable > solution_variables, const typename DoFApplication< dim >::CellInfo &info, FuelCellShop::Layer::BaseLayer< dim > *const layer, std::map< FuelCellShop::PostProcessing::ResponsesNames, double > &resp) const
Routine used in order to compute the response with a modified solution (not the one stored in info) ...
Definition: response_water_sorption.h:212
double time_k
Rate of sorption/desorption.
Definition: response_water_sorption.h:230
const FuelCellShop::Equation::SorptionSourceTerms< dim > * sorption_source
Pointer to SorptionSourceTerms object.
Definition: response_water_sorption.h:224
Definition: base_response.h:61
~WaterSorptionResponse()
Definition: response_water_sorption.h:118
IMPORTANT: Add all new solution variables and equations here !
Definition: system_management.h:300
This simple structure stores certain information regarding a particular variable for the equation (al...
Definition: equation_auxiliaries.h:51
FuelCellShop::Equation::VariableInfo lambda
VariableInfo structure corresponding to the &quot;membrane_water_content&quot;.
Definition: response_water_sorption.h:236
std::vector< std::vector< std::vector< double > > > values
The vector containing the values of finite element functions in the quadrature points.
Definition: mesh_loop_info_objects.h:682
void set_temperature(const FuelCellShop::SolutionVariable &T_in)
Set the solution variable, temperature [Kelvin].
Definition: polymer_electrolyte_material_base.h:506
Virtual class used to characterize a generic layer interface.
Definition: base_layer.h:58
FuelCellShop::Equation::VariableInfo tRev
VariableInfo structure corresponding to the &quot;temperature_of_REV&quot;.
Definition: response_water_sorption.h:248
const FEVALUESBASE & fe() const
Access to a single actual FEVALUES object.
Definition: mesh_loop_info_objects.h:990
Virtual class used to provide the interface for all CatalystLayer children.
Definition: catalyst_layer.h:124