ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
script_interface/reaction_methods/ConstantpHEnsemble.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef SCRIPT_INTERFACE_REACTION_METHODS_CONSTANT_PH_HPP
21#define SCRIPT_INTERFACE_REACTION_METHODS_CONSTANT_PH_HPP
22
23#include "ReactionAlgorithm.hpp"
24
26
30
31#include <memory>
32#include <unordered_map>
33
34namespace ScriptInterface {
35namespace ReactionMethods {
36
38public:
39 std::shared_ptr<::ReactionMethods::ReactionAlgorithm> RE() override {
40 return m_re;
41 }
42 std::shared_ptr<::ReactionMethods::ReactionAlgorithm> const
43 RE() const override {
44 return m_re;
45 }
46
49 {"constant_pH",
50 [this](Variant const &v) {
51 m_re->m_constant_pH = get_value<double>(v);
52 },
53 [this]() { return m_re->m_constant_pH; }},
54 });
55 }
56
57 void do_construct(VariantMap const &params) override {
59 m_re = std::make_shared<::ReactionMethods::ConstantpHEnsemble>(
60 context()->get_comm(), get_value<int>(params, "seed"),
61 get_value<double>(params, "kT"),
62 get_value<double>(params, "exclusion_range"),
63 get_value<double>(params, "constant_pH"),
64 get_value_or<std::unordered_map<int, double>>(
65 params, "exclusion_radius_per_type", {}));
66 });
67 do_set_parameter("search_algorithm",
68 Variant{get_value_or<std::string>(
69 params, "search_algorithm", "order_n")});
70 }
71
72protected:
75 std::unordered_map<int, int> const &particle_numbers) const override {
76 return ::ReactionMethods::calculate_factorial_expression_cpH(
77 reaction, particle_numbers);
78 }
79
80private:
81 std::shared_ptr<::ReactionMethods::ConstantpHEnsemble> m_re;
82};
83} /* namespace ReactionMethods */
84} /* namespace ScriptInterface */
85
86#endif
void do_set_parameter(const std::string &name, const Variant &value) final
void add_parameters(std::vector< AutoParameter > &&params)
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
Context * context() const
Responsible context.
std::shared_ptr<::ReactionMethods::ReactionAlgorithm > RE() override
std::shared_ptr<::ReactionMethods::ReactionAlgorithm > const RE() const override
double calculate_factorial_expression(::ReactionMethods::SingleReaction const &reaction, std::unordered_map< int, int > const &particle_numbers) const override
std::unordered_map< std::string, Variant > VariantMap
Definition Variant.hpp:82
T get_value_or(VariantMap const &vals, std::string const &name, T const &default_)
Get a value from a VariantMap by name, or return a default value if it does not exist.
boost::make_recursive_variant< None, bool, int, std::size_t, double, std::string, ObjectRef, Utils::Vector3b, Utils::Vector3i, Utils::Vector2d, Utils::Vector3d, Utils::Vector4d, std::vector< int >, std::vector< double >, std::vector< boost::recursive_variant_ >, std::unordered_map< int, boost::recursive_variant_ >, std::unordered_map< std::string, boost::recursive_variant_ > >::type Variant
Possible types for parameters.
Definition Variant.hpp:80
static SteepestDescentParameters params
Currently active steepest descent instance.