ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
CylindricalFluxDensityProfile.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19#ifndef OBSERVABLES_CYLINDRICALFLUXDENSITYPROFILE_HPP
20#define OBSERVABLES_CYLINDRICALFLUXDENSITYPROFILE_HPP
21
22#include "BoxGeometry.hpp"
24#include "system/System.hpp"
25#include "utils_histogram.hpp"
26
27#include <utils/Histogram.hpp>
29
30#include <cstddef>
31#include <utility>
32#include <vector>
33
34namespace Observables {
36public:
38
39 std::vector<double>
40 evaluate(boost::mpi::communicator const &comm,
41 ParticleReferenceRange const &local_particles,
42 const ParticleObservables::traits<Particle> &traits) const override {
43 using pos_type = decltype(traits.position(std::declval<Particle>()));
44 using vel_type = decltype(traits.velocity(std::declval<Particle>()));
45 auto const &box_geo = *System::get_system().box_geo;
46
47 std::vector<pos_type> local_folded_positions{};
48 local_folded_positions.reserve(local_particles.size());
49 std::vector<vel_type> local_velocities{};
50 local_velocities.reserve(local_particles.size());
51
52 for (auto const &p : local_particles) {
53 auto const pos = box_geo.folded_position(traits.position(p)) -
54 transform_params->center();
55
56 local_folded_positions.emplace_back(
58 pos, transform_params->axis(), transform_params->orientation()));
59 local_velocities.emplace_back(
61 traits.velocity(p), transform_params->axis(), pos));
62 }
63
64 auto const [global_folded_positions, global_velocities] =
65 detail::gather(comm, local_folded_positions, local_velocities);
66
67 if (comm.rank() != 0) {
68 return {};
69 }
70
72 detail::accumulate(histogram, global_folded_positions, global_velocities);
73 histogram.normalize();
74 return histogram.get_histogram();
75 }
76 std::vector<std::size_t> shape() const override {
77 auto const b = n_bins();
78 return {b[0], b[1], b[2], 3};
79 }
80};
81
82} // Namespace Observables
83
84#endif
std::vector< double > evaluate(boost::mpi::communicator const &comm, ParticleReferenceRange const &local_particles, const ParticleObservables::traits< Particle > &traits) const override
std::vector< std::size_t > shape() const override
CylindricalPidProfileObservable(std::vector< int > const &ids, std::shared_ptr< Utils::CylindricalTransformationParameters > transform_params, int n_r_bins, int n_phi_bins, int n_z_bins, double min_r, double max_r, double min_phi, double max_phi, double min_z, double max_z)
std::shared_ptr< Utils::CylindricalTransformationParameters > transform_params
std::shared_ptr< BoxGeometry > box_geo
Histogram in cylindrical coordinates.
std::vector< T > get_histogram() const
Get the histogram data.
Definition Histogram.hpp:74
Convert coordinates from the Cartesian system to the cylindrical system.
std::vector< std::reference_wrapper< Particle const > > ParticleReferenceRange
System & get_system()
Vector3d transform_vector_cartesian_to_cylinder(Vector3d const &vec, Vector3d const &axis, Vector3d const &pos)
Vector transformation from Cartesian to cylindrical coordinates.
Vector3d transform_coordinate_cartesian_to_cylinder(Vector3d const &pos)
Coordinate transformation from Cartesian to cylindrical coordinates.