ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
script_interface/observables/CylindricalLBProfileObservable.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_CYLINDRICALLBPROFILEOBSERVABLE_HPP
23
#define SCRIPT_INTERFACE_OBSERVABLES_CYLINDRICALLBPROFILEOBSERVABLE_HPP
24
25
#include "
script_interface/auto_parameters/AutoParameters.hpp
"
26
27
#include "
Observable.hpp
"
28
#include "
core/observables/CylindricalLBProfileObservable.hpp
"
29
#include "
script_interface/get_value.hpp
"
30
31
#include "
script_interface/math/CylindricalTransformationParameters.hpp
"
32
33
#include <algorithm>
34
#include <cstddef>
35
#include <iterator>
36
#include <memory>
37
#include <numbers>
38
#include <string>
39
#include <type_traits>
40
#include <vector>
41
42
namespace
ScriptInterface
{
43
namespace
Observables
{
44
45
template
<
typename
CoreCylLBObs>
46
class
CylindricalLBProfileObservable
47
:
public
AutoParameters
<CylindricalLBProfileObservable<CoreCylLBObs>,
48
Observable> {
49
using
Base
=
50
AutoParameters<CylindricalLBProfileObservable<CoreCylLBObs>
,
Observable
>;
51
52
public
:
53
static_assert
(std::is_base_of_v<
::Observables::CylindricalLBProfileObservable
,
54
CoreCylLBObs
>);
55
using
Base::Base;
56
CylindricalLBProfileObservable
() {
57
this->
add_parameters
({
58
{
"transform_params"
, m_transform_params},
59
{
"n_r_bins"
,
AutoParameter::read_only
,
60
[
this
]() {
61
return
static_cast<
int
>
(
62
cylindrical_profile_observable
()->n_bins()[0]);
63
}},
64
{
"n_phi_bins"
,
AutoParameter::read_only
,
65
[
this
]() {
66
return
static_cast<
int
>
(
67
cylindrical_profile_observable
()->n_bins()[1]);
68
}},
69
{
"n_z_bins"
,
AutoParameter::read_only
,
70
[
this
]() {
71
return
static_cast<
int
>
(
72
cylindrical_profile_observable
()->n_bins()[2]);
73
}},
74
{
"min_r"
,
AutoParameter::read_only
,
75
[
this
]() {
76
return
cylindrical_profile_observable
()->limits()[0].first;
77
}},
78
{
"min_phi"
,
AutoParameter::read_only
,
79
[
this
]() {
80
return
cylindrical_profile_observable
()->limits()[1].first;
81
}},
82
{
"min_z"
,
AutoParameter::read_only
,
83
[
this
]() {
84
return
cylindrical_profile_observable
()->limits()[2].first;
85
}},
86
{
"max_r"
,
AutoParameter::read_only
,
87
[
this
]() {
88
return
cylindrical_profile_observable
()->limits()[0].second;
89
}},
90
{
"max_phi"
,
AutoParameter::read_only
,
91
[
this
]() {
92
return
cylindrical_profile_observable
()->limits()[1].second;
93
}},
94
{
"max_z"
,
AutoParameter::read_only
,
95
[
this
]() {
96
return
cylindrical_profile_observable
()->limits()[2].second;
97
}},
98
{
"sampling_density"
,
AutoParameter::read_only
,
99
[
this
]() {
100
return
cylindrical_profile_observable
()->sampling_density;
101
}},
102
});
103
}
104
105
void
do_construct
(
VariantMap
const
&
params
)
override
{
106
set_from_args
(m_transform_params,
params
,
"transform_params"
);
107
108
if
(m_transform_params) {
109
ObjectHandle::context
()->
parallel_try_catch
([&]() {
110
m_observable = std::make_shared<CoreCylLBObs>(
111
m_transform_params->cyl_transform_params(),
112
get_value_or<int>
(
params
,
"n_r_bins"
, 1),
113
get_value_or<int>
(
params
,
"n_phi_bins"
, 1),
114
get_value_or<int>
(
params
,
"n_z_bins"
, 1),
115
get_value_or<double>
(
params
,
"min_r"
, 0.),
116
get_value<double>
(
params
,
"max_r"
),
117
get_value_or<double>
(
params
,
"min_phi"
, -std::numbers::pi),
118
get_value_or<double>
(
params
,
"max_phi"
, std::numbers::pi),
119
get_value<double>
(
params
,
"min_z"
),
120
get_value<double>
(
params
,
"max_z"
),
121
get_value<double>
(
params
,
"sampling_density"
));
122
});
123
}
124
}
125
126
Variant
do_call_method
(std::string
const
&
method
,
127
VariantMap
const
&
parameters
)
override
{
128
if
(
method
==
"edges"
) {
129
std::vector<Variant>
variant_edges
;
130
std::ranges::copy(
cylindrical_profile_observable
()->edges(),
131
std::back_inserter(
variant_edges
));
132
return
variant_edges
;
133
}
134
return
Base::do_call_method(
method
,
parameters
);
135
}
136
137
std::shared_ptr<::Observables::Observable>
observable
()
const override
{
138
return
m_observable;
139
}
140
141
virtual
std::shared_ptr<::Observables::CylindricalLBProfileObservable>
142
cylindrical_profile_observable
()
const
{
143
return
m_observable;
144
}
145
146
private
:
147
std::shared_ptr<CoreCylLBObs> m_observable;
148
std::shared_ptr<Math::CylindricalTransformationParameters> m_transform_params;
149
};
150
151
}
/* namespace Observables */
152
}
/* namespace ScriptInterface */
153
154
#endif
AutoParameters.hpp
CylindricalTransformationParameters.hpp
Observables::CylindricalLBProfileObservable
Definition
core/observables/CylindricalLBProfileObservable.hpp:38
ScriptInterface::AutoParameters
Bind parameters in the script interface.
Definition
AutoParameters.hpp:94
ScriptInterface::AutoParameters< CylindricalLBProfileObservable< CoreCylLBObs >, 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::CylindricalLBProfileObservable
Definition
script_interface/observables/CylindricalLBProfileObservable.hpp:48
ScriptInterface::Observables::CylindricalLBProfileObservable::cylindrical_profile_observable
virtual std::shared_ptr<::Observables::CylindricalLBProfileObservable > cylindrical_profile_observable() const
Definition
script_interface/observables/CylindricalLBProfileObservable.hpp:142
ScriptInterface::Observables::CylindricalLBProfileObservable::do_call_method
Variant do_call_method(std::string const &method, VariantMap const ¶meters) override
Definition
script_interface/observables/CylindricalLBProfileObservable.hpp:126
ScriptInterface::Observables::CylindricalLBProfileObservable::observable
std::shared_ptr<::Observables::Observable > observable() const override
Definition
script_interface/observables/CylindricalLBProfileObservable.hpp:137
ScriptInterface::Observables::CylindricalLBProfileObservable::CylindricalLBProfileObservable
CylindricalLBProfileObservable()
Definition
script_interface/observables/CylindricalLBProfileObservable.hpp:56
ScriptInterface::Observables::CylindricalLBProfileObservable::do_construct
void do_construct(VariantMap const ¶ms) override
Definition
script_interface/observables/CylindricalLBProfileObservable.hpp:105
ScriptInterface::Observables::Observable
Base class for script interfaces to core observables classes.
Definition
script_interface/observables/Observable.hpp:38
CylindricalLBProfileObservable.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
ScriptInterface::set_from_args
void set_from_args(T &dst, VariantMap const &vals, const char *name)
Definition
get_value.hpp:440
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
CylindricalLBProfileObservable.hpp
Generated on Sun Dec 7 2025 02:31:13 for ESPResSo by
1.9.8