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-2022 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
30
#include <algorithm>
31
#include <cstddef>
32
#include <iterator>
33
#include <memory>
34
#include <string>
35
#include <type_traits>
36
#include <vector>
37
38
namespace
ScriptInterface
{
39
namespace
Observables
{
40
41
template
<
typename
CoreLBObs>
42
class
LBProfileObservable
43
:
public
AutoParameters
<LBProfileObservable<CoreLBObs>, Observable> {
44
using
Base
=
AutoParameters<LBProfileObservable<CoreLBObs>
,
Observable
>;
45
46
public
:
47
static_assert
(
48
std::is_base_of_v<::Observables::LBProfileObservable, CoreLBObs>);
49
using
Base::Base;
50
LBProfileObservable
() {
51
this->
add_parameters
(
52
{{
"n_x_bins"
,
AutoParameter::read_only
,
53
[
this
]() {
54
return
static_cast<
int
>
(
profile_observable
()->n_bins()[0]);
55
}},
56
{
"n_y_bins"
,
AutoParameter::read_only
,
57
[
this
]() {
58
return
static_cast<
int
>
(
profile_observable
()->n_bins()[1]);
59
}},
60
{
"n_z_bins"
,
AutoParameter::read_only
,
61
[
this
]() {
62
return
static_cast<
int
>
(
profile_observable
()->n_bins()[2]);
63
}},
64
{
"min_x"
,
AutoParameter::read_only
,
65
[
this
]() {
return
profile_observable
()->limits()[0].first; }},
66
{
"min_y"
,
AutoParameter::read_only
,
67
[
this
]() {
return
profile_observable
()->limits()[1].first; }},
68
{
"min_z"
,
AutoParameter::read_only
,
69
[
this
]() {
return
profile_observable
()->limits()[2].first; }},
70
{
"max_x"
,
AutoParameter::read_only
,
71
[
this
]() {
return
profile_observable
()->limits()[0].second; }},
72
{
"max_y"
,
AutoParameter::read_only
,
73
[
this
]() {
return
profile_observable
()->limits()[1].second; }},
74
{
"max_z"
,
AutoParameter::read_only
,
75
[
this
]() {
return
profile_observable
()->limits()[2].second; }},
76
{
"sampling_delta_x"
,
AutoParameter::read_only
,
77
[
this
]() {
return
profile_observable
()->sampling_delta[0]; }},
78
{
"sampling_delta_y"
,
AutoParameter::read_only
,
79
[
this
]() {
return
profile_observable
()->sampling_delta[1]; }},
80
{
"sampling_delta_z"
,
AutoParameter::read_only
,
81
[
this
]() {
return
profile_observable
()->sampling_delta[2]; }},
82
{
"sampling_offset_x"
,
AutoParameter::read_only
,
83
[
this
]() {
return
profile_observable
()->sampling_offset[0]; }},
84
{
"sampling_offset_y"
,
AutoParameter::read_only
,
85
[
this
]() {
return
profile_observable
()->sampling_offset[1]; }},
86
{
"sampling_offset_z"
,
AutoParameter::read_only
,
87
[
this
]() {
return
profile_observable
()->sampling_offset[2]; }},
88
{
"allow_empty_bins"
,
AutoParameter::read_only
,
89
[
this
]() {
return
profile_observable
()->allow_empty_bins; }}});
90
}
91
92
void
do_construct
(
VariantMap
const
&
params
)
override
{
93
ObjectHandle::context
()->
parallel_try_catch
([&]() {
94
m_observable =
95
make_shared_from_args
<
CoreLBObs
,
double
,
double
,
double
,
double
,
96
double
,
double
,
int
,
int
,
int
,
double
,
double
,
97
double
,
double
,
double
,
double
,
bool
>(
98
params
,
"sampling_delta_x"
,
"sampling_delta_y"
,
99
"sampling_delta_z"
,
"sampling_offset_x"
,
"sampling_offset_y"
,
100
"sampling_offset_z"
,
"n_x_bins"
,
"n_y_bins"
,
"n_z_bins"
,
"min_x"
,
101
"max_x"
,
"min_y"
,
"max_y"
,
"min_z"
,
"max_z"
,
"allow_empty_bins"
);
102
});
103
}
104
105
Variant
do_call_method
(std::string
const
&
method
,
106
VariantMap
const
&
parameters
)
override
{
107
if
(
method
==
"edges"
) {
108
std::vector<Variant>
variant_edges
;
109
std::ranges::copy(
profile_observable
()->edges(),
110
std::back_inserter(
variant_edges
));
111
return
variant_edges
;
112
}
113
return
Base::do_call_method(
method
,
parameters
);
114
}
115
116
std::shared_ptr<::Observables::Observable>
observable
()
const override
{
117
return
m_observable;
118
}
119
120
virtual
std::shared_ptr<::Observables::LBProfileObservable>
121
profile_observable
()
const
{
122
return
m_observable;
123
}
124
125
private
:
126
std::shared_ptr<CoreLBObs> m_observable;
127
};
128
129
}
/* namespace Observables */
130
}
/* namespace ScriptInterface */
131
132
#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:43
ScriptInterface::Observables::LBProfileObservable::do_construct
void do_construct(VariantMap const ¶ms) override
Definition
script_interface/observables/LBProfileObservable.hpp:92
ScriptInterface::Observables::LBProfileObservable::profile_observable
virtual std::shared_ptr<::Observables::LBProfileObservable > profile_observable() const
Definition
script_interface/observables/LBProfileObservable.hpp:121
ScriptInterface::Observables::LBProfileObservable::do_call_method
Variant do_call_method(std::string const &method, VariantMap const ¶meters) override
Definition
script_interface/observables/LBProfileObservable.hpp:105
ScriptInterface::Observables::LBProfileObservable::LBProfileObservable
LBProfileObservable()
Definition
script_interface/observables/LBProfileObservable.hpp:50
ScriptInterface::Observables::LBProfileObservable::observable
std::shared_ptr<::Observables::Observable > observable() const override
Definition
script_interface/observables/LBProfileObservable.hpp:116
ScriptInterface::Observables::Observable
Base class for script interfaces to core observables classes.
Definition
script_interface/observables/Observable.hpp:38
LBProfileObservable.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
ScriptInterface::make_shared_from_args
std::shared_ptr< T > make_shared_from_args(VariantMap const &vals, ArgNames &&...args)
Make a new std::shared_ptr<T> with arguments extracted from a VariantMap.
Definition
get_value.hpp:433
Observable.hpp
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
observables
LBProfileObservable.hpp
Generated on Sun Dec 7 2025 02:31:13 for ESPResSo by
1.9.8