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
27
32
33#include <algorithm>
34#include <cstddef>
35#include <iterator>
36#include <memory>
37#include <string>
38#include <type_traits>
39#include <vector>
40
41namespace ScriptInterface {
42namespace Observables {
43
44template <typename CoreObs>
46 : public AutoParameters<PidProfileObservable<CoreObs>, Observable> {
48
49public:
50 using Base::Base;
52 this->add_parameters(
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 }},
68 [this]() { return pid_profile_observable()->limits()[0].first; }},
70 [this]() { return pid_profile_observable()->limits()[1].first; }},
72 [this]() { return pid_profile_observable()->limits()[2].first; }},
74 [this]() { return pid_profile_observable()->limits()[0].second; }},
76 [this]() { return pid_profile_observable()->limits()[1].second; }},
78 [this]() { return pid_profile_observable()->limits()[2].second; }}});
79 }
80
81 void do_construct(VariantMap const &params) override {
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>
104 return m_observable;
105 }
106
107 std::shared_ptr<::Observables::Observable> observable() const override {
108 return m_observable;
109 }
110
111private:
112 std::shared_ptr<CoreObs> m_observable;
113};
114
115} /* namespace Observables */
116} /* namespace ScriptInterface */
117
118#endif
Bind parameters in the script interface.
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
Context * context() const
Responsible context.
Base class for script interfaces to core observables classes.
std::shared_ptr<::Observables::PidProfileObservable > pid_profile_observable() const
Variant do_call_method(std::string const &method, VariantMap const &parameters) override
std::shared_ptr<::Observables::Observable > observable() const override
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
static SteepestDescentParameters params
Currently active steepest descent instance.
static constexpr const ReadOnly read_only