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
26
27#include "Observable.hpp"
29
31
32#include <utils/constants.hpp>
33
34#include <boost/range/algorithm.hpp>
35
36#include <cstddef>
37#include <iterator>
38#include <memory>
39#include <string>
40#include <type_traits>
41#include <vector>
42
43namespace ScriptInterface {
44namespace Observables {
45
46template <typename CoreObs>
48 : public AutoParameters<CylindricalPidProfileObservable<CoreObs>,
49 Observable> {
50 using Base =
52
53public:
54 static_assert(std::is_base_of_v<
56 using Base::Base;
58 this->add_parameters({
60 [this]() { return cylindrical_pid_profile_observable()->ids(); }},
61 {"transform_params", m_transform_params},
62 {"n_r_bins", AutoParameter::read_only,
63 [this]() {
64 return static_cast<int>(
66 }},
67 {"n_phi_bins", AutoParameter::read_only,
68 [this]() {
69 return static_cast<int>(
71 }},
72 {"n_z_bins", AutoParameter::read_only,
73 [this]() {
74 return static_cast<int>(
76 }},
78 [this]() {
79 return cylindrical_pid_profile_observable()->limits()[0].first;
80 }},
81 {"min_phi", AutoParameter::read_only,
82 [this]() {
83 return cylindrical_pid_profile_observable()->limits()[1].first;
84 }},
86 [this]() {
87 return cylindrical_pid_profile_observable()->limits()[2].first;
88 }},
90 [this]() {
91 return cylindrical_pid_profile_observable()->limits()[0].second;
92 }},
93 {"max_phi", AutoParameter::read_only,
94 [this]() {
95 return cylindrical_pid_profile_observable()->limits()[1].second;
96 }},
98 [this]() {
99 return cylindrical_pid_profile_observable()->limits()[2].second;
100 }},
101 });
102 }
103
104 void do_construct(VariantMap const &params) override {
105 set_from_args(m_transform_params, params, "transform_params");
106
107 if (m_transform_params) {
109 m_observable = std::make_shared<CoreObs>(
110 get_value<std::vector<int>>(params, "ids"),
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", -Utils::pi()),
118 get_value_or<double>(params, "max_phi", Utils::pi()),
119 get_value<double>(params, "min_z"),
120 get_value<double>(params, "max_z"));
121 });
122 }
123 }
124
125 Variant do_call_method(std::string const &method,
126 VariantMap const &parameters) override {
127 if (method == "edges") {
128 std::vector<Variant> variant_edges;
129 boost::copy(cylindrical_pid_profile_observable()->edges(),
130 std::back_inserter(variant_edges));
131 return variant_edges;
132 }
133 return Base::do_call_method(method, parameters);
134 }
135
136 std::shared_ptr<::Observables::Observable> observable() const override {
137 return m_observable;
138 }
139
140 virtual std::shared_ptr<::Observables::CylindricalPidProfileObservable>
142 return m_observable;
143 }
144
145private:
146 std::shared_ptr<CoreObs> m_observable;
147 std::shared_ptr<Math::CylindricalTransformationParameters> m_transform_params;
148};
149
150} /* namespace Observables */
151} /* namespace ScriptInterface */
152
153#endif
Bind parameters in the script interface.
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
Context * context() const
Responsible context.
Variant do_call_method(std::string const &method, VariantMap const &parameters) override
virtual std::shared_ptr<::Observables::CylindricalPidProfileObservable > cylindrical_pid_profile_observable() const
Base class for script interfaces to core observables classes.
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
std::unordered_map< std::string, Variant > VariantMap
Definition Variant.hpp:82
boost::make_recursive_variant< None, bool, int, std::size_t, double, std::string, ObjectRef, Utils::Vector3b, Utils::Vector3i, Utils::Vector2d, Utils::Vector3d, Utils::Vector4d, std::vector< int >, std::vector< double >, std::vector< boost::recursive_variant_ >, std::unordered_map< int, boost::recursive_variant_ >, std::unordered_map< std::string, boost::recursive_variant_ > >::type Variant
Possible types for parameters.
Definition Variant.hpp:80
void set_from_args(T &dst, VariantMap const &vals, const char *name)
DEVICE_QUALIFIER constexpr T pi()
Ratio of diameter and circumference of a circle.
Definition constants.hpp:36
static SteepestDescentParameters params
Currently active steepest descent instance.
static constexpr const ReadOnly read_only