24#ifdef ESPRESSO_BOND_CONSTRAINT
35#include <boost/mpi/collectives/all_reduce.hpp>
36#include <boost/range/algorithm.hpp>
47 static constexpr char const *
const msg =
" failed to converge after ";
63 boost::for_each(particles,
save_pos);
64 boost::for_each(ghost_particles,
save_pos);
75 auto reset_force = [](
Particle &p) { p.rattle_params().correction.fill(0); };
77 boost::for_each(particles, reset_force);
78 boost::for_each(ghost_particles, reset_force);
122template <
typename Kernel>
127 bool correction =
false;
128 cs.
bond_loop([&correction, &kernel, &box_geo, &bonded_ias](
130 auto const &
iaparams = *bonded_ias.
at(bond_id);
132 if (
auto const *
bond = std::get_if<RigidBond>(&
iaparams)) {
151 boost::for_each(particles, [](
Particle &p) {
225 boost::for_each(particles,
Data structures for bonded interactions.
container for bonded interactions.
mapped_type const & at(key_type const &key) const
ESPRESSO_ATTR_ALWAYS_INLINE Utils::Vector3< T > get_mi_vector(Utils::Vector3< T > const &a, Utils::Vector3< T > const &b) const
Get the minimum-image vector between two coordinates.
Describes a cell structure / cell system.
ParticleRange ghost_particles() const
void update_ghosts_and_resort_particle(unsigned data_parts)
Update ghost particles, with particle resort if needed.
void ghosts_update(unsigned data_parts)
Update ghost particles.
bool check_resort_required(Utils::Vector3d const &additional_offset={}) const
Check whether a particle has moved further than half the skin since the last Verlet list update,...
void bond_loop(BondKernel const &bond_kernel)
Bonded pair loop.
void set_resort_particles(Cells::Resort level)
Increase the local resort level at least to level.
ParticleRange local_particles() const
void ghosts_reduce_rattle_correction()
Add rattle corrections from ghost particles to real particles.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
boost::mpi::communicator comm_cart
The communicator.
This file contains the errorhandling code for severe errors, like a broken bond or illegal parameter ...
#define runtimeErrorMsg()
@ DATA_PART_MOMENTUM
Particle::m.
@ DATA_PART_PROPERTIES
Particle::p.
@ DATA_PART_POSITION
Particle::r.
void correct_velocity_shake(CellStructure &cs, BoxGeometry const &box_geo, BondedInteractionsMap const &bonded_ias)
Correction of current velocities using RATTLE algorithm.
void save_old_position(const ParticleRange &particles, const ParticleRange &ghost_particles)
copy current position
void correct_position_shake(CellStructure &cs, BoxGeometry const &box_geo, BondedInteractionsMap const &bonded_ias)
Propagate velocity and position while using SHAKE algorithm for bond constraint.
static constexpr auto shake_max_iterations
Maximal number of iterations before the RATTLE algorithm bails out.
static void init_correction_vector(const ParticleRange &particles, const ParticleRange &ghost_particles)
reset correction vectors to zero
static void apply_positional_correction(const ParticleRange &particles)
Apply positional corrections.
static bool calculate_velocity_correction(RigidBond const &ia_params, BoxGeometry const &box_geo, Particle &p1, Particle &p2)
Calculate the velocity correction for the particles.
static void check_convergence(int cnt, char const *const name)
static void apply_velocity_correction(ParticleRange const &particles)
Apply velocity corrections.
static bool compute_correction_vector(CellStructure &cs, BoxGeometry const &box_geo, BondedInteractionsMap const &bonded_ias, Kernel kernel)
Compute the correction vectors using given kernel.
static bool calculate_positional_correction(RigidBond const &ia_params, BoxGeometry const &box_geo, Particle &p1, Particle &p2)
Calculate the positional correction for the particles.
Definition of the rigid bond data type for the Rattle algorithm.
Struct holding all information for one particle.
auto const & rattle_params() const
Parameters for the rigid_bond/SHAKE/RATTLE ALGORITHM.