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 <boost/range/algorithm.hpp>
34
35#include <cstddef>
36#include <iterator>
37#include <memory>
38#include <string>
39#include <type_traits>
40#include <vector>
41
42namespace ScriptInterface {
43namespace Observables {
44
45template <typename CoreObs>
47 : public AutoParameters<PidProfileObservable<CoreObs>, Observable> {
49
50public:
51 using Base::Base;
53 this->add_parameters(
55 [this]() { return pid_profile_observable()->ids(); }},
56 {"n_x_bins", AutoParameter::read_only,
57 [this]() {
58 return static_cast<int>(pid_profile_observable()->n_bins()[0]);
59 }},
60 {"n_y_bins", AutoParameter::read_only,
61 [this]() {
62 return static_cast<int>(pid_profile_observable()->n_bins()[1]);
63 }},
64 {"n_z_bins", AutoParameter::read_only,
65 [this]() {
66 return static_cast<int>(pid_profile_observable()->n_bins()[2]);
67 }},
69 [this]() { return pid_profile_observable()->limits()[0].first; }},
71 [this]() { return pid_profile_observable()->limits()[1].first; }},
73 [this]() { return pid_profile_observable()->limits()[2].first; }},
75 [this]() { return pid_profile_observable()->limits()[0].second; }},
77 [this]() { return pid_profile_observable()->limits()[1].second; }},
79 [this]() { return pid_profile_observable()->limits()[2].second; }}});
80 }
81
82 void do_construct(VariantMap const &params) override {
84 m_observable =
85 make_shared_from_args<CoreObs, std::vector<int>, int, int, int,
86 double, double, double, double, double, double>(
87 params, "ids", "n_x_bins", "n_y_bins", "n_z_bins", "min_x",
88 "max_x", "min_y", "max_y", "min_z", "max_z");
89 });
90 }
91
92 Variant do_call_method(std::string const &method,
93 VariantMap const &parameters) override {
94 if (method == "edges") {
95 std::vector<Variant> variant_edges;
96 boost::copy(pid_profile_observable()->edges(),
97 std::back_inserter(variant_edges));
98 return variant_edges;
99 }
100 return Base::do_call_method(method, parameters);
101 }
102
103 std::shared_ptr<::Observables::PidProfileObservable>
105 return m_observable;
106 }
107
108 std::shared_ptr<::Observables::Observable> observable() const override {
109 return m_observable;
110 }
111
112private:
113 std::shared_ptr<CoreObs> m_observable;
114};
115
116} /* namespace Observables */
117} /* namespace ScriptInterface */
118
119#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: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
static SteepestDescentParameters params
Currently active steepest descent instance.
static constexpr const ReadOnly read_only