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 <algorithm>
33#include <cstddef>
34#include <iterator>
35#include <memory>
36#include <numbers>
37#include <string>
38#include <type_traits>
39#include <vector>
40
41namespace ScriptInterface {
42namespace Observables {
43
44template <typename CoreObs>
46 : public AutoParameters<CylindricalPidProfileObservable<CoreObs>,
47 Observable> {
48 using Base =
50
51public:
52 static_assert(std::is_base_of_v<
54 using Base::Base;
56 this->add_parameters({
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>(
64 }},
65 {"n_phi_bins", AutoParameter::read_only,
66 [this]() {
67 return static_cast<int>(
69 }},
70 {"n_z_bins", AutoParameter::read_only,
71 [this]() {
72 return static_cast<int>(
74 }},
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 }},
84 [this]() {
85 return cylindrical_pid_profile_observable()->limits()[2].first;
86 }},
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 }},
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) {
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>
140 return m_observable;
141 }
142
143private:
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
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:69
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:67
void set_from_args(T &dst, VariantMap const &vals, const char *name)
static SteepestDescentParameters params
Currently active steepest descent instance.
static constexpr const ReadOnly read_only