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, Madhur Bhaiya and Valentin Zingan
13 // - $Id: porous_layer.h 2605 2014-08-15 03:36:44Z secanell $
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 #include <boost/concept_check.hpp>
32 
33 // FCST
34 #include "base_layer.h"
35 #include "PureGas.h"
36 #include "GasMixture.h"
37 #include "utils/fcst_constants.h"
38 using namespace dealii;
39 
40 namespace FuelCellShop
41 {
42 namespace Layer
43 {
44 
64  template<int dim>
65  class PorousLayer : public BaseLayer<dim>
66  {
67  public:
68 
70 
71 
81  void set_gases_and_compute (std::vector<FuelCellShop::Material::PureGas*>& gases_in,
82  const double& pressure_in,
83  const double& temperature_in);
84 
93  void compute_gas_diffusion (FuelCellShop::Material::PureGas* solute_gas,
94  FuelCellShop::Material::PureGas* solvent_gas);
95 
105  inline void set_gases (std::vector<FuelCellShop::Material::PureGas*>& gases_in,
106  const double& pressure_in)
107  {
108  Assert(gases_in.size() >= 2, ExcMessage("Number of gases should be more than or equal to two in PorousLayer::set_gases method."));
109  this->gases = gases_in;
110  this->pressure = pressure_in;
111 
112  gas_mixture = nullptr;
113  }
114 
119  {
120  gas_mixture = &rgas_mixture;
121  gases.clear();
122  }
123 
131  inline void set_porosity_permeability_tortuosity_booleans(const bool& rporosity_is_constant,
132  const bool& rpermeability_is_constant,
133  const bool& rtortuosity_is_constant)
134  {
135  porosity_is_constant = rporosity_is_constant;
136  permeability_is_constant = rpermeability_is_constant;
137  tortuosity_is_constant = rtortuosity_is_constant;
138  }
139 
144  inline void set_temperature (const SolutionVariable& T_in)
145  {
146  Assert( T_in.get_variablename() == temperature_of_REV, ExcMessage("Wrong solution variable passed in PorousLayer::set_temperature.") );
147  this->T_vector = T_in;
148  }
149 
154  inline void set_saturation (const SolutionVariable& s_in)
155  {
156  Assert( s_in.get_variablename() == liquid_water_saturation, ExcMessage("Wrong solution variable passed in PorousLayer::set_saturation.") );
157  this->s_vector = s_in;
158  }
159 
161 
163 
164 
170  {
171  Assert(index > 0 || index < gases.size(), ExcIndexRange(index,0,gases.size()));
172  return gases[index];
173  };
174 
179  std::vector<FuelCellShop::Material::PureGas*> get_gases() const
180  {
181  return this->gases;
182  }
183 
189  {
190  return this->gas_mixture;
191  }
192 
196  void get_gas_index(FuelCellShop::Material::PureGas* gas_type,
197  int& index) const;
198 
202  void get_T_and_p(double &T, double &p) const
203  {
204  T = this->temperature;
205  p = this->pressure;
206  }
207 
211  void get_p(double& p) const
212  {
213  p = this->pressure;
214 
215  }
216 
221  const bool& get_porosity_is_constant() const
222  {
223  return porosity_is_constant;
224  }
225 
230  const bool& get_permeability_is_constant() const
231  {
232  return permeability_is_constant;
233  }
234 
239  const bool& get_tortuosity_is_constant() const
240  {
241  return tortuosity_is_constant;
242  }
243 
248  inline double get_porosity() const
249  {
250  AssertThrow( porosity_is_constant , ExcInternalError() );
251  return porosity;
252  }
253 
258  inline void get_porosity(std::vector<double>& dst) const
259  {
260  AssertThrow( porosity_is_constant , ExcInternalError() );
261 
262  for(unsigned int q = 0; q < dst.size(); ++q)
263  dst[q] = this->get_porosity();
264  }
265 
270  void get_porosity(std::vector<double>& dst,
271  const std::vector< Point<dim> >& points) const;
272 
277  void get_permeability(std::vector< SymmetricTensor<2,dim> >& dst) const;
278 
283  void get_permeability(std::vector< SymmetricTensor<2,dim> >& dst,
284  const std::vector< Point<dim> >& points) const;
285 
290  void get_SQRT_permeability(std::vector< SymmetricTensor<2,dim> >& dst) const;
291 
296  void get_SQRT_permeability(std::vector< SymmetricTensor<2,dim> >& dst,
297  const std::vector< Point<dim> >& points) const;
298 
303  void get_permeability_INV(std::vector< SymmetricTensor<2,dim> >& dst) const;
304 
309  void get_permeability_INV(std::vector< SymmetricTensor<2,dim> >& dst,
310  const std::vector< Point<dim> >& points) const;
311 
316  void get_SQRT_permeability_INV(std::vector< SymmetricTensor<2,dim> >& dst) const;
317 
322  void get_SQRT_permeability_INV(std::vector< SymmetricTensor<2,dim> >& dst,
323  const std::vector< Point<dim> >& points) const;
324 
329  void get_Forchheimer_permeability(std::vector< SymmetricTensor<2,dim> >& dst) const;
330 
335  void get_Forchheimer_permeability(std::vector< SymmetricTensor<2,dim> >& dst,
336  const std::vector< Point<dim> >& points) const;
337 
342  void get_tortuosity(std::vector< SymmetricTensor<2,dim> >& dst) const;
343 
348  void get_tortuosity(std::vector< SymmetricTensor<2,dim> >& dst,
349  const std::vector< Point<dim> >& points) const;
350 
356  virtual void print_layer_properties() const;
357 
359 
361 
362 
394  void effective_gas_diffusion_coefficient(const FuelCellShop::Material::PureGas* solute_gas,
395  const FuelCellShop::Material::PureGas* solvent_gas,
396  const SolutionVariable& T_in,
397  const SolutionVariable& p_in,
398  std::vector<double>& D_b) const;
417  void effective_gas_diffusion_coefficient(const FuelCellShop::Material::PureGas* solute_gas,
418  const FuelCellShop::Material::PureGas* solvent_gas,
419  const SolutionVariable& T_in,
420  const SolutionVariable& p_in,
421  std::vector<double>& D_b,
422  std::vector<double>& dD_b_dT) const;
429  void effective_molecular_gas_diffusion_coefficient(const FuelCellShop::Material::PureGas* solute_gas,
430  const FuelCellShop::Material::PureGas* solvent_gas,
431  const SolutionVariable& T_in,
432  const SolutionVariable& p_in,
433  std::vector<double>& D_m) const;
434 
441  void effective_molecular_gas_diffusion_coefficient(const FuelCellShop::Material::PureGas* solute_gas,
442  const FuelCellShop::Material::PureGas* solvent_gas,
443  const SolutionVariable& T_in,
444  const SolutionVariable& p_in,
445  std::vector<double>& D_m,
446  std::vector<double>& dD_m_dT) const;
447 
453  void Knudsen_diffusion(const FuelCellShop::Material::PureGas* solute_gas,
454  const SolutionVariable& T_in,
455  std::vector<double>& D_k) const;
456 
462  void Knudsen_diffusion(const FuelCellShop::Material::PureGas* solute_gas,
463  const SolutionVariable& T_in,
464  std::vector<double>& D_k,
465  std::vector<double>& dD_k_dT) const;
466 
470  virtual void pcapillary(std::vector<double>&) const
471  {
472  const std::type_info& info = typeid(*this);
473  FcstUtilities::log << "Calling parent porous layer"<< std::endl;
474  }
476  protected:
477 
479 
480 
484  PorousLayer(const std::string& name)
485  :
486  FuelCellShop::Layer::BaseLayer<dim>(name)
487  {
488  this->derivative_flags.push_back(total_pressure);
489  this->derivative_flags.push_back(temperature_of_REV);
490  porosity_is_constant = true;
491  permeability_is_constant = true;
492  tortuosity_is_constant = true;
493  gases.clear();
494  gas_mixture = nullptr;
495  }
496 
503  :
504  FuelCellShop::Layer::BaseLayer<dim>()
505  {}
506 
510  PorousLayer(const std::string& name,
512  :
513  FuelCellShop::Layer::BaseLayer<dim>(name),
514  gas_mixture(&gas_mixture)
515  {
516  this->derivative_flags.push_back(total_pressure);
517  this->derivative_flags.push_back(temperature_of_REV);
518  porosity_is_constant = true;
519  permeability_is_constant = true;
520  tortuosity_is_constant = true;
521  gases.clear();
522  }
523 
527  virtual ~PorousLayer()
528  {}
529 
533  virtual void declare_parameters (const std::string &name, ParameterHandler &param) const;
534 
541  virtual void declare_parameters (ParameterHandler &param) const
542  {
543  declare_parameters(this->name, param);
544  }
545 
550  virtual void initialize (ParameterHandler &param);
552 
554 
555 
562  void print_caller_name(const std::string& caller_name) const;
563 
565 
567 
573  virtual void gas_diffusion_coefficients(Table< 2, double > &) const;
574 
585  virtual void derivative_gas_diffusion_coefficients(std::vector< Table< 2, double > >&) const;
586 
588 
590  // DATA //
592 
594 
595 
600 
605  std::vector<FuelCellShop::Material::PureGas*> gases;
606 
612 
618 
624 
628  double porosity;
629 
634 
638  SymmetricTensor<2,dim> permeability;
639 
643  SymmetricTensor<2,dim> SQRT_permeability;
644 
648  SymmetricTensor<2,dim> permeability_INV;
649 
653  SymmetricTensor<2,dim> SQRT_permeability_INV;
654 
658  SymmetricTensor<2,dim> Forchheimer_permeability;
659 
663  SymmetricTensor<2,dim> tortuosity;
664 
670 
675  double temperature;
676 
681  double pressure;
682 
685 
688 
691  Table< 2, double > D_ECtheory;
692 
695  std::vector< Table< 2, double > > dD_ECtheory_dx;
696 
701  std::vector<double> D_bulk;
702 
707  std::vector<double> dD_bulk_dT;
708 
710 
711 };
712 
713 } // Layer
714 
715 } // FuelCellShop
716 
717 #endif
SymmetricTensor< 2, dim > permeability_INV
Inverse of user defined constant permeability, 1/m^2.
Definition: porous_layer.h:648
const unsigned int dim
Definition: fcst_constants.h:24
SymmetricTensor< 2, dim > Forchheimer_permeability
User defined constant Forchheimer permeability, 1/m.
Definition: porous_layer.h:658
bool tortuosity_is_constant
Variable defining if the tortuosity is constant.
Definition: porous_layer.h:623
void set_gases(std::vector< FuelCellShop::Material::PureGas * > &gases_in, const double &pressure_in)
Member function used to store all the gases that are in the pore space in the porous layer...
Definition: porous_layer.h:105
std::vector< FuelCellShop::Material::PureGas * > gases
Gases inside a porous layer.
Definition: porous_layer.h:605
SolutionVariable s_vector
Liquid water saturation at every quadrature point inside the cell.
Definition: porous_layer.h:687
VariableNames get_variablename() const
Function to get the VariableNames enumeration corresponding to this struct.
Definition: fcst_variables.h:163
SolutionVariable T_vector
Temperature at every quadrature point inside the cell.
Definition: porous_layer.h:684
std::vector< double > dD_bulk_dT
Vector of derivative of bulk diffusion coefficients w.r.t temperature, at every quadrature point insi...
Definition: porous_layer.h:707
SymmetricTensor< 2, dim > SQRT_permeability_INV
Inverse of square root of user defined constant permeability, 1/m.
Definition: porous_layer.h:653
const FuelCellShop::Material::GasMixture *const get_gas_mixture() const
This function returns gas_mixture.
Definition: porous_layer.h:188
void get_p(double &p) const
Return the constant pressure [atm] inside the layer.
Definition: porous_layer.h:211
void set_saturation(const SolutionVariable &s_in)
Member function used to set the liquid water saturation at every quadrature point inside the cell...
Definition: porous_layer.h:154
This structure is used to encapsulate data from constant values and variable solution data that is us...
Definition: fcst_variables.h:86
SymmetricTensor< 2, dim > permeability
User defined constant permeability, m^2.
Definition: porous_layer.h:638
Table< 2, double > D_ECtheory
Tensor of diffusion coefficients – This are computed with setting up the gas so that they do not need...
Definition: porous_layer.h:691
PorousLayer(const std::string &name)
Constructor.
Definition: porous_layer.h:484
void get_porosity(std::vector< double > &dst) const
This function computes constant porosity in quadrature points of a mesh entity.
Definition: porous_layer.h:258
void set_temperature(const SolutionVariable &T_in)
Member function used to set the temperature [Kelvin] at every quadrature point inside the cell...
Definition: porous_layer.h:144
bool porosity_is_constant
Variable defining if the porosity is constant.
Definition: porous_layer.h:611
std::vector< Table< 2, double > > dD_ECtheory_dx
Vector of tensors for the derivative of the diffusion coefficients – This are computed with setting u...
Definition: porous_layer.h:695
Definition: system_management.h:75
double get_porosity() const
This function computes constant porosity in quadrature points of a mesh entity.
Definition: porous_layer.h:248
virtual ~PorousLayer()
Destructor.
Definition: porous_layer.h:527
virtual void declare_parameters(ParameterHandler &param) const
Declare parameters for a parameter file.
Definition: porous_layer.h:541
PorousLayer()
Constructor.
Definition: porous_layer.h:502
std::vector< double > D_bulk
Vector of bulk diffusion coefficients at every quadrature point inside the cell.
Definition: porous_layer.h:701
void set_porosity_permeability_tortuosity_booleans(const bool &rporosity_is_constant, const bool &rpermeability_is_constant, const bool &rtortuosity_is_constant)
Set.
Definition: porous_layer.h:131
void set_gas_mixture(FuelCellShop::Material::GasMixture &rgas_mixture)
Set gas_mixture.
Definition: porous_layer.h:118
double pressure
Total pressure [atm] used to compute gas diffusivity.
Definition: porous_layer.h:681
Definition: system_management.h:76
FCSTLogStream log
Object used to output data to file and, if file attached recorded to a file as well.
FuelCellShop::Material::PureGas * get_gas_pointer(int index) const
Return the FuelCellShop::Material::PureGas pointer that is stored inside the class in the ith positio...
Definition: porous_layer.h:169
const bool & get_porosity_is_constant() const
This function returns porosity_is_constant.
Definition: porous_layer.h:221
const bool & get_permeability_is_constant() const
This function returns permeability_is_constant.
Definition: porous_layer.h:230
SymmetricTensor< 2, dim > SQRT_permeability
Square root of user defined constant permeability, m.
Definition: porous_layer.h:643
This class describes properties of gas mixtures.
Definition: GasMixture.h:115
This class is a base class for all pure gases used in FCST.
Definition: PureGas.h:89
Definition: system_management.h:91
void get_T_and_p(double &T, double &p) const
Return the constant temperature [Kelvin] and constant pressure [atm] inside the layer.
Definition: porous_layer.h:202
std::string diffusion_species_name
If GDL properties are stored inside the class (e.g DummyGDL) then, return the property stored under c...
Definition: porous_layer.h:669
const bool & get_tortuosity_is_constant() const
This function returns tortuosity_is_constant.
Definition: porous_layer.h:239
double Knudsen_radius
Parameter used to define Knudsen pore radius.
Definition: porous_layer.h:633
double porosity
User defined constant porosity.
Definition: porous_layer.h:628
SymmetricTensor< 2, dim > tortuosity
User defined constant tortuosity.
Definition: porous_layer.h:663
Virtual class used to implement properties that are characteristic of a porous layer.
Definition: porous_layer.h:65
double temperature
Temperature [K] used to compute gas diffusivity.
Definition: porous_layer.h:675
Virtual class used to characterize a generic layer interface.
Definition: base_layer.h:58
FuelCellShop::Material::GasMixture * gas_mixture
Gas mixture.
Definition: porous_layer.h:599
std::vector< FuelCellShop::Material::PureGas * > get_gases() const
Returns the vector of FuelCellShop::Material::PureGas pointers stored in the porous layer...
Definition: porous_layer.h:179
bool permeability_is_constant
Variable defining if the permeability is constant.
Definition: porous_layer.h:617
PorousLayer(const std::string &name, FuelCellShop::Material::GasMixture &gas_mixture)
Constructor.
Definition: porous_layer.h:510
virtual void pcapillary(std::vector< double > &) const
Compute , at all quadrature points in the cell.
Definition: porous_layer.h:470