31#include "collision_detection/CollisionDetection.hpp"
33#include "constraints/Constraints.hpp"
36#include "galilei/ComFixed.hpp"
48#include "system/System.hpp"
57#ifdef ESPRESSO_CALIPER
58#include <caliper/cali.h>
61#include <Cabana_Core.hpp>
74#ifdef ESPRESSO_EXTERNAL_FORCES
76#ifdef ESPRESSO_ROTATION
94#ifdef ESPRESSO_CALIPER
98 auto &cell_structure = *
system.cell_structure;
99 auto const &propagation = *
system.propagation;
100 auto const &thermostat = *
system.thermostat;
101 auto const kT = thermostat.kT;
102 auto const time_step =
system.get_time_step();
106 thermostat.langevin &&
107 (propagation.used_propagations &
111 cell_structure.for_each_local_particle([&](
Particle &p) {
117 auto const &langevin = *thermostat.langevin;
120#ifdef ESPRESSO_ROTATION
127 cell_structure.reset_local_force_and_torque();
130 cell_structure.ghosts_reset_forces();
134 if (force_cap > 0.) {
146#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
159 auto const &aosoa =
system.cell_structure->get_aosoa();
173 auto const &elc_kernel,
auto const &coulomb_kernel,
174 auto const &dipoles_kernel,
auto const &coulomb_u_kernel) {
176 auto const &unique_particles =
system.cell_structure->get_unique_particles();
179#ifdef ESPRESSO_ROTATION
185 auto const &aosoa =
system.cell_structure->get_aosoa();
198#ifdef ESPRESSO_ROTATION
212 auto const &unique_particles =
system.cell_structure->get_unique_particles();
213 auto &local_force =
system.cell_structure->get_local_force();
215 Kokkos::Experimental::contribute(local_force,
scatter_force);
216#ifdef ESPRESSO_ROTATION
217 auto &local_torque =
system.cell_structure->get_local_torque();
222 auto &local_virial =
system.cell_structure->get_local_virial();
228 Kokkos::RangePolicy<execution_space> policy(std::size_t{0},
229 unique_particles.size());
230 Kokkos::parallel_for(
"reduction", policy,
235 &unique_particles](std::size_t
const i) {
237#ifdef ESPRESSO_ROTATION
240 force[0] += local_force(i, 0);
241 force[1] += local_force(i, 1);
242 force[2] += local_force(i, 2);
243#ifdef ESPRESSO_ROTATION
244 torque[0] += local_torque(i, 0);
245 torque[1] += local_torque(i, 1);
246 torque[2] += local_torque(i, 2);
248 unique_particles.at(i)->force() += force;
249#ifdef ESPRESSO_ROTATION
250 unique_particles.at(i)->torque() += torque;
257 (*virial)[0] += local_virial(0);
258 (*virial)[1] += local_virial(1);
259 (*virial)[2] += local_virial(2);
265#ifdef ESPRESSO_CALIPER
270#ifdef ESPRESSO_CALIPER
274#ifdef ESPRESSO_CALIPER
280#ifdef ESPRESSO_COLLISION_DETECTION
281 collision_detection->clear_queue();
286 bond_breakage->clear_queue();
287 auto particles = cell_structure->local_particles();
294#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
301 auto const elc_kernel = coulomb.pair_force_elc_kernel();
302 auto const coulomb_kernel = coulomb.pair_force_kernel();
303 auto const dipoles_kernel = dipoles.pair_force_kernel();
304 auto const coulomb_u_kernel = coulomb.pair_energy_kernel();
305 auto *
const virial = get_npt_virial();
308 cell_structure->get_verlet_skin(),
309 get_interaction_range(),
315 get_interaction_range(), propagation->integ_switch);
316#ifdef ESPRESSO_ELECTROSTATICS
317 if (coulomb.impl->extension) {
318 update_icc_particles();
322#ifdef ESPRESSO_CALIPER
325#ifdef ESPRESSO_ELECTROSTATICS
326 coulomb.calc_long_range_force();
328#ifdef ESPRESSO_DIPOLES
329 dipoles.calc_long_range_force();
331#ifdef ESPRESSO_CALIPER
335#ifdef ESPRESSO_CALIPER
338 auto &
bs = cell_structure->bond_state();
349 dipoles_kernel, coulomb_u_kernel);
353 *cell_structure, get_interaction_range(),
355 propagation->integ_switch);
360#ifdef ESPRESSO_COLLISION_DETECTION
364 collision_detection.detect_collision(
p1,
p2, d.dist2);
366 if (
not collision_detection->is_off()) {
371#ifdef ESPRESSO_CALIPER
375 constraints->add_forces(particles, get_sim_time());
376 oif_global->calculate_forces();
379 immersed_boundaries->volume_conservation(*cell_structure);
381 if (thermostat->lb
and (propagation->used_propagations &
383#ifdef ESPRESSO_CALIPER
386 lb_couple_particles();
387#ifdef ESPRESSO_CALIPER
394#ifdef ESPRESSO_CALIPER
397 gpu->copy_forces_to_host(particles,
this_node);
399#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
400 gpu->copy_dip_fld_to_host(particles,
this_node);
403#ifdef ESPRESSO_CALIPER
409#ifdef ESPRESSO_VIRTUAL_SITES_RELATIVE
410 if (propagation->used_propagations &
416#ifdef ESPRESSO_VIRTUAL_SITES_CENTER_OF_MASS
417 if (propagation->used_propagations &
424 cell_structure->ghosts_reduce_forces();
427 comfixed->apply(particles);
433 propagation->recalc_forces =
false;
Vector implementation and trait types for boost qvm interoperability.
This file contains everything related to the global cell structure / cell system.
double maximal_cutoff() const
Calculate the maximal cutoff of bonded interactions, required to determine the cell size for communic...
Describes a cell structure / cell system.
void for_each_local_particle(Callable &&f, bool parallel=true) const
Run a kernel on all local particles.
void calculate_forces()
Calculate all forces.
Returns true if the particles are to be considered for short range interactions.
void vs_com_back_transfer_forces_and_torques(CellStructure &cell_structure)
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
int this_node
The number of this node.
constexpr double inactive_cutoff
Special cutoff value for an inactive interaction.
const T * get_ptr(std::optional< T > const &opt)
static BondsKernelData create_kokkos_bonds_kernel_data(System::System const &system)
static void reinit_dip_fld(CellStructure const &cell_structure)
static void force_capping(CellStructure &cell_structure, double force_cap)
static void init_forces_and_thermostat(System::System const &system)
Combined force initialization and Langevin noise application.
static ParticleForce external_force(Particle const &p)
External particle forces.
static ForcesKernel create_cabana_neighbor_kernel(System::System const &system, Utils::Vector3d *virial, auto const &elc_kernel, auto const &coulomb_kernel, auto const &dipoles_kernel, auto const &coulomb_u_kernel)
static void reduce_cabana_forces_and_torques(System::System const &system, Utils::Vector3d *virial)
ICC is a method that allows to take into account the influence of arbitrarily shaped dielectric inter...
Utils::Vector3d friction_thermo_langevin(LangevinThermostat const &langevin, Particle const &p, double time_step, double kT)
Langevin thermostat for particle translational velocities.
Utils::Vector3d friction_thermo_langevin_rotation(LangevinThermostat const &langevin, Particle const &p, double time_step, double kT)
Langevin thermostat for particle angular velocities.
@ TRANS_VS_CENTER_OF_MASS
@ TRANS_LB_MOMENTUM_EXCHANGE
DEVICE_QUALIFIER constexpr T sqr(T x)
Calculates the SQuaRe of x.
Various procedures concerning interactions between particles.
Exports for the NpT code.
void vs_relative_back_transfer_forces_and_torques(CellStructure &cell_structure)
This file contains all subroutines required to process rotational motion.
Utils::Vector3d convert_vector_body_to_space(const Particle &p, const Utils::Vector3d &vec)
ESPRESSO_ATTR_ALWAYS_INLINE void update_cabana_state(CellStructure &cell_structure, auto const &verlet_criterion, double const pair_cutoff, auto const integ_switch)
void cabana_short_range(auto const &pair_bonds_kernel, auto const &angle_bonds_kernel, auto const &dihedral_bonds_kernel, auto const &nonbonded_kernel, CellStructure &cell_structure, double pair_cutoff, double bond_cutoff, auto const &verlet_criterion, auto const integ_switch)
BondedInteractionsMap const & bonded_ias
Distance vector and length handed to pair kernels.
BondedInteractionsMap const & bonded_ias
Force information on a particle.
Utils::Vector3d torque
torque.
Struct holding all information for one particle.
auto const & dip_fld() const
auto const & swimming() const
auto const & force_and_torque() const
auto const & torque() const
auto const & ext_force() const
auto const & ext_torque() const
auto const & force() const
auto calc_director() const