40#include "galilei/ComFixed.hpp"
50#include "system/System.hpp"
56#include <boost/variant.hpp>
59#include <caliper/cali.h>
92 CALI_CXX_MARK_FUNCTION;
95 for (
auto &p : particles) {
103 for (
auto &p : particles) {
104 p.force_and_torque() = {};
109 if (force_cap > 0.) {
110 auto const force_cap_sq =
Utils::sqr(force_cap);
111 for (
auto &p : particles) {
112 auto const force_sq = p.force().norm2();
113 if (force_sq > force_cap_sq) {
114 p.force() *= force_cap / std::sqrt(force_sq);
122 CALI_CXX_MARK_FUNCTION;
126 CALI_MARK_BEGIN(
"copy_particles_to_GPU");
130 CALI_MARK_END(
"copy_particles_to_GPU");
134#ifdef COLLISION_DETECTION
137 bond_breakage->clear_queue();
138 auto particles = cell_structure->local_particles();
139 auto ghost_particles = cell_structure->ghost_particles();
141 if (coulomb.impl->extension) {
142 if (
auto icc = std::get_if<std::shared_ptr<ICCStar>>(
143 get_ptr(coulomb.impl->extension))) {
144 (**icc).iteration(*cell_structure, particles, ghost_particles);
152 thermostat_force_init();
156 auto const elc_kernel = coulomb.pair_force_elc_kernel();
157 auto const coulomb_kernel = coulomb.pair_force_kernel();
158 auto const dipoles_kernel = dipoles.pair_force_kernel();
161 auto const coulomb_cutoff = coulomb.cutoff();
167 auto const dipole_cutoff = dipoles.cutoff();
173 [coulomb_kernel_ptr =
get_ptr(coulomb_kernel),
174 &bond_breakage = *bond_breakage, &box_geo = *box_geo](
179 [coulomb_kernel_ptr =
get_ptr(coulomb_kernel),
180 dipoles_kernel_ptr =
get_ptr(dipoles_kernel),
181 elc_kernel_ptr =
get_ptr(elc_kernel), &nonbonded_ias = *nonbonded_ias,
182 &thermostat = *thermostat,
184 auto const &ia_params =
185 nonbonded_ias.get_ia_param(p1.
type(), p2.type());
187 p1, p2, d.vec21, sqrt(d.dist2), d.dist2, ia_params, thermostat,
188 box_geo, coulomb_kernel_ptr, dipoles_kernel_ptr, elc_kernel_ptr);
189#ifdef COLLISION_DETECTION
196 get_interaction_range(), coulomb_cutoff, dipole_cutoff,
204 auto const area_volume = boost::mpi::all_reduce(
206 auto const oif_part_area = std::abs(area_volume[0]);
207 auto const oif_part_vol = std::abs(area_volume[1]);
208 if (oif_part_area < 1e-100 and oif_part_vol < 1e-100) {
217 if (thermostat->lb and (propagation->used_propagations &
219 lb_couple_particles();
224 CALI_MARK_BEGIN(
"copy_forces_from_GPU");
226 gpu.copy_forces_to_host(particles,
this_node);
228 CALI_MARK_END(
"copy_forces_from_GPU");
232#ifdef VIRTUAL_SITES_RELATIVE
233 if (propagation->used_propagations &
240 cell_structure->ghosts_reduce_forces();
243 comfixed->apply(particles);
249 propagation->recalc_forces =
false;
254 CALI_CXX_MARK_FUNCTION;
double maximal_cutoff_bonded()
Calculate the maximal cutoff of bonded interactions, required to determine the cell size for communic...
This file contains everything related to the global cell structure / cell system.
CollisionModeType mode
collision protocol
void volume_conservation(CellStructure &cs)
Calculate volumes, volume force and add it to each virtual particle.
void calculate_forces()
Calculate all forces.
A stripped-down version of std::span from C++17.
Returns true if the particles are to be considered for short range interactions.
void prepare_local_collision_queue()
Collision_parameters collision_params
Parameters for collision detection.
@ OFF
Deactivate collision detection.
double collision_detection_cutoff()
void detect_collision(Particle const &p1, Particle const &p2, double const dist2)
Detect (and queue) a collision between the given particles.
boost::mpi::communicator comm_cart
The communicator.
int this_node
The number of this node.
const T * get_ptr(std::optional< T > const &opt)
static void init_forces(ParticleRange const &particles, ParticleRange const &ghost_particles)
static void force_capping(ParticleRange const &particles, double force_cap)
void init_forces_ghosts(ParticleRange const &particles)
Set forces of all ghosts to zero.
static ParticleForce external_force(Particle const &p)
External particle forces.
void npt_add_virial_force_contribution(const Utils::Vector3d &force, const Utils::Vector3d &d)
Update the NpT virial.
void calc_long_range_forces(const ParticleRange &particles)
Calculate long range forces (P3M, ...).
bool add_bonded_force(Particle &p1, int bond_id, Utils::Span< Particle * > partners, BondBreakage::BondBreakage &bond_breakage, BoxGeometry const &box_geo, Coulomb::ShortRangeForceKernel::kernel_type const *kernel)
void add_non_bonded_pair_force(Particle &p1, Particle &p2, Utils::Vector3d const &d, double dist, double dist2, IA_parameters const &ia_params, Thermostat::Thermostat const &thermostat, BoxGeometry const &box_geo, Coulomb::ShortRangeForceKernel::kernel_type const *coulomb_kernel, Dipoles::ShortRangeForceKernel::kernel_type const *dipoles_kernel, Coulomb::ShortRangeForceCorrectionsKernel::kernel_type const *elc_kernel)
Calculate non-bonded forces between a pair of particles and update their forces and torques.
ICC is a method that allows to take into account the influence of arbitrarily shaped dielectric inter...
ImmersedBoundaries immersed_boundaries
Constraints< ParticleRange, Constraint > constraints
Solver const & get_coulomb()
Solver const & get_dipoles()
@ TRANS_LB_MOMENTUM_EXCHANGE
DEVICE_QUALIFIER constexpr T sqr(T x)
Calculates the SQuaRe of x.
Various procedures concerning interactions between particles.
constexpr double INACTIVE_CUTOFF
Cutoff for deactivated interactions.
void npt_add_virial_contribution(double energy)
void npt_reset_instantaneous_virials()
reset virial part of instantaneous pressure
Exports for the NpT code.
void add_oif_global_forces(Utils::Vector2d const &area_volume, int molType, BoxGeometry const &box_geo, CellStructure &cs)
Distribute the OIF global forces to all particles in the mesh.
Utils::Vector2d calc_oif_global(int molType, BoxGeometry const &box_geo, CellStructure &cs)
Calculate the OIF global force.
P3M electrostatics on GPU.
void vs_relative_back_transfer_forces_and_torques(CellStructure &cell_structure)
This file contains all subroutines required to process rotational motion.
void short_range_loop(BondKernel bond_kernel, PairKernel pair_kernel, CellStructure &cell_structure, double pair_cutoff, double bond_cutoff, VerletCriterion const &verlet_criterion={})
void calc_long_range_force(ParticleRange const &particles) const
void calc_long_range_force(ParticleRange const &particles) const
Distance vector and length handed to pair kernels.
Force information on a particle.
Struct holding all information for one particle.
auto const & swimming() const
auto const & ext_force() const
auto const & type() const
auto const & ext_torque() const
auto calc_director() const