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