59#ifdef ESPRESSO_CALIPER
63#include <Cabana_Core.hpp>
115#ifdef ESPRESSO_VIRTUAL_SITES_INERTIALESS_TRACERS
120#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
132 if (force_cap > 0.) {
133 auto const force_cap_sq =
Utils::sqr(force_cap);
135 [&force_cap, &force_cap_sq](
Particle &p) {
136 auto const force_sq = p.
force().norm2();
137 if (force_sq > force_cap_sq) {
138 p.
force() *= force_cap / std::sqrt(force_sq);
144#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
171 auto const &elc_kernel,
auto const &coulomb_kernel,
172 auto const &dipoles_kernel,
auto const &coulomb_u_kernel) {
177#ifdef ESPRESSO_ROTATION
180#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
199#ifdef ESPRESSO_ROTATION
202#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
215template <
bool HasCoulomb>
221#ifdef ESPRESSO_ELECTROSTATICS
231 std::size_t
const n) {
236 verlet_list.neighbors,
239#ifdef ESPRESSO_ELECTROSTATICS
248 Kokkos::parallel_for(
"specialized_nonbonded_pairs",
249 Kokkos::RangePolicy<Kokkos::DefaultHostExecutionSpace>(
265 [[maybe_unused]]
auto const &elc_kernel,
auto const &coulomb_kernel,
266 [[maybe_unused]]
auto const &dipoles_kernel) {
270 if (virial !=
nullptr)
273#ifdef ESPRESSO_DIPOLES
274 if (
get_ptr(dipoles_kernel) !=
nullptr)
277#ifdef ESPRESSO_ELECTROSTATICS
278 if (
get_ptr(elc_kernel) !=
nullptr)
287 if ((nonbonded_ias.combined_active_pair_mask() &
292 if (nonbonded_ias.any_thole_configured())
296 auto const &aosoa = cell_structure.get_aosoa();
297#ifdef ESPRESSO_EXCLUSIONS
302 if (aosoa.has_any_exclusion())
306 auto scatter_force = cell_structure.get_scatter_force();
310#ifdef ESPRESSO_ELECTROSTATICS
311 if (
auto const *coulomb_ptr =
get_ptr(coulomb_kernel);
312 coulomb_ptr !=
nullptr) {
314 nonbonded_ias, aosoa, scatter_force, minimum_image, max_cutoff_sq,
323 static_cast<void>(coulomb_kernel);
327 nonbonded_ias, aosoa, scatter_force, minimum_image, max_cutoff_sq);
332#ifdef ESPRESSO_CALIPER
339 Kokkos::Experimental::contribute(local_force, scatter_force);
340#ifdef ESPRESSO_ROTATION
348 Kokkos::Experimental::contribute(local_torque, scatter_torque);
351#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
354 if (reduce_dip_fld) {
356 Kokkos::Experimental::contribute(local_dip_fld, scatter_dip_fld);
363 Kokkos::Experimental::contribute(local_virial, scatter_virial);
367 using execution_space = Kokkos::DefaultHostExecutionSpace;
368 Kokkos::RangePolicy<execution_space> policy(std::size_t{0},
369 unique_particles.size());
370 Kokkos::parallel_for(
"reduction", policy,
372#ifdef ESPRESSO_ROTATION
373 &local_torque, reduce_torque,
375#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
376 &local_dip_fld, reduce_dip_fld,
378 &unique_particles](std::size_t
const i) {
380 force[0] += local_force(i, 0);
381 force[1] += local_force(i, 1);
382 force[2] += local_force(i, 2);
383 unique_particles.at(i)->force() += force;
384#ifdef ESPRESSO_ROTATION
388 torque[0] += local_torque(i, 0);
389 torque[1] += local_torque(i, 1);
390 torque[2] += local_torque(i, 2);
391 unique_particles.at(i)->torque() += torque;
394#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
395 if (reduce_dip_fld) {
397 dip_fld[0] += local_dip_fld(i, 0);
398 dip_fld[1] += local_dip_fld(i, 1);
399 dip_fld[2] += local_dip_fld(i, 2);
400 unique_particles.at(i)->dip_fld() += dip_fld;
408 (*virial)[0] += local_virial(0);
409 (*virial)[1] += local_virial(1);
410 (*virial)[2] += local_virial(2);
416#ifdef ESPRESSO_CALIPER
421#ifdef ESPRESSO_CALIPER
425#ifdef ESPRESSO_CALIPER
431#ifdef ESPRESSO_COLLISION_DETECTION
445#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
446 if (
dipoles.impl->solver.has_value()) {
453 auto const elc_kernel =
coulomb.pair_force_elc_kernel();
454 auto const coulomb_kernel =
coulomb.pair_force_kernel();
455 auto const dipoles_kernel =
dipoles.pair_force_kernel();
456 auto const coulomb_u_kernel =
coulomb.pair_energy_kernel();
462 auto const make_verlet_criterion = [&] {
468 collision_detection_cutoff};
472#ifdef ESPRESSO_ELECTROSTATICS
478#ifdef ESPRESSO_CALIPER
481#ifdef ESPRESSO_ELECTROSTATICS
482 coulomb.calc_long_range_force();
484#ifdef ESPRESSO_DIPOLES
485 dipoles.calc_long_range_force();
487#ifdef ESPRESSO_CALIPER
491#ifdef ESPRESSO_CALIPER
497 bonds_kernel_data, bs.pair_list, bs.pair_ids,
get_ptr(coulomb_kernel)};
498 auto angle_bonds_kernel =
500 auto dihedral_bonds_kernel =
503 auto first_neighbor_kernel =
505 dipoles_kernel, coulomb_u_kernel);
508 *
this, virial, elc_kernel, coulomb_kernel, dipoles_kernel);
518 [[maybe_unused]]
auto const generic_pair_path =
520 (not specialized_pair_loop or
523#ifdef ESPRESSO_ROTATION
528 auto const dipolar_pair_kernel_active =
529#ifdef ESPRESSO_DIPOLES
530 get_ptr(dipoles_kernel) !=
nullptr;
534 if (generic_pair_path and (
gay_berne_active or dipolar_pair_kernel_active)) {
536#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
546 auto const have_bonds =
cell_structure->get_local_pair_bond_numbers() > 0 or
549 if (generic_pair_path or
550 (
bonded_ias->maximal_cutoff() >= 0. and have_bonds)) {
556 dihedral_bonds_kernel, first_neighbor_kernel,
558 bonded_ias->maximal_cutoff(), make_verlet_criterion,
564#ifdef ESPRESSO_COLLISION_DETECTION
571 auto const verlet_criterion = make_verlet_criterion();
572 cell_structure->non_bonded_loop(collision_kernel, verlet_criterion);
576#ifdef ESPRESSO_CALIPER
588#ifdef ESPRESSO_CALIPER
592#ifdef ESPRESSO_CALIPER
599#ifdef ESPRESSO_CALIPER
604#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
608#ifdef ESPRESSO_CALIPER
614#ifdef ESPRESSO_VIRTUAL_SITES_RELATIVE
621#ifdef ESPRESSO_VIRTUAL_SITES_CENTER_OF_MASS
633 assert(
comfixed->get_fixed_types().empty() &&
634 "ghost_reduce_overlap: comfixed must be inactive on the eligible "
637 "ghost_reduce_overlap: force_cap must be 0 on the eligible path");
642#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
643 if (
dipoles.impl->solver.has_value()) {
@ INTEG_METHOD_STEEPEST_DESCENT
@ INTEG_METHOD_SYMPLECTIC_EULER
Vector implementation and trait types for boost qvm interoperability.
Zero-overhead Caliper guards for the inactive (no CALI_CONFIG) case.
#define ESPRESSO_CALI_MARK_END(name)
Guarded CALI_MARK_END — no-op when inactive.
#define ESPRESSO_CALI_MARK_BEGIN(name)
Guarded CALI_MARK_BEGIN — no-op when inactive.
#define ESPRESSO_CALI_MARK_FUNCTION
Guarded drop-in replacement for CALI_CXX_MARK_FUNCTION.
This file contains everything related to the global cell structure / cell system.
std::unordered_map< int, std::shared_ptr< BreakageSpec > > breakage_specs
Bond breakage specifications.
auto cuboid_minimum_image() const
Cuboid minimum-image fold parameters for hoisting into kernels.
Describes a cell structure / cell system.
void for_each_local_particle(ParticleCallback auto &&f, bool parallel=true) const
Run a kernel on all local particles.
auto get_scatter_virial()
auto & get_local_torque()
auto & get_local_virial()
auto const & get_unique_particles() const
auto dip_fld_replicas_dirty() const
Kokkos::Experimental::ScatterView< double *[3], Kokkos::LayoutRight, memory_space > ScatterForce
CustomVerletList< memory_space, ListAlgorithm, Cabana::VerletLayout2D, Cabana::TeamVectorOpTag > ListType
auto get_scatter_dip_fld()
auto virial_replicas_dirty() const
auto torque_replicas_dirty() const
auto get_scatter_torque()
auto & get_local_dip_fld()
std::vector< int > get_fixed_types() const
Cuboid minimum-image fold parameters for hot pair loops.
double get_interaction_range() const
Get the interaction range.
double maximal_cutoff() const
Calculate the maximal cutoff of all interactions.
std::shared_ptr< BondedInteractionsMap > bonded_ias
std::shared_ptr< ImmersedBoundaries > immersed_boundaries
std::shared_ptr< ComFixed > comfixed
std::shared_ptr< BondBreakage::BondBreakage > bond_breakage
std::shared_ptr< CollisionDetection::CollisionDetection > collision_detection
std::shared_ptr< InstantaneousPressure > npt_inst_pressure
std::shared_ptr< OifGlobal > oif_global
double force_cap
Molecular dynamics integrator force capping.
void calculate_forces()
Calculate all forces.
std::shared_ptr< Propagation > propagation
void update_icc_particles()
std::shared_ptr< GpuParticleData > gpu
std::shared_ptr< Thermostat::Thermostat > thermostat
void lb_couple_particles()
Calculate particle-lattice interactions.
Utils::Vector3d * get_npt_virial() const
unsigned get_force_reduce_ghost_flags() const
Returns the ghost flags for the force-reduce step.
std::shared_ptr< CellStructure > cell_structure
std::shared_ptr< Constraints::Constraints > constraints
auto get_force_cap() const
Get force_cap.
auto get_sim_time() const
Get sim_time.
std::shared_ptr< BoxGeometry > box_geo
std::shared_ptr< InteractionsNonBonded > nonbonded_ias
Returns true if the particles are to be considered for short range interactions.
void vs_com_back_transfer_forces_and_torques(CellStructure &cell_structure)
boost::mpi::communicator comm_cart
The communicator.
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)
This file contains the asynchronous MPI communication.
Implementation in thermostat.cpp.
static BondsKernelData create_kokkos_bonds_kernel_data(System::System const &system)
static ShortRangeVerletPairLoop create_specialized_verlet_pair_loop(System::System const &system, Utils::Vector3d const *virial, auto const &elc_kernel, auto const &coulomb_kernel, auto const &dipoles_kernel)
static void reinit_dip_fld(CellStructure const &cell_structure)
static void force_capping(CellStructure &cell_structure, double force_cap)
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 ShortRangeVerletPairLoop make_specialized_verlet_pair_loop(InteractionsNonBonded const &nonbonded_ias, CellStructure::AoSoA_pack const &aosoa, CellStructure::ScatterForce scatter_force, CuboidMinimumImage const &minimum_image, double const max_cutoff_sq, Coulomb::ShortRangeForceKernel::kernel_type const *coulomb_ptr=nullptr, CoulombP3M const *p3m=nullptr)
static bool ghost_reduce_overlap_eligible(System::System const &system)
Eligibility check for the split-phase ghost force reduction.
static void reduce_cabana_forces_and_torques(System::System const &system, Utils::Vector3d *virial)
CoulombP3M const * get_toplevel_p3m_solver(Coulomb::Solver const &coulomb)
The active P3M solver, or nullptr.
constexpr unsigned specialized_kernel_pair_mask
Pair potentials fully handled by SpecializedForcesKernel, i.e.
void init_forces_and_thermostat(System::System const &system)
Combined force initialization and Langevin noise application.
Ghost particles and particle exchange.
@ GHOSTTRANS_TORQUE
transfer torque (reduced with force; runtime-conditional)
ICC is a method that allows to take into account the influence of arbitrarily shaped dielectric inter...
@ 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.
std::function< void(CellStructure::ListType const &, std::size_t)> ShortRangeVerletPairLoop
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 &make_verlet_criterion, auto const integ_switch, ShortRangeVerletPairLoop const &verlet_pair_loop={})
ESPRESSO_ATTR_ALWAYS_INLINE KOKKOS_INLINE_FUNCTION bool gay_berne_active(double dist, IA_parameters const &ia_params)
void update_verlet_state(System::System const &system, double const collision_cut)
Solver::ShortRangeForceKernel kernel_type
std::unique_ptr< Implementation > impl
Pointer-to-implementation.
Distance vector and length handed to pair kernels.
Struct holding all information for one particle.
constexpr auto const & dip_fld() const
constexpr auto const & force() const
Own-the-loop specialization of the non-bonded pair kernel.