Flow123d
sorption.cc
Go to the documentation of this file.
1 #include <boost/foreach.hpp>
2 
3 #include "reaction/isotherm.hh"
4 #include "reaction/sorption.hh"
5 //#include "system/system.hh"
6 #include "system/sys_profiler.hh"
7 
8 #include "mesh/mesh.h"
9 
10 using namespace std;
11 
12 
14  = IT::Record("Sorption", "Information about all the limited solubility affected adsorptions.")
17  .declare_key("output_fields", IT::Array(make_output_selection("conc_solid", "Sorption_Output")),
18  IT::Default("conc_solid"), "List of fields to write to output stream.");
19 
20 
21 
23  : SorptionBase(init_mesh, in_rec)
24 {
25  //DBGMSG("SorptionSimple constructor.\n");
26  data_ = new EqData("conc_solid");
27  output_selection = make_output_selection("conc_solid", "SorptionSimple_Output");
28 }
29 
31 {
32 }
33 
35 {
36  START_TIMER("SorptionSimple::isotherm_reinit");
37 
38  double rock_density = data_->rock_density.value(elem.centre(),elem);
39  double por_m = data_->porosity.value(elem.centre(),elem);
40 
41  // List of types of isotherms in particular regions
42  arma::uvec adsorption_type = data_->sorption_type.value(elem.centre(),elem);
43  arma::Col<double> mult_coef_vec = data_->isotherm_mult.value(elem.centre(),elem);
44  arma::Col<double> second_coef_vec = data_->isotherm_other.value(elem.centre(),elem);
45 
46  for(int i_subst = 0; i_subst < n_substances_; i_subst++)
47  {
48  double mult_coef = mult_coef_vec[i_subst];
49  double second_coef = second_coef_vec[i_subst];
50  Isotherm & isotherm = isotherms_vec[i_subst];
51 
52  //scales are different for the case of sorption in mobile and immobile pores
53  double scale_aqua = por_m,
54  scale_sorbed = (1 - por_m) * rock_density * molar_masses[i_subst];
55 
56  //DBGMSG("molar_masses[%d %d]: %f\n",i_subst, substance_id[i_subst], molar_masses[i_subst]);
57  if ( scale_sorbed == 0.0)
58  xprintf(UsrErr, "Sorption::init_from_input() failed. Parameter scale_sorbed (phi * (1 - por_m - por_imm) * rock_density * molar_masses[i_subst]) is equal to zero.");
59  bool limited_solubility_on = false;
60  double table_limit;
61  if (solubility_vec_[i_subst] <= 0.0) {
62  limited_solubility_on = false;
63  table_limit=table_limit_[i_subst];
64  } else {
65  limited_solubility_on = true;
66  table_limit=solubility_vec_[i_subst];
67  }
68  isotherm.reinit(Isotherm::SorptionType(adsorption_type[i_subst]), limited_solubility_on,
69  solvent_density, scale_aqua, scale_sorbed, table_limit, mult_coef, second_coef);
70 
71  }
72 
73  END_TIMER("SorptionSimple::isotherm_reinit");
74 }