ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
script_interface/reaction_methods/SingleReaction.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_SINGLE_REACTION_HPP
21
#define SCRIPT_INTERFACE_REACTION_METHODS_SINGLE_REACTION_HPP
22
23
#include "
script_interface/ScriptInterface.hpp
"
24
25
#include "
core/reaction_methods/SingleReaction.hpp
"
26
27
#include <memory>
28
#include <string>
29
#include <vector>
30
31
namespace
ScriptInterface
{
32
namespace
ReactionMethods
{
33
34
class
SingleReaction
:
public
AutoParameters
<SingleReaction> {
35
public
:
36
SingleReaction
() {
37
add_parameters
({
38
{
"nu_bar"
,
AutoParameter::read_only
, [
this
]() {
return
m_sr->nu_bar; }},
39
{
"gamma"
,
AutoParameter::read_only
, [
this
]() {
return
m_sr->gamma; }},
40
{
"reactant_types"
,
AutoParameter::read_only
,
41
[
this
]() {
return
m_sr->reactant_types; }},
42
{
"reactant_coefficients"
,
AutoParameter::read_only
,
43
[
this
]() {
return
m_sr->reactant_coefficients; }},
44
{
"product_types"
,
AutoParameter::read_only
,
45
[
this
]() {
return
m_sr->product_types; }},
46
{
"product_coefficients"
,
AutoParameter::read_only
,
47
[
this
]() {
return
m_sr->product_coefficients; }},
48
});
49
}
50
51
void
do_construct
(
VariantMap
const
&
params
)
override
{
52
context
()->
parallel_try_catch
([&]() {
53
m_sr = std::make_shared<::ReactionMethods::SingleReaction>(
54
get_value<double>
(
params
,
"gamma"
),
55
get_value
<std::vector<int>>(
params
,
"reactant_types"
),
56
get_value
<std::vector<int>>(
params
,
"reactant_coefficients"
),
57
get_value
<std::vector<int>>(
params
,
"product_types"
),
58
get_value
<std::vector<int>>(
params
,
"product_coefficients"
));
59
});
60
}
61
62
std::shared_ptr<::ReactionMethods::SingleReaction>
get_reaction
() {
63
return
m_sr;
64
}
65
66
Variant
do_call_method
(std::string
const
&
name
,
VariantMap
const
&)
override
{
67
if
(
name
==
"get_acceptance_rate"
) {
68
return
m_sr->get_acceptance_rate();
69
}
70
return
{};
71
}
72
73
private
:
74
std::shared_ptr<::ReactionMethods::SingleReaction> m_sr;
75
};
76
77
}
/* namespace ReactionMethods */
78
}
/* namespace ScriptInterface */
79
80
#endif
ScriptInterface.hpp
ScriptInterface::AutoParameters
Bind parameters in the script interface.
Definition
AutoParameters.hpp:94
ScriptInterface::AutoParameters< SingleReaction >::add_parameters
void add_parameters(std::vector< AutoParameter > &¶ms)
Definition
AutoParameters.hpp:123
ScriptInterface::Context::parallel_try_catch
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
ScriptInterface::ObjectHandle::context
Context * context() const
Responsible context.
Definition
ObjectHandle.hpp:57
ScriptInterface::ObjectHandle::name
std::string_view name() const
Definition
ObjectHandle.cpp:117
ScriptInterface::ReactionMethods::SingleReaction
Definition
script_interface/reaction_methods/SingleReaction.hpp:34
ScriptInterface::ReactionMethods::SingleReaction::get_reaction
std::shared_ptr<::ReactionMethods::SingleReaction > get_reaction()
Definition
script_interface/reaction_methods/SingleReaction.hpp:62
ScriptInterface::ReactionMethods::SingleReaction::do_call_method
Variant do_call_method(std::string const &name, VariantMap const &) override
Definition
script_interface/reaction_methods/SingleReaction.hpp:66
ScriptInterface::ReactionMethods::SingleReaction::SingleReaction
SingleReaction()
Definition
script_interface/reaction_methods/SingleReaction.hpp:36
ScriptInterface::ReactionMethods::SingleReaction::do_construct
void do_construct(VariantMap const ¶ms) override
Definition
script_interface/reaction_methods/SingleReaction.hpp:51
SingleReaction.hpp
ReactionMethods
Definition
core/reaction_methods/ConstantpHEnsemble.hpp:26
ScriptInterface
Definition
script_interface/accumulators/AccumulatorBase.hpp:33
ScriptInterface::get_value
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
Definition
get_value.hpp:398
ScriptInterface::VariantMap
std::unordered_map< std::string, Variant > VariantMap
Definition
Variant.hpp:133
params
static SteepestDescentParameters params
Currently active steepest descent instance.
Definition
steepest_descent.cpp:44
ScriptInterface::AutoParameter::read_only
static constexpr const ReadOnly read_only
Definition
AutoParameter.hpp:42
ScriptInterface::impl::recursive_variant
Recursive variant implementation.
Definition
Variant.hpp:84
src
script_interface
reaction_methods
SingleReaction.hpp
Generated on Sun Dec 7 2025 02:31:13 for ESPResSo by
1.9.8