Flow123d  master-c754b67
sorption.cc
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file sorption.cc
15  * @brief
16  */
17 
18 #include <vector>
19 #include <limits>
20 
21 #include "reaction/isotherm.hh"
22 #include "reaction/sorption.hh"
23 #include "system/sys_profiler.hh"
24 #include "system/asserts.hh"
25 #include "mesh/accessors.hh"
26 #include "input/factory.hh"
27 #include "fields/field_model.hh"
28 
29 FLOW123D_FORCE_LINK_IN_CHILD(sorptionMobile)
30 FLOW123D_FORCE_LINK_IN_CHILD(sorptionImmobile)
32 
33 
34 /********************************* SORPTION_SIMPLE *********************************************************/
35 /********************************* *********************************************************/
36 
37 // Functors for computing models
39  inline double operator() (double por_m) {
40  return por_m;
41  }
42 };
43 
45  inline double operator() (double surface_cond, double rock_density) {
46  return surface_cond * rock_density;
47  }
48 };
49 
51  inline double operator() (double por_m) {
52  return 1 - por_m;
53  }
54 };
55 
56 
58  return IT::Record("Sorption", "Sorption model in the reaction term of transport.")
61  .declare_key("output", make_output_type("Sorption", "conc_solid", "Concentration solution in the solid phase."),
62  IT::Default("{ \"fields\": [ \"conc_solid\" ] }"),
63  "Setting of the fields output.")
64 
65  .close();
66 }
67 
69  : SorptionBase(init_mesh, in_rec)
70 {
71  eq_fields_ = std::make_shared<EqFields>("conc_solid", "Concentration solution in the solid phase.");
72  this->eq_fieldset_ = eq_fields_;
73  this->eq_fields_base_ = std::static_pointer_cast<ReactionTerm::EqFields>(eq_fields_);
74 }
75 
76 const int SorptionSimple::registrar =
77  Input::register_class< SorptionSimple, Mesh &, Input::Record >("Sorption") +
79 
81 {}
82 
84 {
85  eq_fields_->scale_aqua.set(Model<3, FieldValue<3>::Scalar>::create(fn_simple_scale_aqua(), eq_fields_->porosity), 0.0);
86  eq_fields_->scale_sorbed.set(Model<3, FieldValue<3>::Scalar>::create(
87  fn_simple_scale_sorbed(), eq_fields_->no_sorbing_surface_cond, eq_fields_->rock_density), 0.0);
88  eq_fields_->no_sorbing_surface_cond.set(Model<3, FieldValue<3>::Scalar>::create(fn_simple_surface_cond(), eq_fields_->porosity), 0.0);
89 }
90 
91 
92 /*********************************** *********************************************************/
93 /*********************************** SORPTION_DUAL *********************************************************/
94 /*********************************** *********************************************************/
95 
96 SorptionDual::EqFields::EqFields(const string &output_field_name, const string &output_field_desc)
97 : SorptionBase::EqFields(output_field_name, output_field_desc)
98 {
99  *this+=immob_porosity_
101  .name("porosity_immobile")
102  .set_limits(0.0);
103 }
104 
106  const string &output_conc_name,
107  const string &output_conc_desc)
108  : SorptionBase(init_mesh, in_rec)
109 {
110  eq_fields_dual_ = std::make_shared<EqFields>(output_conc_name, output_conc_desc);
112  this->eq_fields_base_ = std::static_pointer_cast<ReactionTerm::EqFields>(eq_fields_dual_);
113  this->eq_fields_ = std::static_pointer_cast<SorptionBase::EqFields>(eq_fields_dual_);
114 }
115 
117 {}
118 
119 /********************************** *******************************************************/
120 /*********************************** SORPTION_MOBILE *******************************************************/
121 /********************************** *******************************************************/
122 
123 // Functors for computing models
125  inline double operator() (double por_m) {
126  return por_m;
127  }
128 };
129 
131  inline double operator() (double por_m, double por_imm, double surface_cond, double rock_density) {
132  double phi = por_m/(por_m + por_imm);
133  return phi * surface_cond * rock_density;
134  }
135 };
136 
138  inline double operator() (double por_m, double por_imm) {
139  return 1 - por_m - por_imm;
140  }
141 };
142 
143 
145  return IT::Record("SorptionMobile", "Sorption model in the mobile zone, following the dual porosity model.")
148  .declare_key("output", make_output_type("SorptionMobile", "conc_solid", "Concentration solution in the solid mobile phase."),
149  IT::Default("{ \"fields\": [ \"conc_solid\" ] }"),
150  "Setting of the fields output.")
151 
152  .close();
153 }
154 
155 
156 const int SorptionMob::registrar =
157  Input::register_class< SorptionMob, Mesh &, Input::Record >("SorptionMobile") +
159 
160 
162  : SorptionDual(init_mesh, in_rec, "conc_solid", "Concentration solution in the solid mobile phase.")
163 {}
164 
165 
167 {}
168 
170 {
171  eq_fields_->scale_aqua.set(Model<3, FieldValue<3>::Scalar>::create(fn_mob_scale_aqua(), eq_fields_->porosity), 0.0);
172  eq_fields_->scale_sorbed.set(Model<3, FieldValue<3>::Scalar>::create(
173  fn_mob_scale_sorbed(), eq_fields_->porosity, eq_fields_dual_->immob_porosity_, eq_fields_->no_sorbing_surface_cond,
174  eq_fields_->rock_density), 0.0);
175  eq_fields_->no_sorbing_surface_cond.set(Model<3, FieldValue<3>::Scalar>::create(
176  fn_mob_surface_cond(), eq_fields_->porosity, eq_fields_dual_->immob_porosity_), 0.0);
177 }
178 
179 
180 /*********************************** *****************************************************/
181 /*********************************** SORPTION_IMMOBILE *****************************************************/
182 /*********************************** *****************************************************/
183 
184 // Functors for computing models
186  inline double operator() (double por_imm) {
187  return por_imm;
188  }
189 };
190 
192  inline double operator() (double por_m, double por_imm, double surface_cond, double rock_density) {
193  double phi = por_m/(por_m + por_imm);
194  return (1 - phi) * surface_cond * rock_density;
195  }
196 };
197 
199  inline double operator() (double por_m, double por_imm) {
200  return 1 - por_m - por_imm;
201  }
202 };
203 
204 
206  return IT::Record("SorptionImmobile", "Sorption model in the immobile zone, following the dual porosity model.")
209  .declare_key("output", make_output_type("SorptionImmobile", "conc_immobile_solid", "Concentration solution in the solid immobile phase."),
210  IT::Default("{ \"fields\": [ \"conc_immobile_solid\" ] }"),
211  "Setting of the fields output.")
212 
213  .close();
214 }
215 
216 const int SorptionImmob::registrar =
217  Input::register_class< SorptionImmob, Mesh &, Input::Record >("SorptionImmobile") +
219 
221 : SorptionDual(init_mesh, in_rec, "conc_immobile_solid", "Concentration solution in the solid immobile phase.")
222 {}
223 
225 {}
226 
228 {
229  eq_fields_->scale_aqua.set(Model<3, FieldValue<3>::Scalar>::create(fn_immob_scale_aqua(), eq_fields_dual_->immob_porosity_), 0.0);
230  eq_fields_->scale_sorbed.set(Model<3, FieldValue<3>::Scalar>::create(
231  fn_immob_scale_sorbed(), eq_fields_->porosity, eq_fields_dual_->immob_porosity_, eq_fields_->no_sorbing_surface_cond,
232  eq_fields_->rock_density), 0.0);
233  eq_fields_->no_sorbing_surface_cond.set(Model<3, FieldValue<3>::Scalar>::create(
234  fn_immob_surface_cond(), eq_fields_->porosity, eq_fields_dual_->immob_porosity_), 0.0);
235 }
SorptionDual::SorptionDual
SorptionDual(Mesh &init_mesh, Input::Record in_rec, const string &output_conc_name, const string &output_conc_desc)
Constructor.
Definition: sorption.cc:105
SorptionImmob::SorptionImmob
SorptionImmob(Mesh &init_mesh, Input::Record in_rec)
Constructor.
Definition: sorption.cc:220
SorptionBase::get_input_type
static const Input::Type::Record & get_input_type()
Definition: sorption_base.cc:54
ReactionTerm::it_abstract_immobile_term
static Input::Type::Abstract & it_abstract_immobile_term()
Definition: reaction_term.cc:37
SorptionMob::SorptionMob
SorptionMob(Mesh &init_mesh, Input::Record in_rec)
Constructor.
Definition: sorption.cc:161
SorptionSimple::registrar
static const int registrar
Registrar of class to factory.
Definition: sorption.hh:66
SorptionSimple::init_field_models
void init_field_models() override
Implements SorptionBase::init_field_models.
Definition: sorption.cc:83
factory.hh
SorptionMob::~SorptionMob
~SorptionMob(void)
Destructor.
Definition: sorption.cc:166
fn_mob_scale_aqua
Definition: sorption.cc:124
fn_simple_scale_sorbed
Definition: sorption.cc:44
EquationBase::eq_fieldset_
std::shared_ptr< FieldSet > eq_fieldset_
Definition: equation.hh:249
SorptionImmob::~SorptionImmob
~SorptionImmob(void)
Destructor.
Definition: sorption.cc:224
ReactionTerm::EqFields::EqFields
EqFields()
Constructor.
Definition: reaction_term.hh:69
fn_simple_surface_cond::operator()
double operator()(double por_m)
Definition: sorption.cc:51
SorptionSimple::~SorptionSimple
~SorptionSimple(void)
Destructor.
Definition: sorption.cc:80
asserts.hh
Definitions of ASSERTS.
SorptionBase::eq_fields_
std::shared_ptr< EqFields > eq_fields_
Pointer to equation fields. The object is constructed in descendants.
Definition: sorption_base.hh:241
SorptionImmob::init_field_models
void init_field_models() override
Implements SorptionBase::init_field_models.
Definition: sorption.cc:227
FLOW123D_FORCE_LINK_IN_CHILD
#define FLOW123D_FORCE_LINK_IN_CHILD(x)
Definition: global_defs.h:104
FieldCommon::set_limits
FieldCommon & set_limits(double min, double max=std::numeric_limits< double >::max())
Definition: field_common.hh:159
fn_mob_surface_cond
Definition: sorption.cc:137
fn_immob_scale_sorbed::operator()
double operator()(double por_m, double por_imm, double surface_cond, double rock_density)
Definition: sorption.cc:192
SorptionBase
Definition: sorption_base.hh:63
FieldCommon::flags_add
FieldCommon & flags_add(FieldFlag::Flags::Mask mask)
Definition: field_common.hh:198
fn_mob_scale_aqua::operator()
double operator()(double por_m)
Definition: sorption.cc:125
Input::Type::Record::size
unsigned int size() const
Returns number of keys in the Record.
Definition: type_record.hh:602
fn_simple_surface_cond
Definition: sorption.cc:50
Input::Type::Default
Class Input::Type::Default specifies default value of keys of a Input::Type::Record.
Definition: type_record.hh:61
Input::Type::Record::derive_from
virtual Record & derive_from(Abstract &parent)
Method to derive new Record from an AbstractRecord parent.
Definition: type_record.cc:196
accessors.hh
SorptionBase::make_output_type
static Input::Type::Instance make_output_type(const string &equation_name, const string &output_field_name, const string &output_field_desc)
Definition: sorption_base.hh:78
SorptionImmob::get_input_type
static const Input::Type::Record & get_input_type()
Definition: sorption.cc:205
Input::Record
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
sys_profiler.hh
SorptionMob::init_field_models
void init_field_models() override
Implements SorptionBase::init_field_models.
Definition: sorption.cc:169
field_model.hh
fn_immob_scale_aqua
Definition: sorption.cc:185
fn_immob_scale_sorbed
Definition: sorption.cc:191
fn_immob_surface_cond
Definition: sorption.cc:198
sorption.hh
This file contains classes representing sorption model. Sorption model can be computed both in case t...
Input::Type::Record::declare_key
Record & declare_key(const string &key, std::shared_ptr< TypeBase > type, const Default &default_value, const string &description, TypeBase::attribute_map key_attributes=TypeBase::attribute_map())
Declares a new key of the Record.
Definition: type_record.cc:503
SorptionDual::~SorptionDual
~SorptionDual(void)
Destructor.
Definition: sorption.cc:116
isotherm.hh
FieldFlag::input_copy
static constexpr Mask input_copy
Definition: field_flag.hh:44
Input::Type::Record::close
Record & close() const
Close the Record for further declarations of keys.
Definition: type_record.cc:304
SorptionMob::get_input_type
static const Input::Type::Record & get_input_type()
Definition: sorption.cc:144
Input::Type::Record
Record type proxy class.
Definition: type_record.hh:182
fn_simple_scale_aqua
Definition: sorption.cc:38
Mesh
Definition: mesh.h:362
Input::Type::Record::copy_keys
Record & copy_keys(const Record &other)
Copy keys from other record.
Definition: type_record.cc:216
Model
Definition: field_model.hh:291
fn_immob_scale_aqua::operator()
double operator()(double por_imm)
Definition: sorption.cc:186
ReactionTerm::it_abstract_term
static Input::Type::Abstract & it_abstract_term()
Definition: reaction_term.cc:25
fn_mob_surface_cond::operator()
double operator()(double por_m, double por_imm)
Definition: sorption.cc:138
SorptionMob::registrar
static const int registrar
Registrar of class to factory.
Definition: sorption.hh:124
ReactionTerm::eq_fields_base_
std::shared_ptr< EqFields > eq_fields_base_
Equation data - all fields needs in assembly class.
Definition: reaction_term.hh:149
SorptionDual::EqFields
Definition: sorption.hh:76
fn_mob_scale_sorbed
Definition: sorption.cc:130
SorptionDual::eq_fields_dual_
std::shared_ptr< EqFields > eq_fields_dual_
Overwrites SorptionBase::eq_fields_.
Definition: sorption.hh:98
SorptionSimple::get_input_type
static const Input::Type::Record & get_input_type()
Definition: sorption.cc:57
fn_mob_scale_sorbed::operator()
double operator()(double por_m, double por_imm, double surface_cond, double rock_density)
Definition: sorption.cc:131
ReactionTerm::it_abstract_mobile_term
static Input::Type::Abstract & it_abstract_mobile_term()
Definition: reaction_term.cc:31
SorptionDual
Abstract class of sorption model in case dual porosity is considered.
Definition: sorption.hh:73
SorptionSimple::SorptionSimple
SorptionSimple(Mesh &init_mesh, Input::Record in_rec)
Constructor.
Definition: sorption.cc:68
fn_simple_scale_sorbed::operator()
double operator()(double surface_cond, double rock_density)
Definition: sorption.cc:45
SorptionDual::EqFields::immob_porosity_
Field< 3, FieldValue< 3 >::Scalar > immob_porosity_
Definition: sorption.hh:80
FieldCommon::name
FieldCommon & name(const string &name)
Definition: field_common.hh:121
FieldValue
Definition: field_values.hh:567
fn_immob_surface_cond::operator()
double operator()(double por_m, double por_imm)
Definition: sorption.cc:199
SorptionImmob::registrar
static const int registrar
Registrar of class to factory.
Definition: sorption.hh:150