Loading [MathJax]/extensions/TeX/AMSmath.js
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
CylindricalVelocityProfile.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_CYLINDRICALVELOCITYPROFILE_HPP
20#define OBSERVABLES_CYLINDRICALVELOCITYPROFILE_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 <vector>
32
33namespace Observables {
35public:
37
38 std::vector<double>
39 evaluate(boost::mpi::communicator const &comm,
40 ParticleReferenceRange const &local_particles,
41 const ParticleObservables::traits<Particle> &traits) const override {
42 using pos_type = Utils::Vector3d;
43 using vel_type = Utils::Vector3d;
44 auto const &box_geo = *System::get_system().box_geo;
45
46 std::vector<pos_type> local_folded_positions{};
47 std::vector<vel_type> local_velocities{};
48 local_folded_positions.reserve(local_particles.size());
49 local_velocities.reserve(local_particles.size());
50
51 for (auto const &p : local_particles) {
52 auto const pos = box_geo.folded_position(traits.position(p)) -
53 transform_params->center();
54 local_folded_positions.emplace_back(
56 pos, transform_params->axis(), transform_params->orientation()));
57 local_velocities.emplace_back(
59 traits.velocity(p), transform_params->axis(), pos));
60 }
61
62 auto const [global_folded_positions, global_velocities] =
63 detail::gather(comm, local_folded_positions, local_velocities);
64
65 if (comm.rank() != 0) {
66 return {};
67 }
68
70 detail::accumulate(histogram, global_folded_positions, global_velocities);
71 return detail::normalize_by_bin_size(histogram);
72 }
73
74 std::vector<std::size_t> shape() const override {
75 auto const b = n_bins();
76 return {b[0], b[1], b[2], 3};
77 }
78};
79
80} // Namespace Observables
81
82#endif
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::vector< std::size_t > shape() const override
std::vector< double > evaluate(boost::mpi::communicator const &comm, ParticleReferenceRange const &local_particles, const ParticleObservables::traits< Particle > &traits) const override
std::shared_ptr< BoxGeometry > box_geo
Histogram in cylindrical coordinates.
Convert coordinates from the Cartesian system to the cylindrical system.
std::vector< std::reference_wrapper< Particle const > > ParticleReferenceRange
System & get_system()
VectorXd< 3 > Vector3d
Definition Vector.hpp:165
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.