ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
script_interface/observables/PidProfileObservable.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_PIDPROFILEOBSERVABLE_HPP
23
#define SCRIPT_INTERFACE_OBSERVABLES_PIDPROFILEOBSERVABLE_HPP
24
25
#include "
script_interface/auto_parameters/AutoParameters.hpp
"
26
#include "
script_interface/observables/Observable.hpp
"
27
28
#include "
core/observables/DensityProfile.hpp
"
29
#include "
core/observables/FluxDensityProfile.hpp
"
30
#include "
core/observables/ForceDensityProfile.hpp
"
31
#include "
core/observables/PidProfileObservable.hpp
"
32
33
#include <algorithm>
34
#include <cstddef>
35
#include <iterator>
36
#include <memory>
37
#include <string>
38
#include <type_traits>
39
#include <vector>
40
41
namespace
ScriptInterface
{
42
namespace
Observables
{
43
44
template
<
typename
CoreObs>
45
class
PidProfileObservable
46
:
public
AutoParameters
<PidProfileObservable<CoreObs>, Observable> {
47
using
Base
=
AutoParameters<PidProfileObservable<CoreObs>
,
Observable
>;
48
49
public
:
50
using
Base::Base;
51
PidProfileObservable
() {
52
this->
add_parameters
(
53
{{
"ids"
,
AutoParameter::read_only
,
54
[
this
]() {
return
pid_profile_observable
()->ids(); }},
55
{
"n_x_bins"
,
AutoParameter::read_only
,
56
[
this
]() {
57
return
static_cast<
int
>
(
pid_profile_observable
()->n_bins()[0]);
58
}},
59
{
"n_y_bins"
,
AutoParameter::read_only
,
60
[
this
]() {
61
return
static_cast<
int
>
(
pid_profile_observable
()->n_bins()[1]);
62
}},
63
{
"n_z_bins"
,
AutoParameter::read_only
,
64
[
this
]() {
65
return
static_cast<
int
>
(
pid_profile_observable
()->n_bins()[2]);
66
}},
67
{
"min_x"
,
AutoParameter::read_only
,
68
[
this
]() {
return
pid_profile_observable
()->limits()[0].first; }},
69
{
"min_y"
,
AutoParameter::read_only
,
70
[
this
]() {
return
pid_profile_observable
()->limits()[1].first; }},
71
{
"min_z"
,
AutoParameter::read_only
,
72
[
this
]() {
return
pid_profile_observable
()->limits()[2].first; }},
73
{
"max_x"
,
AutoParameter::read_only
,
74
[
this
]() {
return
pid_profile_observable
()->limits()[0].second; }},
75
{
"max_y"
,
AutoParameter::read_only
,
76
[
this
]() {
return
pid_profile_observable
()->limits()[1].second; }},
77
{
"max_z"
,
AutoParameter::read_only
,
78
[
this
]() {
return
pid_profile_observable
()->limits()[2].second; }}});
79
}
80
81
void
do_construct
(
VariantMap
const
&
params
)
override
{
82
ObjectHandle::context
()->
parallel_try_catch
([&]() {
83
m_observable =
84
make_shared_from_args<CoreObs, std::vector<int>
,
int
,
int
,
int
,
85
double
,
double
,
double
,
double
,
double
,
double
>(
86
params
,
"ids"
,
"n_x_bins"
,
"n_y_bins"
,
"n_z_bins"
,
"min_x"
,
87
"max_x"
,
"min_y"
,
"max_y"
,
"min_z"
,
"max_z"
);
88
});
89
}
90
91
Variant
do_call_method
(std::string
const
&
method
,
92
VariantMap
const
&
parameters
)
override
{
93
if
(
method
==
"edges"
) {
94
std::vector<Variant>
variant_edges
;
95
std::ranges::copy(
pid_profile_observable
()->edges(),
96
std::back_inserter(
variant_edges
));
97
return
variant_edges
;
98
}
99
return
Base::do_call_method(
method
,
parameters
);
100
}
101
102
std::shared_ptr<::Observables::PidProfileObservable>
103
pid_profile_observable
()
const
{
104
return
m_observable;
105
}
106
107
std::shared_ptr<::Observables::Observable>
observable
()
const override
{
108
return
m_observable;
109
}
110
111
private
:
112
std::shared_ptr<CoreObs> m_observable;
113
};
114
115
}
/* namespace Observables */
116
}
/* namespace ScriptInterface */
117
118
#endif
AutoParameters.hpp
DensityProfile.hpp
FluxDensityProfile.hpp
ForceDensityProfile.hpp
ScriptInterface::AutoParameters
Bind parameters in the script interface.
Definition
AutoParameters.hpp:94
ScriptInterface::AutoParameters< PidProfileObservable< 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::Observable
Base class for script interfaces to core observables classes.
Definition
script_interface/observables/Observable.hpp:38
ScriptInterface::Observables::PidProfileObservable
Definition
script_interface/observables/PidProfileObservable.hpp:46
ScriptInterface::Observables::PidProfileObservable::pid_profile_observable
std::shared_ptr<::Observables::PidProfileObservable > pid_profile_observable() const
Definition
script_interface/observables/PidProfileObservable.hpp:103
ScriptInterface::Observables::PidProfileObservable::PidProfileObservable
PidProfileObservable()
Definition
script_interface/observables/PidProfileObservable.hpp:51
ScriptInterface::Observables::PidProfileObservable::do_call_method
Variant do_call_method(std::string const &method, VariantMap const ¶meters) override
Definition
script_interface/observables/PidProfileObservable.hpp:91
ScriptInterface::Observables::PidProfileObservable::observable
std::shared_ptr<::Observables::Observable > observable() const override
Definition
script_interface/observables/PidProfileObservable.hpp:107
ScriptInterface::Observables::PidProfileObservable::do_construct
void do_construct(VariantMap const ¶ms) override
Definition
script_interface/observables/PidProfileObservable.hpp:81
PidProfileObservable.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
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
PidProfileObservable.hpp
Generated on Sun Dec 7 2025 02:31:13 for ESPResSo by
1.9.8