ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
script_interface/observables/ProfileObservable.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_PROFILEOBSERVABLE_HPP
23#define SCRIPT_INTERFACE_OBSERVABLES_PROFILEOBSERVABLE_HPP
24
27
30
31#include <algorithm>
32#include <cstddef>
33#include <iterator>
34#include <memory>
35#include <string>
36#include <vector>
37
38namespace ScriptInterface {
39namespace Observables {
40
41template <typename CoreObs>
43 : public AutoParameters<ProfileObservable<CoreObs>, Observable> {
45
46public:
47 using Base::Base;
49 this->add_parameters(
50 {{"n_x_bins",
51 [this](const Variant &v) {
52 profile_observable()->n_bins[0] =
53 static_cast<std::size_t>(get_value<int>(v));
54 },
55 [this]() {
56 return static_cast<int>(profile_observable()->n_bins[0]);
57 }},
58 {"n_y_bins",
59 [this](const Variant &v) {
60 profile_observable()->n_bins[1] =
61 static_cast<std::size_t>(get_value<int>(v));
62 },
63 [this]() {
64 return static_cast<int>(profile_observable()->n_bins[1]);
65 }},
66 {"n_z_bins",
67 [this](const Variant &v) {
68 profile_observable()->n_bins[2] =
69 static_cast<std::size_t>(get_value<int>(v));
70 },
71 [this]() {
72 return static_cast<int>(profile_observable()->n_bins[2]);
73 }},
74 {"min_x",
75 [this](const Variant &v) {
76 profile_observable()->limits[0].first = get_value<double>(v);
77 },
78 [this]() { return profile_observable()->limits[0].first; }},
79 {"min_y",
80 [this](const Variant &v) {
81 profile_observable()->limits[1].first = get_value<double>(v);
82 },
83 [this]() { return profile_observable()->limits[1].first; }},
84 {"min_z",
85 [this](const Variant &v) {
86 profile_observable()->limits[2].first = get_value<double>(v);
87 },
88 [this]() { return profile_observable()->limits[2].first; }},
89 {"max_x",
90 [this](const Variant &v) {
91 profile_observable()->limits[0].second = get_value<double>(v);
92 },
93 [this]() { return profile_observable()->limits[0].second; }},
94 {"max_y",
95 [this](const Variant &v) {
96 profile_observable()->limits[1].second = get_value<double>(v);
97 },
98 [this]() { return profile_observable()->limits[1].second; }},
99 {"max_z",
100 [this](const Variant &v) {
101 profile_observable()->limits[2].second = get_value<double>(v);
102 },
103 [this]() { return profile_observable()->limits[2].second; }}});
104 }
105
106 void construct(VariantMap const &params) override {}
107
108 Variant call_method(std::string const &method,
109 VariantMap const &parameters) override {
110 if (method == "edges") {
111 std::vector<Variant> variant_edges;
112 std::ranges::copy(profile_observable()->edges(),
113 std::back_inserter(variant_edges));
114 return variant_edges;
115 }
116 return Base::call_method(method, parameters);
117 }
118
119 std::shared_ptr<::Observables::ProfileObservable> profile_observable() const {
120 return m_observable;
121 }
122
123 std::shared_ptr<::Observables::Observable> observable() const override {
124 return m_observable;
125 }
126
127private:
128 std::shared_ptr<CoreObs> m_observable;
129};
130
131} /* namespace Observables */
132} /* namespace ScriptInterface */
133
134#endif
Bind parameters in the script interface.
Base class for script interfaces to core observables classes.
std::shared_ptr<::Observables::Observable > observable() const override
Variant call_method(std::string const &method, VariantMap const &parameters) override
std::shared_ptr<::Observables::ProfileObservable > profile_observable() const
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.