Flow123d  jenkins-Flow123d-windows32-release-multijob-51
sorption.cc
Go to the documentation of this file.
1 #include <vector>
2 
3 #include "reaction/isotherm.hh"
4 #include "reaction/sorption.hh"
5 #include "system/sys_profiler.hh"
6 #include "mesh/accessors.hh"
7 
8 using namespace std;
9 
10 /********************************* *********************************************************/
11 /********************************* SORPTION_SIMPLE *********************************************************/
12 /********************************* *********************************************************/
13 
15 
17  : SorptionBase(init_mesh, in_rec)
18 {
19  data_ = new EqData("conc_solid");
20  this->eq_data_ = data_;
21  output_selection = make_output_selection("conc_solid", "SorptionSimple_Output");
22 }
23 
25 {}
26 
28 {
29  START_TIMER("SorptionSimple::isotherm_reinit");
30 
31  double rock_density = data_->rock_density.value(elem.centre(),elem);
32  double por_m = data_->porosity.value(elem.centre(),elem);
33 
34  // List of types of isotherms in particular regions
35  arma::uvec adsorption_type = data_->sorption_type.value(elem.centre(),elem);
36  arma::Col<double> mult_coef_vec = data_->isotherm_mult.value(elem.centre(),elem);
37  arma::Col<double> second_coef_vec = data_->isotherm_other.value(elem.centre(),elem);
38 
39  for(unsigned int i_subst = 0; i_subst < n_substances_; i_subst++)
40  {
41  double mult_coef = mult_coef_vec[i_subst];
42  double second_coef = second_coef_vec[i_subst];
43  Isotherm & isotherm = isotherms_vec[i_subst];
44 
45  //scales are different for the case of sorption in mobile and immobile pores
46  double scale_aqua = por_m,
47  scale_sorbed = (1 - por_m) * rock_density * molar_masses_[i_subst];
48 
49  if ( scale_sorbed == 0.0)
50  xprintf(UsrErr, "Parameter scale_sorbed ((1 - por_m) * rock_density * molar_masses[i_subst]) is equal to zero.");
51  bool limited_solubility_on = false;
52  double table_limit;
53  if (solubility_vec_[i_subst] <= 0.0) {
54  limited_solubility_on = false;
55  table_limit=table_limit_[i_subst];
56  } else {
57  limited_solubility_on = true;
58  table_limit=solubility_vec_[i_subst];
59  }
60  isotherm.reinit(Isotherm::SorptionType(adsorption_type[i_subst]), limited_solubility_on,
61  solvent_density_, scale_aqua, scale_sorbed, table_limit, mult_coef, second_coef);
62 
63  }
64 
65  END_TIMER("SorptionSimple::isotherm_reinit");
66 }
67 
68 
69 /*********************************** *********************************************************/
70 /*********************************** SORPTION_DUAL *********************************************************/
71 /*********************************** *********************************************************/
72 
74  const string &output_conc_name,
75  const string &output_selection_name)
76  : SorptionBase(init_mesh, in_rec)
77 {
78  data_ = new EqData(output_conc_name);
81  .name("porosity_immobile");
82  this->eq_data_ = data_;
83  output_selection = make_output_selection(output_conc_name, output_selection_name);
84 }
85 
87 {}
88 
89 /********************************** *******************************************************/
90 /*********************************** SORPTION_MOBILE *******************************************************/
91 /********************************** *******************************************************/
92 
94 
96  : SorptionDual(init_mesh, in_rec, "conc_solid", "SorptionMobile_Output")
97 {}
98 
99 
101 {}
102 
103 /*
104 double SorptionMob::compute_sorbing_scale(double por_m, double por_imm)
105 {
106  double phi = por_m/(por_m + por_imm);
107  return phi;
108 }
109 */
110 
112 {
113  START_TIMER("SorptionMob::isotherm_reinit");
114 
115  double rock_density = data_->rock_density.value(elem.centre(),elem);
116 
117  double por_m = data_->porosity.value(elem.centre(),elem);
118  double por_imm = immob_porosity_.value(elem.centre(),elem);
119  double phi = por_m/(por_m + por_imm);
120 
121  // List of types of isotherms in particular regions
122  arma::uvec adsorption_type = data_->sorption_type.value(elem.centre(),elem);
123  arma::Col<double> mult_coef_vec = data_->isotherm_mult.value(elem.centre(),elem);
124  arma::Col<double> second_coef_vec = data_->isotherm_other.value(elem.centre(),elem);
125 
126  for(unsigned int i_subst = 0; i_subst < n_substances_; i_subst++)
127  {
128  double mult_coef = mult_coef_vec[i_subst];
129  double second_coef = second_coef_vec[i_subst];
130  Isotherm & isotherm = isotherms_vec[i_subst];
131 
132  //scales are different for the case of sorption in mobile and immobile pores
133  double scale_aqua, scale_sorbed;
134  scale_aqua = por_m;
135  scale_sorbed = phi * (1 - por_m - por_imm) * rock_density * molar_masses_[i_subst];
136  if(scale_sorbed == 0.0)
137  xprintf(UsrErr, "Parameter scale_sorbed (phi * (1 - por_m - por_imm) * rock_density * molar_masses[i_subst]) is equal to zero.");
138  bool limited_solubility_on;
139  double table_limit;
140  if (solubility_vec_[i_subst] <= 0.0) {
141  limited_solubility_on = false;
142  table_limit=table_limit_[i_subst];
143 
144  } else {
145  limited_solubility_on = true;
146  table_limit=solubility_vec_[i_subst];
147  }
148  isotherm.reinit(Isotherm::SorptionType(adsorption_type[i_subst]), limited_solubility_on,
149  solvent_density_, scale_aqua, scale_sorbed, table_limit, mult_coef, second_coef);
150 
151  }
152 
153  END_TIMER("SorptionMob::isotherm_reinit");
154 }
155 
156 
157 /*********************************** *****************************************************/
158 /*********************************** SORPTION_IMMOBILE *****************************************************/
159 /*********************************** *****************************************************/
160 
162 
164 : SorptionDual(init_mesh, in_rec, "conc_immobile_solid", "SorptionImmobile_Output")
165 {}
166 
168 {}
169 
170 /*
171 double SorptionImmob::compute_sorbing_scale(double por_m, double por_imm)
172 {
173  double phi = por_imm / (por_m + por_imm);
174  return phi;
175 }
176 */
177 
179 {
180  START_TIMER("SorptionImmob::isotherm_reinit");
181 
182  double rock_density = data_->rock_density.value(elem.centre(),elem);
183 
184  double por_m = data_->porosity.value(elem.centre(),elem);
185  double por_imm = immob_porosity_.value(elem.centre(),elem);
186  double phi = por_m/(por_m + por_imm);
187 
188  // List of types of isotherms in particular regions
189  arma::uvec adsorption_type = data_->sorption_type.value(elem.centre(),elem);
190  arma::Col<double> mult_coef_vec = data_->isotherm_mult.value(elem.centre(),elem);
191  arma::Col<double> second_coef_vec = data_->isotherm_other.value(elem.centre(),elem);
192 
193  for(unsigned int i_subst = 0; i_subst < n_substances_; i_subst++)
194  {
195  double mult_coef = mult_coef_vec[i_subst];
196  double second_coef = second_coef_vec[i_subst];
197  Isotherm & isotherm = isotherms_vec[i_subst];
198 
199  //scales are different for the case of sorption in mobile and immobile pores
200  double scale_aqua, scale_sorbed;
201  scale_aqua = por_imm;
202  scale_sorbed = (1 - phi) * (1 - por_m - por_imm) * rock_density * molar_masses_[i_subst];
203  if(scale_sorbed == 0.0)
204  xprintf(UsrErr, "Parameter scale_sorbed ((1 - phi) * (1 - por_m - por_imm) * rock_density * molar_masses[i_subst]) is equal to zero.");
205  bool limited_solubility_on;
206  double table_limit;
207  if (solubility_vec_[i_subst] <= 0.0) {
208  limited_solubility_on = false;
209  table_limit=table_limit_[i_subst];
210 
211  } else {
212  limited_solubility_on = true;
213  table_limit=solubility_vec_[i_subst];
214  }
215  isotherm.reinit(Isotherm::SorptionType(adsorption_type[i_subst]), limited_solubility_on,
216  solvent_density_, scale_aqua, scale_sorbed, table_limit, mult_coef, second_coef);
217 
218  }
219 
220  END_TIMER("SorptionImmob::isotherm_reinit");
221 }
static Input::Type::Record input_type
Definition: sorption.hh:78
FieldSet * eq_data_
Definition: equation.hh:227
double solvent_density_
~SorptionDual(void)
Destructor.
Definition: sorption.cc:86
Field< 3, FieldValue< 3 >::EnumVector > sorption_type
Discrete need Selection for initialization.
FieldCommon & flags_add(FieldFlag::Flags::Mask mask)
Field< 3, FieldValue< 3 >::Vector > isotherm_other
Langmuir sorption coeficients alpha (in fraction c_s = omega * (alpha*c_a)/(1- alpha*c_a)).
Input::Type::Selection output_selection
~SorptionMob(void)
Destructor.
Definition: sorption.cc:100
Abstract class of sorption model in case dual porosity is considered.
Definition: sorption.hh:45
static Input::Type::Record input_type
Definition: sorption.hh:100
Field< 3, FieldValue< 3 >::Scalar > rock_density
Rock matrix density.
void isotherm_reinit(std::vector< Isotherm > &isotherms_vec, const ElementAccessor< 3 > &elem) override
Reinitializes the isotherm.
Definition: sorption.cc:111
Definition: mesh.h:108
std::vector< double > molar_masses_
std::vector< double > table_limit_
Field< 3, FieldValue< 3 >::Vector > isotherm_mult
Multiplication coefficients (k, omega) for all types of isotherms.
void reinit(enum SorptionType sorption_type, bool limited_solubility_on, double aqua_density, double scale_aqua, double scale_sorbed, double c_aqua_limit, double mult_coef, double second_coef)
Definition: isotherm.hh:295
Field< 3, FieldValue< 3 >::Scalar > porosity
Porosity field copied from transport.
Field< 3, FieldValue< 3 >::Scalar > immob_porosity_
Definition: sorption.hh:66
static constexpr Mask input_copy
A field that is input of its equation and cna not read from input, thus muzt be set by copy...
Definition: field_flag.hh:29
std::vector< double > solubility_vec_
Accessor to the data with type Type::Record.
Definition: accessors.hh:308
#define xprintf(...)
Definition: system.hh:100
#define START_TIMER(tag)
Starts a timer with specified tag.
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm) const
Definition: field.hh:399
static Input::Type::Record record_factory(SorptionRecord::Type)
Creates the input record for different cases of sorption model (simple or in dual porosity)...
static Input::Type::Selection make_output_selection(const string &output_field_name, const string &selection_name)
SorptionType
Type of adsorption isotherm.
Definition: isotherm.hh:138
Definition: system.hh:72
SorptionImmob(Mesh &init_mesh, Input::Record in_rec)
Constructor.
Definition: sorption.cc:163
static Input::Type::Record input_type
Definition: sorption.hh:28
void isotherm_reinit(std::vector< Isotherm > &isotherms, const ElementAccessor< 3 > &elm) override
Reinitializes the isotherm.
Definition: sorption.cc:27
SorptionSimple(Mesh &init_mesh, Input::Record in_rec)
Constructor.
Definition: sorption.cc:16
~SorptionSimple(void)
Destructor.
Definition: sorption.cc:24
FieldCommon & name(const string &name)
Definition: field_common.hh:71
#define END_TIMER(tag)
Ends a timer with specified tag.
arma::vec::fixed< spacedim > centre() const
Definition: accessors.hh:81
Record type proxy class.
Definition: type_record.hh:161
unsigned int n_substances_
SorptionDual(Mesh &init_mesh, Input::Record in_rec, const string &output_conc_name, const string &output_selection_name)
Constructor.
Definition: sorption.cc:73
EqData * data_
Pointer to equation data. The object is constructed in descendants.
void isotherm_reinit(std::vector< Isotherm > &isotherms_vec, const ElementAccessor< 3 > &elem) override
Reinitializes the isotherm.
Definition: sorption.cc:178
SorptionMob(Mesh &init_mesh, Input::Record in_rec)
Constructor.
Definition: sorption.cc:95
~SorptionImmob(void)
Destructor.
Definition: sorption.cc:167