30#include <Cabana_Core.hpp>
31#include <Kokkos_ScatterView.hpp>
50#ifdef ESPRESSO_ROTATION
72 std::vector<Particle *>
const &unique_particles_,
74#ifdef ESPRESSO_ROTATION
88#ifdef ESPRESSO_ROTATION
97 if (
auto &solver = coulomb_.
impl->solver; solver.has_value()) {
98 if (std::holds_alternative<std::shared_ptr<CoulombP3M>>(*solver)) {
99 p3m = std::get<std::shared_ptr<CoulombP3M>>(*solver).get();
120 auto const dist_sq = d.norm2();
125 auto const dist = std::sqrt(dist_sq);
126 auto const &ia_params =
132#if defined(ESPRESSO_EXCLUSIONS) or defined(ESPRESSO_THOLE)
133 bool need_particle_pointers =
false;
134#ifdef ESPRESSO_EXCLUSIONS
138 need_particle_pointers |=
144 if (need_particle_pointers) {
154 if (dist <= ia_params.max_cut) {
155#ifdef ESPRESSO_EXCLUSIONS
156 bool skip_non_bonded =
false;
161 constexpr bool skip_non_bonded =
false;
163 if (not skip_non_bonded) {
174#ifdef ESPRESSO_GAY_BERNE
192 virial = hadamard_product(pf.f, d);
214#ifdef ESPRESSO_ELECTROSTATICS
222 if (
p3m) [[likely]] {
227 pf.f += (*coulomb_kernel)(q1q2, d, dist);
232 (*elc_kernel)(pos1, pos2, f1_asym, f2_asym, q1q2);
238 virial[0] += (*coulomb_u_kernel)(pos1, pos2, q1q2, d, dist);
246#ifdef ESPRESSO_DIPOLES
252 pf += (*dipoles_kernel)(d1d2,
aosoa.
dipm(i) * dir1,
259#ifdef ESPRESSO_ELECTROSTATICS
266 access_force(i, 0) += pf.f[0];
267 access_force(i, 1) += pf.f[1];
268 access_force(i, 2) += pf.f[2];
269#ifdef ESPRESSO_ROTATION
271 access_torque(i, 0) += pf.torque[0];
272 access_torque(i, 1) += pf.torque[1];
273 access_torque(i, 2) += pf.torque[2];
276 access_force(j, 0) += opf.f[0];
277 access_force(j, 1) += opf.f[1];
278 access_force(j, 2) += opf.f[2];
279#ifdef ESPRESSO_ROTATION
280 access_torque(j, 0) += opf.torque[0];
281 access_torque(j, 1) += opf.torque[1];
282 access_torque(j, 2) += opf.torque[2];
287 access_virial(0) += virial[0];
288 access_virial(1) += virial[1];
289 access_virial(2) += virial[2];
Vector implementation and trait types for boost qvm interoperability.
#define ESPRESSO_ATTR_ALWAYS_INLINE
container for bonded interactions.
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.
Kokkos::Experimental::ScatterView< double[3], Kokkos::LayoutRight > ScatterVirial
Kokkos::Experimental::ScatterView< double *[3], Kokkos::LayoutRight > ScatterForce
auto & get_ia_param(int i, int j)
Get interaction parameters between particle types i and j.
std::shared_ptr< DPDThermostat > dpd
int thermo_switch
Bitmask of currently active thermostats.
Utils::Vector3d dpd_pair_force(Utils::Vector3d const &p1_position, Utils::Vector3d const &p1_velocity, int p1_id, Utils::Vector3d const &p2_position, Utils::Vector3d const &p2_velocity, int p2_id, DPDThermostat const &dpd, BoxGeometry const &box_geo, IA_parameters const &ia_params, Utils::Vector3d const &d, double dist, double dist2)
bool do_nonbonded(Particle const &p1, Particle const &p2)
Determine if the non-bonded interactions between p1 and p2 should be calculated.
ParticleForce calc_opposing_force(ParticleForce const &pf, Utils::Vector3d const &d)
ESPRESSO_ATTR_ALWAYS_INLINE Utils::Vector3d calc_central_radial_force(IA_parameters const &ia_params, Utils::Vector3d const &d, double const dist)
ParticleForce gb_pair_force(Utils::Vector3d const &ui, Utils::Vector3d const &uj, IA_parameters const &ia_params, Utils::Vector3d const &d, double dist)
Calculate Gay-Berne force and torques.
ESPRESSO_ATTR_ALWAYS_INLINE KOKKOS_INLINE_FUNCTION bool gay_berne_active(double dist, IA_parameters const &ia_params)
KOKKOS_INLINE_FUNCTION bool thole_active(IA_parameters const &ia_params, bool has_coulomb_kernel)
ESPRESSO_ATTR_ALWAYS_INLINE KOKKOS_INLINE_FUNCTION bool dpd_active(IA_parameters const &ia_params, int thermo_switch)
bool has_exclusion(std::size_t i) const
PositionViewType position
Utils::Vector< T, N > get_vector_at(Kokkos::View< T *[N], array_layout, Kokkos::HostSpace > const &view, std::size_t i) const
DirectorViewType director
VelocityViewType velocity
Utils::Vector3d pair_force(double q1q2, Utils::Vector3d const &d, double dist) const
Calculate real-space contribution of p3m Coulomb pair forces.
Solver::ShortRangeEnergyKernel kernel_type
Solver::ShortRangeForceCorrectionsKernel kernel_type
Solver::ShortRangeForceKernel kernel_type
std::unique_ptr< Implementation > impl
Pointer-to-implementation.
Solver::ShortRangeForceKernel kernel_type
std::vector< Particle * > const & unique_particles
CellStructure::ScatterForce local_force
Coulomb::ShortRangeEnergyKernel::kernel_type const *const coulomb_u_kernel
ForcesKernel(BondedInteractionsMap const &bonded_ias_, InteractionsNonBonded const &nonbonded_ias_, Coulomb::ShortRangeForceKernel::kernel_type const *coulomb_kernel_, Dipoles::ShortRangeForceKernel::kernel_type const *dipoles_kernel_, Coulomb::ShortRangeForceCorrectionsKernel::kernel_type const *elc_kernel_, Coulomb::ShortRangeEnergyKernel::kernel_type const *coulomb_u_kernel_, Coulomb::Solver const &coulomb_, Thermostat::Thermostat const &thermostat_, BoxGeometry const &box_geo_, std::vector< Particle * > const &unique_particles_, CellStructure::ScatterForce local_force_, CellStructure::ScatterForce local_torque_, Utils::Vector3d *const global_virial_, CellStructure::ScatterVirial local_virial_, CellStructure::AoSoA_pack const &aosoa_, double system_max_cutoff_)
Coulomb::ShortRangeForceCorrectionsKernel::kernel_type const * elc_kernel
ESPRESSO_ATTR_ALWAYS_INLINE KOKKOS_INLINE_FUNCTION bool npt_active() const
CellStructure::ScatterVirial local_virial
BoxGeometry const & box_geo
double system_max_cutoff_sq
Dipoles::ShortRangeForceKernel::kernel_type const *const dipoles_kernel
CellStructure::AoSoA_pack const & aosoa
CellStructure::ScatterForce local_torque
InteractionsNonBonded const & nonbonded_ias
Utils::Vector3d *const global_virial
ESPRESSO_ATTR_ALWAYS_INLINE KOKKOS_INLINE_FUNCTION void operator()(std::size_t i, std::size_t j) const
BondedInteractionsMap const & bonded_ias
Coulomb::ShortRangeForceKernel::kernel_type const *const coulomb_kernel
Thermostat::Thermostat const & thermostat
Force information on a particle.
Struct holding all information for one particle.
Utils::Vector3d thole_pair_force(Particle const &p1, Particle const &p2, IA_parameters const &ia_params, Utils::Vector3d const &d, double dist, BondedInteractionsMap const &bonded_ias, Coulomb::ShortRangeForceKernel::kernel_type const *kernel)
Calculate Thole force.