OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
porous_layer.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: porous_layer.h
11 // - Description: Child of base layer that implements common functionality for handling gases.
12 // - Developers: M. Secanell and Madhur Bhaiya
13 // - $Id: porous_layer.h 1373 2013-08-21 00:34:53Z madhur $
14 //
15 //---------------------------------------------------------------------------
16 
17 #ifndef _FUELCELLSHOP__POROUS__LAYER_H
18 #define _FUELCELLSHOP__POROUS__LAYER_H
19 
20 // Include deal.II classes
21 #include <base/parameter_handler.h>
22 #include <base/point.h>
23 #include <base/function.h>
24 #include <lac/vector.h>
25 #include <fe/fe_values.h>
26 
27 //Include STL
28 #include "cmath"
29 #include "iostream"
30 #include "algorithm"
31 
32 // FCST
33 #include "base_layer.h"
34 #include "PureGas.h"
35 #include "BinaryDiffusion.h"
36 
37 using namespace dealii;
38 
39 namespace FuelCellShop
40 {
41  namespace Layer
42  {
56  template <int dim>
57  class PorousLayer
58  :
59  public BaseLayer<dim>
60  {
61  public:
62 
64 
65 
72  void set_gases_and_compute (std::vector<FuelCellShop::Material::PureGas*>& gases_in,
73  const double& pressure_in,
74  const double& temperature_in);
75 
82  void compute_gas_diffusion (FuelCellShop::Material::PureGas* solute_gas,
83  FuelCellShop::Material::PureGas* solvent_gas);
84 
94  inline void set_gases (std::vector<FuelCellShop::Material::PureGas*>& gases_in,
95  const double& pressure_in)
96  {
97  Assert(gases_in.size() >= 2, ExcMessage("Number of gases should be more than or equal to two in PorousLayer::set_gases method."));
98  this->gases = gases_in;
99  this->pressure = pressure_in;
100  }
101 
106  inline void set_temperature (const SolutionVariable& T_in)
107  {
108  Assert( T_in.get_variablename() == temperature_of_REV, ExcMessage("Wrong solution variable passed in PorousLayer::set_temperature.") );
109  this->T_vector = T_in;
110  }
111 
113 
115 
116 
120  FuelCellShop::Material::PureGas* get_gas_pointer(int index) const
121  {
122  Assert(index > 0 || index < gases.size(), ExcIndexRange(index,0,gases.size()));
123  return gases[index];
124  };
125 
130  std::vector<FuelCellShop::Material::PureGas*> get_gases() const
131  {
132  return this->gases;
133  }
134 
138  void get_gas_index(FuelCellShop::Material::PureGas* gas_type,
139  int& index) const;
143  void get_T_and_p(double &T, double &p) const
144  {
145  T = this->temperature;
146  p = this->pressure;
147  }
148 
152  void get_p(double& p) const
153  {
154  p = this->pressure;
155  }
156 
162  virtual void print_layer_properties() const
163  {
164  const std::type_info& info = typeid(*this);
165  deallog << "Pure function " << __FUNCTION__
166  << " called in Class "
167  << info.name() << std::endl;
168  };
169 
173  virtual bool test_layer() const;
174 
176 
177 
178 
179  protected:
181 
182 
185  PorousLayer(const std::string& name)
186  : FuelCellShop::Layer::BaseLayer<dim> (name)
187  {
188  this->derivative_flags.push_back(total_pressure);
189  this->derivative_flags.push_back(temperature_of_REV);
190  };
191 
198  : FuelCellShop::Layer::BaseLayer<dim> ()
199  {};
200 
204  virtual ~PorousLayer()
205  {};
209  virtual void declare_parameters (const std::string &name, ParameterHandler &param) const
210  {
212 
213  param.enter_subsection("Fuel cell data");
214  {
215  param.enter_subsection(name);
216  {
217 
218  }
219  param.leave_subsection();
220  }
221  param.leave_subsection();
222  }
223 
230  virtual void declare_parameters (ParameterHandler &param) const
231  {
232  declare_parameters(this->name, param);
233  };
234 
239  virtual void initialize (ParameterHandler &param);
240 
252  void set_parameters(const std::string &object_name,
253  const std::vector<std::string>& name_dvar,
254  const std::vector<double>& value_dvar,
255  ParameterHandler &param)
256  {
257  FuelCellShop::Layer::BaseLayer<dim>::set_parameters(object_name,name_dvar,value_dvar,param);
258 
259  param.enter_subsection("Fuel cell data");
260  {
261  param.enter_subsection(object_name);
262  {
263  // ADD VARIABLES IF NEEDED
264  //param.set(name_var, value_param);
265  }
266  param.leave_subsection();
267  }
268  param.leave_subsection();
269  };
270 
278  virtual void set_parameters(const std::vector<std::string>& name_dvar,
279  const std::vector<double>& value_dvar,
280  ParameterHandler &param)
281  {};
283 
284 
285 
291  virtual void gas_diffusion_coefficients(Table< 2, double > &) const;
292 
303  virtual void derivative_gas_diffusion_coefficients(std::vector< Table< 2, double > >&) const;
305 
306 
307 
311 
313  std::vector<FuelCellShop::Material::PureGas*> gases;
314 
316  double temperature;
317 
319  double pressure;
320 
323 
326  Table< 2, double > D_ECtheory;
327 
330  std::vector< Table< 2, double > > dD_ECtheory_dx;
331 
336  std::vector<double> D_bulk;
341  std::vector<double> dD_bulk_dT;
342 
344  };
345 
346  } // Layer
347 
348 } // FuelCellShop
349 
350 #endif // _FUELCELLSHOP__GENERIC__LAYER_H