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
33
namespace
ClusterAnalysis
{
34
35
/** @brief Represents a single cluster of particles */
36
class
Cluster
{
37
public
:
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 */
45
Utils::Vector3d
46
center_of_mass_subcluster
(std::vector<int>
const
&particle_ids);
47
Utils::Vector3d
center_of_mass
();
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
62
private
:
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
BoxGeometry.hpp
Particle.hpp
Vector.hpp
Vector implementation and trait types for boost qvm interoperability.
ClusterAnalysis::Cluster
Represents a single cluster of particles.
Definition
core/cluster_analysis/Cluster.hpp:36
ClusterAnalysis::Cluster::center_of_mass
Utils::Vector3d center_of_mass()
Definition
Cluster.cpp:46
ClusterAnalysis::Cluster::add_particle
void add_particle(const Particle &p)
add a particle to the cluster
Definition
core/cluster_analysis/Cluster.hpp:43
ClusterAnalysis::Cluster::fractal_dimension
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
ClusterAnalysis::Cluster::center_of_mass_subcluster
Utils::Vector3d center_of_mass_subcluster(std::vector< int > const &particle_ids)
Calculate the center of mass of the cluster.
Definition
Cluster.cpp:52
ClusterAnalysis::Cluster::Cluster
Cluster(std::weak_ptr< BoxGeometry const > const &box_geo)
Definition
core/cluster_analysis/Cluster.hpp:38
ClusterAnalysis::Cluster::particles
std::vector< int > particles
Ids of the particles in the cluster.
Definition
core/cluster_analysis/Cluster.hpp:41
ClusterAnalysis::Cluster::longest_distance
double longest_distance()
Longest distance between any combination of two particles.
Definition
Cluster.cpp:84
ClusterAnalysis::Cluster::radius_of_gyration
double radius_of_gyration()
Calculate radius of gyration of the cluster.
Definition
Cluster.cpp:104
ClusterAnalysis::Cluster::radius_of_gyration_subcluster
double radius_of_gyration_subcluster(std::vector< int > const &particle_ids)
Definition
Cluster.cpp:109
Utils::Vector
Definition
Vector.hpp:48
ClusterAnalysis
Definition
Cluster.cpp:43
Particle
Struct holding all information for one particle.
Definition
Particle.hpp:395
Particle::id
auto const & id() const
Definition
Particle.hpp:414
src
core
cluster_analysis
Cluster.hpp
Generated on Thu Dec 19 2024 02:13:16 for ESPResSo by
1.9.8