24#ifdef ESPRESSO_BOND_CONSTRAINT
39#include <boost/mpi/collectives/all_reduce.hpp>
40#include <boost/range/algorithm.hpp>
53 static constexpr char const *
const msg =
" failed to converge after ";
69 boost::for_each(particles,
save_pos);
70 boost::for_each(ghost_particles,
save_pos);
81 auto reset_force = [](
Particle &p) { p.rattle_params().correction.fill(0); };
83 boost::for_each(particles, reset_force);
84 boost::for_each(ghost_particles, reset_force);
102 std::vector<Utils::Vector9d> &rigid_bond_virial) {
126 rigid_bond_virial[
static_cast<std::size_t
>(bond_id)] +=
Utils::flatten(
144template <
typename Kernel>
149 bool correction =
false;
150 cs.
bond_loop([&correction, &kernel, &box_geo, &bonded_ias](
152 auto const &
iaparams = *bonded_ias.
at(bond_id);
154 if (
auto const *
bond = std::get_if<RigidBond>(&
iaparams)) {
173 boost::for_each(particles, [](
Particle &p) {
196 cs, box_geo, bonded_ias,
257 boost::for_each(particles,
272 cs, box_geo, bonded_ias,
Vector implementation and trait types for boost qvm interoperability.
Data structures for bonded interactions.
container for bonded interactions.
mapped_type const & at(key_type const &key) const
std::vector< Utils::Vector9d > rigid_bond_virial
Per-bond-type RATTLE constraint virial.
DEVICE_QUALIFIER auto get_next_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.
static DEVICE_QUALIFIER constexpr Vector< T, N > broadcast(typename Base::value_type const &value) noexcept
Create a vector that has all entries set to the same value.
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()
Matrix implementation and trait types for boost qvm interoperability.
@ DATA_PART_MOMENTUM
Particle::m.
@ DATA_PART_PROPERTIES
Particle::p.
@ DATA_PART_POSITION
Particle::r.
void flatten(Range const &v, OutputIterator out)
Flatten a range of ranges.
Matrix< T, N, M > tensor_product(const Vector< T, N > &x, const Vector< T, M > &y)
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
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.
void correct_position_shake(CellStructure &cs, BoxGeometry const &box_geo, BondedInteractionsMap &bonded_ias)
Propagate velocity and position while using SHAKE algorithm for bond constraint.
static bool calculate_positional_correction(RigidBond const &ia_params, BoxGeometry const &box_geo, Particle &p1, Particle &p2, int bond_id, std::vector< Utils::Vector9d > &rigid_bond_virial)
Calculate the positional 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.
Definition of the rigid bond data type for the Rattle algorithm.
Struct holding all information for one particle.
constexpr auto const & pos() const
constexpr auto const & rattle_params() const
constexpr auto const & v() const
Parameters for the rigid_bond/SHAKE/RATTLE ALGORITHM.