22 #include <boost/core/explicit_operator_bool.hpp>
24 #include <boost/exception/exception.hpp>
26 #include <boost/format/alt_sstream.hpp>
27 #include <boost/format/alt_sstream_impl.hpp>
28 #include <boost/optional/optional.hpp>
29 #include <boost/exception/diagnostic_information.hpp>
30 #include <boost/math/tools/toms748_solve.hpp>
45 double rho_aqua,
double scale_aqua,
double scale_sorbed,
46 double c_aqua_limit,
double mult_coef,
double second_coef)
80 c_sorbed=result.
solid;
96 c_sorbed=result.
solid;
105 THROW( Isotherm::ExcNegativeTotalMass()
106 << EI_TotalMass(total_mass)
110 unsigned int total_mass_idx =
static_cast <unsigned int>(std::floor(total_mass_steps));
144 if (total_mass > mass_limit){
149 mass_limit = total_mass;
152 double upper_solution_bound = mass_limit /
scale_aqua_;
154 std::pair<double,double> solution;
158 boost::uintmax_t max_iter = 20;
160 solution = boost::math::tools::toms748_solve(eq_func, 0.0, upper_solution_bound, toler, max_iter);
162 catch(boost::exception
const & e)
164 THROW( Isotherm::ExcBoostSolver()
165 << EI_BoostMessage(boost::diagnostic_information(e))
170 difference = (solution.second - solution.first)/2;
171 double c_aqua = solution.first + difference;
228 THROW( Isotherm::ExcNegativeTotalMass()
229 << EI_TotalMass(mass_limit)
235 for(
int i=0; i<= n_steps; i++) {
double solubility_limit_
Concentration limit in liquid phase (solubility limit).
ConcPair precipitate(ConcPair conc)
void make_table(unsigned int n_points, double table_limit)
double get_total_mass(ConcPair conc)
ConcPair compute_projection(ConcPair conc)
ConcPair solve_conc(ConcPair c_pair, const Func &isotherm)
void compute(double &c_aqua, double &c_sorbed)
bool limited_solubility_on_
Solubility limit flag.
double mult_coef_
Multiplication parameter of the isotherm.
double table_limit(void) const
Getter for table limit (limit aqueous concentration).
Isotherm()
Default constructor.
SorptionType
Type of adsorption isotherm.
double table_limit_
Concentration in liquid phase for limit of the interpolation table.
double second_coef_
Optional secod parameter of the isotherm.
void interpolate(double &c_aqua, double &c_sorbed)
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)
double rho_aqua_
density of the solvent
std::vector< double > interpolation_table
double scale_aqua_
coefficient that convert soluted concentration to mass; porosity = k_W, originally rho_aqua*porosity ...
enum SorptionType adsorption_type_
Type of isotherm.
double inv_scale_aqua_
reciprocal values
double scale_sorbed_
coefficient that convert adsorbed molar concentration to mass; molar_weight * rho_rock * (1 - porosit...
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Pair of soluted and adsorbed concentration.
#define START_TIMER(tag)
Starts a timer with specified tag.