ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
core/cluster_analysis/Cluster.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
20#pragma once
21
22#include "BoxGeometry.hpp"
23#include "Particle.hpp"
24
25#include <utils/Vector.hpp>
26
27#include <algorithm>
28#include <cassert>
29#include <memory>
30#include <utility>
31#include <vector>
32
33namespace ClusterAnalysis {
34
35/** @brief Represents a single cluster of particles */
36class Cluster {
37public:
38 explicit Cluster(std::weak_ptr<BoxGeometry const> const &box_geo)
39 : m_box_geo{box_geo} {}
40 /** @brief Ids of the particles in the cluster */
41 std::vector<int> particles;
42 /** @brief add a particle to the cluster */
43 void add_particle(const Particle &p) { particles.push_back(p.id()); }
44 /** @brief Calculate the center of mass of the cluster */
46 center_of_mass_subcluster(std::vector<int> const &particle_ids);
48 /** @brief Longest distance between any combination of two particles */
49 double longest_distance();
50 /** @brief Calculate radius of gyration of the cluster */
51 double radius_of_gyration();
52 double radius_of_gyration_subcluster(std::vector<int> const &particle_ids);
53 /** @brief Calculate the fractal dimension
54 * N(r) via r^d, where N(r) counts the number of particles in a sphere
55 * of radius n, and d denotes the fractal dimension.
56 * The fitting is done by the Gnu Scientific Library.
57 * @param dr increment for when constructing the discrete version of N(r)
58 *
59 * @return fractal dimension, rms error of the fit */
60 std::pair<double, double> fractal_dimension(double dr);
61
62private:
63 void sanity_checks() const;
64 auto get_box_geo() const {
65 auto ptr = m_box_geo.lock();
66 assert(ptr);
67 return ptr;
68 }
69 mutable std::weak_ptr<BoxGeometry const> m_box_geo;
70};
71
72} // namespace ClusterAnalysis
Vector implementation and trait types for boost qvm interoperability.
Represents a single cluster of particles.
Utils::Vector3d center_of_mass()
Definition Cluster.cpp:46
void add_particle(const Particle &p)
add a particle to the cluster
std::pair< double, double > fractal_dimension(double dr)
Calculate the fractal dimension N(r) via r^d, where N(r) counts the number of particles in a sphere o...
Definition Cluster.cpp:138
Utils::Vector3d center_of_mass_subcluster(std::vector< int > const &particle_ids)
Calculate the center of mass of the cluster.
Definition Cluster.cpp:52
Cluster(std::weak_ptr< BoxGeometry const > const &box_geo)
std::vector< int > particles
Ids of the particles in the cluster.
double longest_distance()
Longest distance between any combination of two particles.
Definition Cluster.cpp:84
double radius_of_gyration()
Calculate radius of gyration of the cluster.
Definition Cluster.cpp:104
double radius_of_gyration_subcluster(std::vector< int > const &particle_ids)
Definition Cluster.cpp:109
Struct holding all information for one particle.
Definition Particle.hpp:395
auto const & id() const
Definition Particle.hpp:414