ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
collision.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2011-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 "config/config.hpp"
23
25
26#include "BondList.hpp"
27#include "Particle.hpp"
28
29/** @brief Protocols for collision handling. */
30enum class CollisionModeType : int {
31 /** @brief Deactivate collision detection. */
32 OFF = 0,
33 /** @brief Create bond between centers of colliding particles. */
34 BIND_CENTERS = 1,
35 /**
36 * @brief Create a bond between the centers of the colliding particles,
37 * plus two virtual sites at the point of collision and bind them
38 * together. This prevents the particles from sliding against each
39 * other. Requires VIRTUAL_SITES_RELATIVE.
40 */
41 BIND_VS = 2,
42 /** @brief Glue a particle to a specific spot on another particle. */
43 GLUE_TO_SURF = 3,
44 /** @brief Three particle binding mode. */
46};
47
49public:
53
54 /// collision protocol
56 /// distance at which particles are bound
57 double distance;
58 // Square of distance at which particle are bound
59 double distance2;
60
61 /// bond type used between centers of colliding particles
63 /// bond type used between virtual sites
65 /// particle type for virtual sites created on collision
67
68 /// For mode "glue to surface": The distance from the particle which is to be
69 /// glued to the new virtual site
71 /// For mode "glue to surface": The particle type being glued
73 /// For mode "glue to surface": The particle type to which the virtual site is
74 /// attached
76 /// Particle type to which the newly glued particle is converted
78 /// First bond type (for zero degrees) used for the three-particle bond
79 /// (angle potential)
81 /// Number of angle bonds to use (angular resolution)
82 /// different angle bonds with different equilibrium angles
83 /// Are expected to have ids immediately following to bond_three_particles
85 /** Placement of virtual sites for MODE_VS.
86 * 0=on same particle as related to,
87 * 1=on collision partner,
88 * 0.5=in the middle between
89 */
91
92 /** @brief Validates parameters and creates particle types if needed. */
93 void initialize();
94};
95
96/// Parameters for collision detection
98
99#ifdef COLLISION_DETECTION
100
102
103/// Handle the collisions recorded in the queue
104void handle_collisions(CellStructure &cell_structure);
105
106/** @brief Add the collision between the given particle ids to the collision
107 * queue
108 */
109void queue_collision(int part1, int part2);
110
111/** @brief Check additional criteria for the glue_to_surface collision mode */
118
119/** @brief Detect (and queue) a collision between the given particles. */
120inline void detect_collision(Particle const &p1, Particle const &p2,
121 double const dist2) {
122 if (dist2 > collision_params.distance2)
123 return;
124
125 // If we are in the glue to surface mode, check that the particles
126 // are of the right type
128 if (!glue_to_surface_criterion(p1, p2))
129 return;
130
131 // Ignore virtual particles
132 if (p1.is_virtual() or p2.is_virtual())
133 return;
134
135 // Check, if there's already a bond between the particles
137 return;
138
140 return;
141
142 /* If we're still here, there is no previous bond between the particles,
143 we have a new collision */
144
145 // do not create bond between ghost particles
146 if (p1.is_ghost() and p2.is_ghost()) {
147 return;
148 }
149 queue_collision(p1.id(), p2.id());
150}
151
152#endif // COLLISION_DETECTION
153
155#ifdef COLLISION_DETECTION
158#endif
159 return -1.;
160}
bool pair_bond_exists_on(BondList const &bonds, int partner_id, int bond_id)
Check if there is a specific bond in a bond list.
Definition BondList.hpp:239
int part_type_after_glueing
Particle type to which the newly glued particle is converted.
Definition collision.hpp:77
void initialize()
Validates parameters and creates particle types if needed.
int part_type_to_be_glued
For mode "glue to surface": The particle type being glued.
Definition collision.hpp:72
double vs_placement
Placement of virtual sites for MODE_VS.
Definition collision.hpp:90
int bond_centers
bond type used between centers of colliding particles
Definition collision.hpp:62
CollisionModeType mode
collision protocol
Definition collision.hpp:55
int three_particle_angle_resolution
Number of angle bonds to use (angular resolution) different angle bonds with different equilibrium an...
Definition collision.hpp:84
int part_type_to_attach_vs_to
For mode "glue to surface": The particle type to which the virtual site is attached.
Definition collision.hpp:75
double dist_glued_part_to_vs
For mode "glue to surface": The distance from the particle which is to be glued to the new virtual si...
Definition collision.hpp:70
int bond_three_particles
First bond type (for zero degrees) used for the three-particle bond (angle potential)
Definition collision.hpp:80
double distance
distance at which particles are bound
Definition collision.hpp:57
int bond_vs
bond type used between virtual sites
Definition collision.hpp:64
int vs_particle_type
particle type for virtual sites created on collision
Definition collision.hpp:66
bool glue_to_surface_criterion(Particle const &p1, Particle const &p2)
Check additional criteria for the glue_to_surface collision mode.
void prepare_local_collision_queue()
CollisionModeType
Protocols for collision handling.
Definition collision.hpp:30
@ BIND_CENTERS
Create bond between centers of colliding particles.
@ GLUE_TO_SURF
Glue a particle to a specific spot on another particle.
@ OFF
Deactivate collision detection.
@ BIND_THREE_PARTICLES
Three particle binding mode.
@ BIND_VS
Create a bond between the centers of the colliding particles, plus two virtual sites at the point of ...
double collision_detection_cutoff()
void queue_collision(int part1, int part2)
Add the collision between the given particle ids to the collision queue.
void detect_collision(Particle const &p1, Particle const &p2, double const dist2)
Detect (and queue) a collision between the given particles.
void handle_collisions(CellStructure &cell_structure)
Handle the collisions recorded in the queue.
Collision_parameters collision_params
Parameters for collision detection.
Definition collision.cpp:73
This file contains the defaults for ESPResSo.
Describes a cell structure / cell system.
Struct holding all information for one particle.
Definition Particle.hpp:393
auto is_virtual() const
Definition Particle.hpp:516
auto const & type() const
Definition Particle.hpp:416
auto const & bonds() const
Definition Particle.hpp:426
bool is_ghost() const
Definition Particle.hpp:438
auto const & id() const
Definition Particle.hpp:412