OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
operating_conditions.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 // $Id: operating_conditions.h 2605 2014-08-15 03:36:44Z secanell $
3 //
4 // Copyright (C) 2009 by Marc Secanell
5 //
6 // This file is subject to QPL and may not be distributed
7 // without copyright and license information. Please refer
8 // to the file deal.II/doc/license.html for the text and
9 // further information on this license.
10 //
11 //---------------------------------------------------------------------------
12 
13 #ifndef _FUELCELL_OPERATING_CONDITIONS__H
14 #define _FUELCELL_OPERATING_CONDITIONS__H
15 
16 // Include deal.II classes
17 #include <deal.II/base/parameter_handler.h>
18 
19 
20 #include <boost/lexical_cast.hpp>
21 
22 #include <utils/logging.h>
23 #include <utils/fcst_constants.h>
25 #include <grid/geometry.h>
26 #include <materials/PureGas.h>
27 #include <materials/GasMixture.h>
28 #include <utils/fcst_units.h>
29 
30 using namespace dealii;
31 
32 namespace FuelCell
33 {
34 
119  {
120  public:
125 
130 
154  void declare_parameters (ParameterHandler &param) const;
155 
160  void initialize (ParameterHandler& param);
161 
168  {
169  c_mix.set_total_pressure(get_pc_Pa());
170  c_mix.set_temperature(get_T());
171 
172  cathode_mix = &c_mix;
173 
174  a_mix.set_total_pressure(get_pa_Pa());
175  a_mix.set_temperature(get_T());
176 
177  anode_mix = &a_mix;
178  }
179 
183  std::vector<double> get_rho_anode() const;
184 
188  std::vector<double> get_rho_cathode() const;
189 
190 
194  double saturation_pressure() const;
195 
199  double get_x_wv(int) const;
200 
204  double get_x_wv() const;
205 
209  double get_x_wv_anode() const;
210 
214  double get_x_o2() const;
215 
219  double get_x_h2() const;
220 
224  double get_x_n2(int) const;
225 
229  double get_rho_wv(int) const;
230 
234  double get_rho_wv() const;
235 
239  double get_rho_wv_anode() const;
240 
244  double get_rho_o2() const;
248  double get_rho_h2() const;
252  double get_rho_n2(int) const;
256  double get_rho_n2() const;
260  double get_rho_n2_anode() const;
261 
267  void set_gas_map(std::map<unsigned int, std::string> tmp);
268 
272  std::map<unsigned int, std::string> get_gas_map() const;
273 
279  double get_density_from_map(std::string species) const;
280 
285  double voltage_cell_th();
286 
290  void print_operating_conditions() const;
291 
295  void adjust_initial_solution(std::vector< component_materialID_value_map >& maps,
296  const boost::shared_ptr< FuelCellShop::Geometry::GridBase<dim> > grid) const;
316  void adjust_boundary_conditions(std::vector< component_boundaryID_value_map >& maps,
317  const boost::shared_ptr< FuelCellShop::Geometry::GridBase<dim> > grid) const;
323  inline double get_c_c() const
324  { return c_c; }
326  inline double get_T() const
327  { return T_cell; }
329  inline double get_V() const
330  { return V_cell; }
336  inline double get_dV_a() const
337  { return dV_a; }
339  inline double get_pc_Pa() const
340  { return p_c; }
342  inline double get_pc_atm() const
343  { return p_c/Units::convert(1.,Units::ATM_to_PA); }
345  inline double get_c_a() const
346  { return c_a; }
348  inline double get_pa_Pa() const
349  { return p_a; }
351  inline double get_pa_atm() const
352  { return p_a/Units::convert(1.,Units::ATM_to_PA); }
354  inline double get_RH_a() const
355  {return RH_a;}
357  inline double get_RH_c() const
358  {return RH_c;}
360  inline double get_OCV() const
361  {return OCV;}
362 
363  private:
369  unsigned int get_species_index(std::string name) const
370  {
371  AssertThrow(name.compare(0,16,"density_species_") == 0, ExcMessage("This function is only meant to be used to get species number from density_species_*, please use another function."));
372 
373  std::string speciesStr = name.substr(16); //get substring from position 16 to end which should be the full species number
374  unsigned int species_index = atoi(speciesStr.c_str()) - 1; //convert species string number to int to use in map
375 
376  return species_index;
377  }
385  double get_anode_gas_density(unsigned int species_index) const
386  {
387  double density(0.0);
388  double p_sat_Pa = Units::convert(saturation_pressure(),Units::ATM_to_PA);
389 
390  unsigned int anode_gas_index = species_index - cathode_mix->n_gases();
391 
392  const std::string gas_name = anode_mix->get_gas(anode_gas_index)->name_material ();
393  double M = 1e3*anode_mix->get_gas(anode_gas_index)->get_molar_mass(); // g/cm3
394 
395  //-- Get pV if water is solved for only:
396  double pv_a = 0.0;
397  for (unsigned int ind_g = 0; ind_g<anode_mix->n_gases(); ind_g++) {
398  std::string name = anode_mix->get_gas(ind_g)->name_material ();
399  if (name.compare("water") == 0)
400  pv_a = p_sat_Pa*RH_a;
401  }
402  double p_H2 = channel_dry_hydrogen_mole_fraction*(p_a-pv_a);
403  double p_N2 = p_a - p_H2 - pv_a;
404 
405  if (gas_name.compare("water") == 0)
406  density = 1E-6*M*pv_a/(R*T_cell); // g/cm^3
407  else if (gas_name.compare("hydrogen") == 0)
408  density = 1E-6*M*p_H2/(R*T_cell); // g/cm^3
409  else if (gas_name.compare("nitrogen") == 0)
410  density = 1E-6*M*p_N2/(R*T_cell); // g/cm^3
411  else
412  AssertThrow(false, ExcMessage("Gas not implemented"));
413 
414  return density;
415 
416  }
424  double get_cathode_gas_density(unsigned int species_index) const
425  {
426  double density(0.0);
427  double p_sat_Pa = Units::convert(saturation_pressure(),Units::ATM_to_PA);
428 
429  const std::string gas_name = cathode_mix->get_gas(species_index)->name_material ();
430  double M = 1e3*cathode_mix->get_gas(species_index)->get_molar_mass(); // g/cm3
431 
432  double pv_c = 0.0;
433  for (unsigned int ind_g = 0; ind_g<cathode_mix->n_gases(); ind_g++)
434  {
435  std::string name = cathode_mix->get_gas(ind_g)->name_material ();
436  if (name.compare("water") == 0)
437  pv_c = p_sat_Pa*RH_c;
438  }
439  double p_O2 = channel_oxygen_mole_fraction*(p_c-pv_c);
440  double p_N2 = p_a - p_O2 - pv_c;
441 
442  if (gas_name.compare("water") == 0)
443  density = 1E-6*M*pv_c/(R*T_cell); // g/cm^3
444  else if (gas_name.compare("oxygen") == 0)
445  density = 1E-6*M*p_O2/(R*T_cell); // g/cm^3
446  else if (gas_name.compare("nitrogen") == 0)
447  density = 1E-6*M*p_N2/(R*T_cell); // g/cm^3
448  else
449  AssertThrow(false, ExcMessage("Gas not implemented"));
450 
451  return density;
452  }
453 
454  //------------ BOUNDARY CONDITIONS -------------------------------
456  bool adjust_BC;
457  //------------ CONSTANTS -----------------------------------------
458  double R; //Gas constant 8.3144 J / (mol K)
459 
462 
465 
466  //------------ CELL DATA -----------------------------------------
468  double T_cell;
470  double V_cell;
472  double dV_a;
474  double OCV;
476  double E_th;
477 
478  //------------- ANODE DATA -------------------------------------
480  double p_a;
482  double c_a;
484  double RH_a;
485 
486  //------------- CATHODE DATA -------------------------------------
488  double p_c;
490  double c_c;
492  double RH_c;
493 
494  //------------- GAS DATA -------------------------------------
497  const double M_water = water.get_molar_mass() * 1000; // [g/mol]
500  const double M_oxygen = oxygen.get_molar_mass() * 1000; // [g/mol]
503  const double M_nitrogen = nitrogen.get_molar_mass() * 1000; // [g/mol]
506  const double M_hydrogen = hydrogen.get_molar_mass() * 1000; // [g/mol]
515 
517  std::map<unsigned int, std::string> gasSpeciesMap;
518 
522  bool anode = false;
523 
527  enum Electrode {noElectrode, ANODE, CATHODE, MEMBRANE};
529  };
530 
531 }
532 
533 #endif // _FUELCELL_OPERATING_CONDITIONS__H
double p_c
Pressure of the gas mixture in the cathode B.C.
Definition: operating_conditions.h:488
double get_V() const
Return cell voltage as input in Operating Conditions subsection.
Definition: operating_conditions.h:329
double T_cell
Operating temperature of the cell.
Definition: operating_conditions.h:468
double c_c
Concentration of the gas mixture in the cathode B.C.
Definition: operating_conditions.h:490
Class used to store, read from file and define the operating conditions for a fuel cell...
Definition: operating_conditions.h:118
double c_a
Concentration of the gas mixture in the anode B.C.
Definition: operating_conditions.h:482
double RH_a
Relative humidity of the gas mixture in the anode B.C.
Definition: operating_conditions.h:484
double E_th
Theoretical voltage for the cell.
Definition: operating_conditions.h:476
double channel_oxygen_mole_fraction
Initial amount of oxygen in channel prior to humidification.
Definition: operating_conditions.h:461
double get_anode_gas_density(unsigned int species_index) const
Private function used in adjust_initial_solution and adjust_boundary_conditions that estimates the de...
Definition: operating_conditions.h:385
double get_pa_atm() const
Return anode pressure as input in Operating Conditions subsection.
Definition: operating_conditions.h:351
double get_pa_Pa() const
Return anode pressure as input in Operating Conditions subsection.
Definition: operating_conditions.h:348
FuelCellShop::Material::GasMixture * cathode_mix
Container storing the gas mixture in the anode compartment of the cell.
Definition: operating_conditions.h:514
double get_c_c() const
Get the total gas concentration in the cathode.
Definition: operating_conditions.h:323
double get_cathode_gas_density(unsigned int species_index) const
Private function used in adjust_initial_solution and adjust_boundary_conditions that estimates the de...
Definition: operating_conditions.h:424
bool adjust_BC
Bool set to true if you want to modify boundary conditions.
Definition: operating_conditions.h:456
FuelCellShop::Material::GasMixture * anode_mix
Container storing the gas mixture in the anode compartment of the cell.
Definition: operating_conditions.h:510
double get_RH_a() const
Return anode relative humidity as input in Operating Conditions subsection.
Definition: operating_conditions.h:354
FuelCellShop::Material::Oxygen oxygen
Get molar mass of oxygen.
Definition: operating_conditions.h:499
double dV_a
Voltage drop in the anode.
Definition: operating_conditions.h:472
double get_dV_a() const
Return the voltage drop in the anode.
Definition: operating_conditions.h:336
double RH_c
Relative humidity of the gas mixture in the anode B.C.
Definition: operating_conditions.h:492
unsigned int get_species_index(std::string name) const
Private member function used to extract the species index value from name.
Definition: operating_conditions.h:369
double get_pc_atm() const
Return cathode pressure as input in Operating Conditions subsection.
Definition: operating_conditions.h:342
double get_T() const
Return cell temperture as input in Operating Conditions subsection.
Definition: operating_conditions.h:326
double R
Definition: operating_conditions.h:458
double V_cell
Operating voltage of the cell.
Definition: operating_conditions.h:470
double get_OCV() const
Get the open circuit voltage for the cell.
Definition: operating_conditions.h:360
Definition: operating_conditions.h:527
std::map< unsigned int, std::string > gasSpeciesMap
map relating species number (key) to species material (value)
Definition: operating_conditions.h:517
FuelCellShop::Material::WaterVapor water
Get molar mass of water vapour.
Definition: operating_conditions.h:496
double R()
Universal gas constant, .
Definition: fcst_constants.h:32
This class describes properties of pure oxygen.
Definition: PureGas.h:974
void set_gas_mixtures(FuelCellShop::Material::GasMixture &c_mix, FuelCellShop::Material::GasMixture &a_mix)
Initialize the temperature and pressure for anode gas mixture and store a copy of GasMixture class in...
Definition: operating_conditions.h:167
double get_RH_c() const
Return cathode relative humidity as input in Operating Conditions subsection.
Definition: operating_conditions.h:357
This class describes properties of pure nitrogen.
Definition: PureGas.h:1027
FuelCellShop::Material::Hydrogen hydrogen
Get molar mass of nitrogen.
Definition: operating_conditions.h:505
double channel_dry_hydrogen_mole_fraction
Initial amount of hydrogen in channel prior to humidification.
Definition: operating_conditions.h:464
void set_total_pressure(const double &rtotal_pressure)
This function takes a pressure (Pa) and if Isobaric fluid flow is set to true in the data file then t...
Definition: GasMixture.h:147
This class describes properties of gas mixtures.
Definition: GasMixture.h:102
double get_c_a() const
Get the total gas concentration in the anode.
Definition: operating_conditions.h:345
double OCV
Open circuit voltage for the cell.
Definition: operating_conditions.h:474
double get_pc_Pa() const
Return cathode pressure as input in Operating Conditions subsection.
Definition: operating_conditions.h:339
Electrode
Variable to switch between electrodes in molar fraction functions:
Definition: operating_conditions.h:527
FuelCell Geometry information class.
Definition: geometry.h:92
FuelCellShop::Material::Nitrogen nitrogen
Get molar mass of nitrogen.
Definition: operating_conditions.h:502
double p_a
Pressure of the gas mixture in the anode B.C.
Definition: operating_conditions.h:480
Electrode compartment
Definition: operating_conditions.h:528
static const unsigned int ATM_to_PA
Definition: fcst_units.h:99
This class describes properties of pure hydrogen.
Definition: PureGas.h:1081
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
void set_temperature(const double &rtemperature)
This function takes a temperature (K) and if Isothermal fluid flow is set to true in the data file th...
Definition: GasMixture.h:157
This class describes properties of pure WaterVapor.
Definition: PureGas.h:1134
const double & get_molar_mass() const
This function returns molar_mass [kg/mol].
Definition: PureGas.h:116