ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
script_interface/observables/LBProfileObservable.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2010-2026 The ESPResSo project
3
* Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
4
* Max-Planck-Institute for Polymer Research, Theory Group
5
*
6
* This file is part of ESPResSo.
7
*
8
* ESPResSo is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
12
*
13
* ESPResSo is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
#ifndef SCRIPT_INTERFACE_OBSERVABLES_LBPROFILEOBSERVABLE_HPP
23
#define SCRIPT_INTERFACE_OBSERVABLES_LBPROFILEOBSERVABLE_HPP
24
25
#include "
script_interface/auto_parameters/AutoParameters.hpp
"
26
27
#include "
Observable.hpp
"
28
#include "
core/observables/LBProfileObservable.hpp
"
29
#include "
script_interface/get_value.hpp
"
30
31
#include <algorithm>
32
#include <cstddef>
33
#include <iterator>
34
#include <memory>
35
#include <string>
36
#include <type_traits>
37
#include <vector>
38
39
namespace
ScriptInterface
{
40
namespace
Observables
{
41
42
template
<
typename
CoreLBObs>
43
class
LBProfileObservable
44
:
public
AutoParameters
<LBProfileObservable<CoreLBObs>, Observable> {
45
using
Base
=
AutoParameters<LBProfileObservable<CoreLBObs>
,
Observable
>;
46
47
public
:
48
static_assert
(
49
std::is_base_of_v<::Observables::LBProfileObservable, CoreLBObs>);
50
using
Base::Base;
51
LBProfileObservable
() {
52
this->
add_parameters
(
53
{{
"n_x_bins"
,
AutoParameter::read_only
,
54
[
this
]() {
55
return
static_cast<
int
>
(
profile_observable
()->n_bins()[0]);
56
}},
57
{
"n_y_bins"
,
AutoParameter::read_only
,
58
[
this
]() {
59
return
static_cast<
int
>
(
profile_observable
()->n_bins()[1]);
60
}},
61
{
"n_z_bins"
,
AutoParameter::read_only
,
62
[
this
]() {
63
return
static_cast<
int
>
(
profile_observable
()->n_bins()[2]);
64
}},
65
{
"min_x"
,
AutoParameter::read_only
,
66
[
this
]() {
return
profile_observable
()->limits()[0].first; }},
67
{
"min_y"
,
AutoParameter::read_only
,
68
[
this
]() {
return
profile_observable
()->limits()[1].first; }},
69
{
"min_z"
,
AutoParameter::read_only
,
70
[
this
]() {
return
profile_observable
()->limits()[2].first; }},
71
{
"max_x"
,
AutoParameter::read_only
,
72
[
this
]() {
return
profile_observable
()->limits()[0].second; }},
73
{
"max_y"
,
AutoParameter::read_only
,
74
[
this
]() {
return
profile_observable
()->limits()[1].second; }},
75
{
"max_z"
,
AutoParameter::read_only
,
76
[
this
]() {
return
profile_observable
()->limits()[2].second; }},
77
{
"sampling_delta_x"
,
AutoParameter::read_only
,
78
[
this
]() {
return
profile_observable
()->sampling_delta[0]; }},
79
{
"sampling_delta_y"
,
AutoParameter::read_only
,
80
[
this
]() {
return
profile_observable
()->sampling_delta[1]; }},
81
{
"sampling_delta_z"
,
AutoParameter::read_only
,
82
[
this
]() {
return
profile_observable
()->sampling_delta[2]; }},
83
{
"sampling_offset_x"
,
AutoParameter::read_only
,
84
[
this
]() {
return
profile_observable
()->sampling_offset[0]; }},
85
{
"sampling_offset_y"
,
AutoParameter::read_only
,
86
[
this
]() {
return
profile_observable
()->sampling_offset[1]; }},
87
{
"sampling_offset_z"
,
AutoParameter::read_only
,
88
[
this
]() {
return
profile_observable
()->sampling_offset[2]; }},
89
{
"allow_empty_bins"
,
AutoParameter::read_only
,
90
[
this
]() {
return
profile_observable
()->allow_empty_bins; }}});
91
}
92
93
void
do_construct
(
VariantMap
const
¶ms)
override
{
94
ObjectHandle::context
()->
parallel_try_catch
([&]() {
95
m_observable = std::make_shared<CoreLBObs>(
96
get_value_or<double>
(params,
"sampling_delta_x"
, 1.),
97
get_value_or<double>
(params,
"sampling_delta_y"
, 1.),
98
get_value_or<double>
(params,
"sampling_delta_z"
, 1.),
99
get_value_or<double>
(params,
"sampling_offset_x"
, 0.),
100
get_value_or<double>
(params,
"sampling_offset_y"
, 0.),
101
get_value_or<double>
(params,
"sampling_offset_z"
, 0.),
102
get_value<int>
(params,
"n_x_bins"
),
103
get_value<int>
(params,
"n_y_bins"
),
104
get_value<int>
(params,
"n_z_bins"
),
105
get_value<double>
(params,
"min_x"
),
106
get_value<double>
(params,
"max_x"
),
107
get_value<double>
(params,
"min_y"
),
108
get_value<double>
(params,
"max_y"
),
109
get_value<double>
(params,
"min_z"
),
110
get_value<double>
(params,
"max_z"
),
111
get_value_or<bool>
(params,
"allow_empty_bins"
,
false
));
112
});
113
}
114
115
Variant
do_call_method
(std::string
const
&
method
,
116
VariantMap
const
&
parameters
)
override
{
117
if
(
method
==
"edges"
) {
118
std::vector<Variant>
variant_edges
;
119
std::ranges::copy(
profile_observable
()->edges(),
120
std::back_inserter(
variant_edges
));
121
return
variant_edges
;
122
}
123
return
Base::do_call_method(
method
,
parameters
);
124
}
125
126
std::shared_ptr<::Observables::Observable>
observable
()
const override
{
127
return
m_observable;
128
}
129
130
virtual
std::shared_ptr<::Observables::LBProfileObservable>
131
profile_observable
()
const
{
132
return
m_observable;
133
}
134
135
private
:
136
std::shared_ptr<CoreLBObs> m_observable;
137
};
138
139
}
/* namespace Observables */
140
}
/* namespace ScriptInterface */
141
142
#endif
AutoParameters.hpp
ScriptInterface::AutoParameters
Bind parameters in the script interface.
Definition
AutoParameters.hpp:94
ScriptInterface::AutoParameters< LBProfileObservable< CoreLBObs >, Observable >::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::Observables::LBProfileObservable
Definition
script_interface/observables/LBProfileObservable.hpp:44
ScriptInterface::Observables::LBProfileObservable::do_construct
void do_construct(VariantMap const ¶ms) override
Definition
script_interface/observables/LBProfileObservable.hpp:93
ScriptInterface::Observables::LBProfileObservable::profile_observable
virtual std::shared_ptr<::Observables::LBProfileObservable > profile_observable() const
Definition
script_interface/observables/LBProfileObservable.hpp:131
ScriptInterface::Observables::LBProfileObservable::do_call_method
Variant do_call_method(std::string const &method, VariantMap const ¶meters) override
Definition
script_interface/observables/LBProfileObservable.hpp:115
ScriptInterface::Observables::LBProfileObservable::LBProfileObservable
LBProfileObservable()
Definition
script_interface/observables/LBProfileObservable.hpp:51
ScriptInterface::Observables::LBProfileObservable::observable
std::shared_ptr<::Observables::Observable > observable() const override
Definition
script_interface/observables/LBProfileObservable.hpp:126
ScriptInterface::Observables::Observable
Base class for script interfaces to core observables classes.
Definition
script_interface/observables/Observable.hpp:38
LBProfileObservable.hpp
get_value.hpp
Observables
Definition
BondAngles.hpp:37
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
Observable.hpp
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
observables
LBProfileObservable.hpp
Generated on Tue Jul 7 2026 01:25:54 for ESPResSo by
1.9.8