ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
script_interface/observables/CylindricalLBProfileObservable.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_CYLINDRICALLBPROFILEOBSERVABLE_HPP
23#define SCRIPT_INTERFACE_OBSERVABLES_CYLINDRICALLBPROFILEOBSERVABLE_HPP
24
26
27#include "Observable.hpp"
30
32
33#include <algorithm>
34#include <cstddef>
35#include <iterator>
36#include <memory>
37#include <numbers>
38#include <string>
39#include <type_traits>
40#include <vector>
41
42namespace ScriptInterface {
43namespace Observables {
44
45template <typename CoreCylLBObs>
47 : public AutoParameters<CylindricalLBProfileObservable<CoreCylLBObs>,
48 Observable> {
49 using Base =
51
52public:
53 static_assert(std::is_base_of_v<::Observables::CylindricalLBProfileObservable,
54 CoreCylLBObs>);
55 using Base::Base;
57 this->add_parameters({
58 {"transform_params", m_transform_params},
59 {"n_r_bins", AutoParameter::read_only,
60 [this]() {
61 return static_cast<int>(
62 cylindrical_profile_observable()->n_bins()[0]);
63 }},
64 {"n_phi_bins", AutoParameter::read_only,
65 [this]() {
66 return static_cast<int>(
67 cylindrical_profile_observable()->n_bins()[1]);
68 }},
69 {"n_z_bins", AutoParameter::read_only,
70 [this]() {
71 return static_cast<int>(
72 cylindrical_profile_observable()->n_bins()[2]);
73 }},
75 [this]() {
76 return cylindrical_profile_observable()->limits()[0].first;
77 }},
78 {"min_phi", AutoParameter::read_only,
79 [this]() {
80 return cylindrical_profile_observable()->limits()[1].first;
81 }},
83 [this]() {
84 return cylindrical_profile_observable()->limits()[2].first;
85 }},
87 [this]() {
88 return cylindrical_profile_observable()->limits()[0].second;
89 }},
90 {"max_phi", AutoParameter::read_only,
91 [this]() {
92 return cylindrical_profile_observable()->limits()[1].second;
93 }},
95 [this]() {
96 return cylindrical_profile_observable()->limits()[2].second;
97 }},
98 {"sampling_density", AutoParameter::read_only,
99 [this]() {
100 return cylindrical_profile_observable()->sampling_density;
101 }},
102 });
103 }
104
105 void do_construct(VariantMap const &params) override {
106 set_from_args(m_transform_params, params, "transform_params");
107
108 if (m_transform_params) {
110 m_observable = std::make_shared<CoreCylLBObs>(
111 m_transform_params->cyl_transform_params(),
112 get_value_or<int>(params, "n_r_bins", 1),
113 get_value_or<int>(params, "n_phi_bins", 1),
114 get_value_or<int>(params, "n_z_bins", 1),
115 get_value_or<double>(params, "min_r", 0.),
116 get_value<double>(params, "max_r"),
117 get_value_or<double>(params, "min_phi", -std::numbers::pi),
118 get_value_or<double>(params, "max_phi", std::numbers::pi),
119 get_value<double>(params, "min_z"),
120 get_value<double>(params, "max_z"),
121 get_value<double>(params, "sampling_density"));
122 });
123 }
124 }
125
126 Variant do_call_method(std::string const &method,
127 VariantMap const &parameters) override {
128 if (method == "edges") {
129 std::vector<Variant> variant_edges;
130 std::ranges::copy(cylindrical_profile_observable()->edges(),
131 std::back_inserter(variant_edges));
132 return variant_edges;
133 }
134 return Base::do_call_method(method, parameters);
135 }
136
137 std::shared_ptr<::Observables::Observable> observable() const override {
138 return m_observable;
139 }
140
141 virtual std::shared_ptr<::Observables::CylindricalLBProfileObservable>
143 return m_observable;
144 }
145
146private:
147 std::shared_ptr<CoreCylLBObs> m_observable;
148 std::shared_ptr<Math::CylindricalTransformationParameters> m_transform_params;
149};
150
151} /* namespace Observables */
152} /* namespace ScriptInterface */
153
154#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::CylindricalLBProfileObservable > cylindrical_profile_observable() const
Variant do_call_method(std::string const &method, VariantMap const &parameters) override
Base class for script interfaces to core observables classes.
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