ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
script_interface/observables/LBProfileObservable.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_LBPROFILEOBSERVABLE_HPP
23#define SCRIPT_INTERFACE_OBSERVABLES_LBPROFILEOBSERVABLE_HPP
24
26
27#include "Observable.hpp"
29
30#include <algorithm>
31#include <cstddef>
32#include <iterator>
33#include <memory>
34#include <string>
35#include <type_traits>
36#include <vector>
37
38namespace ScriptInterface {
39namespace Observables {
40
41template <typename CoreLBObs>
43 : public AutoParameters<LBProfileObservable<CoreLBObs>, Observable> {
45
46public:
47 static_assert(
48 std::is_base_of_v<::Observables::LBProfileObservable, CoreLBObs>);
49 using Base::Base;
51 this->add_parameters(
52 {{"n_x_bins", AutoParameter::read_only,
53 [this]() {
54 return static_cast<int>(profile_observable()->n_bins()[0]);
55 }},
56 {"n_y_bins", AutoParameter::read_only,
57 [this]() {
58 return static_cast<int>(profile_observable()->n_bins()[1]);
59 }},
60 {"n_z_bins", AutoParameter::read_only,
61 [this]() {
62 return static_cast<int>(profile_observable()->n_bins()[2]);
63 }},
65 [this]() { return profile_observable()->limits()[0].first; }},
67 [this]() { return profile_observable()->limits()[1].first; }},
69 [this]() { return profile_observable()->limits()[2].first; }},
71 [this]() { return profile_observable()->limits()[0].second; }},
73 [this]() { return profile_observable()->limits()[1].second; }},
75 [this]() { return profile_observable()->limits()[2].second; }},
76 {"sampling_delta_x", AutoParameter::read_only,
77 [this]() { return profile_observable()->sampling_delta[0]; }},
78 {"sampling_delta_y", AutoParameter::read_only,
79 [this]() { return profile_observable()->sampling_delta[1]; }},
80 {"sampling_delta_z", AutoParameter::read_only,
81 [this]() { return profile_observable()->sampling_delta[2]; }},
82 {"sampling_offset_x", AutoParameter::read_only,
83 [this]() { return profile_observable()->sampling_offset[0]; }},
84 {"sampling_offset_y", AutoParameter::read_only,
85 [this]() { return profile_observable()->sampling_offset[1]; }},
86 {"sampling_offset_z", AutoParameter::read_only,
87 [this]() { return profile_observable()->sampling_offset[2]; }},
88 {"allow_empty_bins", AutoParameter::read_only,
89 [this]() { return profile_observable()->allow_empty_bins; }}});
90 }
91
92 void do_construct(VariantMap const &params) override {
94 m_observable =
95 make_shared_from_args<CoreLBObs, double, double, double, double,
96 double, double, int, int, int, double, double,
97 double, double, double, double, bool>(
98 params, "sampling_delta_x", "sampling_delta_y",
99 "sampling_delta_z", "sampling_offset_x", "sampling_offset_y",
100 "sampling_offset_z", "n_x_bins", "n_y_bins", "n_z_bins", "min_x",
101 "max_x", "min_y", "max_y", "min_z", "max_z", "allow_empty_bins");
102 });
103 }
104
105 Variant do_call_method(std::string const &method,
106 VariantMap const &parameters) override {
107 if (method == "edges") {
108 std::vector<Variant> variant_edges;
109 std::ranges::copy(profile_observable()->edges(),
110 std::back_inserter(variant_edges));
111 return variant_edges;
112 }
113 return Base::do_call_method(method, parameters);
114 }
115
116 std::shared_ptr<::Observables::Observable> observable() const override {
117 return m_observable;
118 }
119
120 virtual std::shared_ptr<::Observables::LBProfileObservable>
122 return m_observable;
123 }
124
125private:
126 std::shared_ptr<CoreLBObs> m_observable;
127};
128
129} /* namespace Observables */
130} /* namespace ScriptInterface */
131
132#endif
Bind parameters in the script interface.
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
Context * context() const
Responsible context.
virtual std::shared_ptr<::Observables::LBProfileObservable > profile_observable() const
Variant do_call_method(std::string const &method, VariantMap const &parameters) override
std::shared_ptr<::Observables::Observable > observable() const override
Base class for script interfaces to core observables classes.
std::unordered_map< std::string, Variant > VariantMap
Definition Variant.hpp:69
std::shared_ptr< T > make_shared_from_args(VariantMap const &vals, ArgNames &&...args)
Make a new std::shared_ptr<T> with arguments extracted from a VariantMap.
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