OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
liquid_water_source_terms.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 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: liquid_water_source_terms.h
11 // - Description: Equation class for liquid water source terms
12 // - Developers: Jie Zhou, Marc Secanell
13 //
14 //---------------------------------------------------------------------------
15 
16 #ifndef _FCST_FUELCELLSHOP_EQUATION_LIQUID_SOURCE_TERMS_EQUATION_H_
17 #define _FCST_FUELCELLSHOP_EQUATION_LIQUID_SOURCE_TERMS_EQUATION_H_
18 
19 // FCST includes
20 #include "utils/fcst_constants.h"
21 #include "utils/fcst_utilities.h"
22 #include "utils/fcst_units.h"
23 #include "materials/PureLiquid.h"
24 
26 
29 #include "layers/catalyst_layer.h"
30 #include "PSD_base.h"
31 // STD
32 #include <sstream>
33 #include <string>
34 
35 namespace FuelCellShop
36 {
37  namespace Equation
38  {
121  template<int dim>
122  class LiquidSourceEquation : public EquationBase<dim>
123  {
124  public:
125 
127 
128 
132  LiquidSourceEquation(FuelCell::SystemManagement& system_management,boost::shared_ptr< FuelCell::ApplicationCore::ApplicationData > data =
133  boost::shared_ptr< FuelCell::ApplicationCore::ApplicationData >());
134 
138  virtual ~LiquidSourceEquation();
139 
143  virtual void declare_parameters(ParameterHandler& param) const;
144 
148  virtual void initialize(ParameterHandler& param);
149 
151 
153 
154 
160 
167 
169 
171 
172 
177  virtual void print_equation_info() const;
178 
182  double get_kevap() const
183  {
184  return k_e;
185  }
186 
190  double get_kcond() const
191  {
192  return k_c;
193  }
194 
198  void set_relative_humility(double const x_wv)
199  {
200  this->Relative_humility = x_wv;
202  }
203 
212  virtual void adjust_internal_cell_couplings(std::vector< couplings_map >& ) const;
213 
215 
216  protected:
221  inline void get_temp_related_parameters(double Temp,double c_pressure,double &psat,double &dpsat_dT,
222  double &h_lv,double &dhlv_dT,double &Kelvin_factor,
223  double &psat_kelvin, double &dpsat_kelvin_dpc, double &dpsat_kelvin_dT,
225  {
226  psat = water.get_water_vapor_saturation_pressure(Temp); // saturation pressure [Pa]
227  dpsat_dT = water.get_Dwater_vapor_saturation_pressure_Dtemperature(Temp); // derivative of saturation pressure w.r.t temperature
228  h_lv = FuelCellShop::Material::LiquidWater::latentVap_heat(Temp); // latent heat of vaporization [J/mol]
229  dhlv_dT = FuelCellShop::Material::LiquidWater::deriv_latentVap_heat(Temp); // derivative of latent heat w.r.t temperature
230  Kelvin_factor = std::exp(c_pressure * M_water * Units::convert(1, Units::PER_C_UNIT3, Units::PER_UNIT2) / (Constants::R() * rho_l * Temp ) );
231 
232  psat_kelvin = psat * Kelvin_factor;
233  dpsat_kelvin_dpc = psat * (M_water * Units::convert(1, Units::PER_C_UNIT3, Units::PER_UNIT2) / (Constants::R() * rho_l * Temp )) * Kelvin_factor;
234  dpsat_kelvin_dT = dpsat_dT * Kelvin_factor
235  + psat * (-1.0 * (c_pressure * M_water * Units::convert(1, Units::PER_C_UNIT3, Units::PER_UNIT2) / (Constants::R() * rho_l) ) / std::pow(Temp,2.0)) * Kelvin_factor;
236  }
237 
239 
240 
246 
256 
263 
265 
267 
268 
272  virtual void make_boundary_types(){};
273 
278  virtual void make_output_types(){};
280 
282 
283 
284  std::map<unsigned int, double> capillary_pressure_current_flux_map;
285 
290 
295 
300 
305 
310 
315 
320 
325 
330 
334  double M_water;
335 
339  double k_e;
343  double k_c;
347  double rho_l;
348 
350 
352 
353 
357  double p_cell;
358 
362  std::vector<double> area_lv_cell;
363 
367  std::vector<double> darea_lv_dp_cell;
368 
376  std::vector< std::vector<double> > phi_p_cell;
377 
385  std::vector< std::vector<double> > phi_xwater_cell;
386 
394  std::vector< std::vector<double> > phi_T_cell;
395 
397 
403 
408  unsigned int last_iter_cell;
409 
413  double T_constant;
414 
419 
424 
425  };
426  } // Equation
427 } // FuelCellShop
428 
429 #endif
VariableInfo x_water
VariableInfo structure corresponding to &quot;water_molar_fraction&quot;.
Definition: liquid_water_source_terms.h:294
boost::shared_ptr< FuelCell::ApplicationCore::ApplicationData > data
Data object for the application data to be passed to the equation classes.
Definition: equation_base.h:890
std::vector< std::vector< double > > phi_T_cell
shape functions.
Definition: liquid_water_source_terms.h:394
std::map< unsigned int, double > capillary_pressure_current_flux_map
Definition: liquid_water_source_terms.h:284
This class implements a liquid water condensation and evaporation term.
Definition: liquid_water_source_terms.h:122
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: liquid_water_source_terms.h:408
double k_e
Evaporation rate constant, .
Definition: liquid_water_source_terms.h:339
unsigned int thermal_blockindex_trev
Block index for &quot;temperature_of_REV&quot; corresponding to &quot;Thermal Transport Equation&quot;.
Definition: liquid_water_source_terms.h:329
bool Relative_humility_is_set
This is used to check if relative humility is set when not solving water vapor as the solution variab...
Definition: liquid_water_source_terms.h:423
void set_relative_humility(double const x_wv)
Set the relative humility value from the operating condition class (using get_x_wv) ...
Definition: liquid_water_source_terms.h:198
FuelCell::SystemManagement * system_management
Pointer to the external YourApplication&lt;dim&gt;::system_management object.
Definition: equation_base.h:798
double k_c
Condensation rate constant, .
Definition: liquid_water_source_terms.h:343
double Relative_humility
This is used to return relative humility the when not solving water vapor as the solution variable...
Definition: liquid_water_source_terms.h:418
virtual void make_output_types()
This function fills out output_types.
Definition: liquid_water_source_terms.h:278
double rho_l
Density of liquid water, .
Definition: liquid_water_source_terms.h:347
static double PER_C_UNIT3
Definition: fcst_units.h:118
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 Local CG FEM based assemblers - variable data (cell) .
virtual void make_boundary_types()
This function fills out boundary_types.
Definition: liquid_water_source_terms.h:272
unsigned int fickswater_blockindex_xwater
Block index for &quot;water_molar_fraction&quot; corresponding to &quot;Ficks Transport Equation - water&quot;...
Definition: liquid_water_source_terms.h:304
std::vector< double > darea_lv_dp_cell
, at all quadrature points in the cell.
Definition: liquid_water_source_terms.h:367
double R()
Universal gas constant, .
Definition: fcst_constants.h:32
static double latentVap_heat(const double &)
Static function to return latent heat of vaporization of water as a function of input temperature ...
This class is created for the objects handed to the mesh loops.
Definition: mesh_loop_info_objects.h:544
virtual void print_equation_info() const
The function prints out the equation&#39;s info about the internal coupling equations with the liquid wat...
const double get_Dwater_vapor_saturation_pressure_Dtemperature(const double &temperature) const
This function returns the first derivative of the saturation pressure of water vapor.
virtual void make_assemblers_cell_constant_data(const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info)
This function computes Local CG FEM based assemblers - constant data (cell) and allocates the memor...
std::vector< MatrixBlock< FullMatrix< double > > > MatrixVector
The matrix vector used in the mesh loops.
Definition: matrix_block.h:102
unsigned int thermal_blockindex_xwater
Block index for &quot;water_molar_fraction&quot; corresponding to &quot;Thermal Transport Equation&quot;.
Definition: liquid_water_source_terms.h:319
LiquidSourceEquation(FuelCell::SystemManagement &system_management, boost::shared_ptr< FuelCell::ApplicationCore::ApplicationData > data=boost::shared_ptr< FuelCell::ApplicationCore::ApplicationData >())
Constructor.
double p_cell
Total pressure in the cell.
Definition: liquid_water_source_terms.h:357
std::vector< double > area_lv_cell
Interfacial surface area per unit volume, , at all quadrature points in the cell. ...
Definition: liquid_water_source_terms.h:362
VariableInfo t_rev
VariableInfo structure corresponding to &quot;temperature_of_REV&quot;.
Definition: liquid_water_source_terms.h:299
std::vector< std::vector< double > > phi_xwater_cell
shape functions.
Definition: liquid_water_source_terms.h:385
static double deriv_latentVap_heat(const double &)
Static function to return derivative of latent heat of vaporization of water with respect to temperat...
double T_constant
This tempearture is used when not solving temperature as the solution variable.
Definition: liquid_water_source_terms.h:413
virtual void initialize(ParameterHandler &param)
Initialize parameters.
void get_temp_related_parameters(double Temp, double c_pressure, double &psat, double &dpsat_dT, double &h_lv, double &dhlv_dT, double &Kelvin_factor, double &psat_kelvin, double &dpsat_kelvin_dpc, double &dpsat_kelvin_dT, FuelCellShop::Material::WaterVapor water) const
Inline function to reduce the repeatability of the code This function is used to compute Kelvin satur...
Definition: liquid_water_source_terms.h:221
VariableInfo p_liquid_water
VariableInfo structure corresponding to &quot;liquid_capillary_pressure&quot;.
Definition: liquid_water_source_terms.h:289
bool cell_residual_counter
Counter set to TRUE when cell_residual is being assembled.
Definition: liquid_water_source_terms.h:402
virtual void declare_parameters(ParameterHandler &param) const
Declare parameters.
virtual void adjust_internal_cell_couplings(std::vector< couplings_map > &) const
This function is used to adjust std::vector &lt; internal_cell_couplings &gt;, which is generated after get...
const double get_water_vapor_saturation_pressure(const double &temperature) const
This function returns saturation pressure [Pa] of water vapor.
double get_kcond() const
Returns condensation rate constant, .
Definition: liquid_water_source_terms.h:190
This is the base class used for all Equation classes.
Definition: equation_base.h:160
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
unsigned int fickswater_blockindex_pliquid
Block index for &quot;liquid_capillary_pressure&quot; corresponding to &quot;Ficks Transport Equation - water&quot;...
Definition: liquid_water_source_terms.h:309
double get_kevap() const
Returns evaporation rate constant, .
Definition: liquid_water_source_terms.h:182
virtual void make_assemblers_generic_constant_data()
This function computes Local CG FEM based assemblers - constant data (generic).
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.
double M_water
Molar weight of water in grams/mole.
Definition: liquid_water_source_terms.h:334
static double PER_UNIT2
Definition: fcst_units.h:110
unsigned int fickswater_blockindex_trev
Block index for &quot;temperature_of_REV&quot; corresponding to &quot;Ficks Transport Equation - water&quot;...
Definition: liquid_water_source_terms.h:314
BlockVector< double > FEVector
The vector class used by applications.
Definition: application_data.h:46
virtual void assemble_cell_residual(FuelCell::ApplicationCore::FEVector &cell_rhs, const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
Assemble local cell residual.
Virtual class used to characterize a generic layer interface.
Definition: base_layer.h:58
std::vector< std::vector< double > > phi_p_cell
shape functions.
Definition: liquid_water_source_terms.h:376
unsigned int thermal_blockindex_pliquid
Block index for &quot;liquid_capillary_pressure&quot; corresponding to &quot;Thermal Transport Equation&quot;.
Definition: liquid_water_source_terms.h:324
static double convert(double unitToConvert, double to, double from)
The conversion routine convert(unitToConvert, X, Y) should be read as:
Definition: fcst_units.h:57
This class describes properties of pure WaterVapor.
Definition: PureGas.h:1134