44#include <Cabana_Core.hpp>
74 KOKKOS_INLINE_FUNCTION
79 KOKKOS_INLINE_FUNCTION
85 KOKKOS_INLINE_FUNCTION
94 KOKKOS_INLINE_FUNCTION std::size_t
bonded_idx(
int b)
const {
95 return off_bonded +
static_cast<std::size_t
>(b);
115 Kokkos::View<int *, Kokkos::LayoutRight, execution_space>
mol_id_view;
130 std::vector<Particle *>
const &unique_particles_,
131 Kokkos::View<double **, Kokkos::LayoutRight, execution_space>
const
134 Kokkos::View<int *, execution_space> mol_id_view_,
135 double system_max_cutoff_,
int thermo_switch_)
149 std::size_t j)
const {
150 auto const pos1 =
aosoa.get_vector_at(
aosoa.position, i);
151 auto const pos2 =
aosoa.get_vector_at(
aosoa.position, j);
152 auto const d =
box_geo.get_mi_vector(pos1, pos2);
153 auto const dist = d.norm();
157 auto const t1 =
aosoa.type(i);
158 auto const t2 =
aosoa.type(j);
160 auto const tid = omp_get_thread_num();
163 if (dist <= ia_params.max_cut) {
165#ifdef ESPRESSO_EXCLUSIONS
166 if (
aosoa.has_exclusion(i) or
aosoa.has_exclusion(j)) {
174#ifdef ESPRESSO_GAY_BERNE
176 auto const dir1 =
aosoa.get_vector_at(
aosoa.director, i);
177 auto const dir2 =
aosoa.get_vector_at(
aosoa.director, j);
191 ?
layout.nb_intra_idx(t1, t2)
192 :
layout.nb_inter_idx(t1, t2);
193 for (std::size_t k = 0; k < 9; ++k)
198 auto const pid1 =
aosoa.id(i);
199 auto const pid2 =
aosoa.id(j);
200 auto const noise_vec = (ia_params.dpd.radial.pref > 0.0 ||
201 ia_params.dpd.trans.pref > 0.0)
204 auto const vel1 =
aosoa.get_vector_at(
aosoa.velocity, i);
205 auto const vel2 =
aosoa.get_vector_at(
aosoa.velocity, j);
206 auto const v21 =
box_geo.velocity_difference(pos1, pos2, vel1, vel2);
207 auto const dist2 = d.norm2();
214 auto const f_d =
P * (f_r - f_t) + f_t;
216 for (std::size_t k = 0; k < 9; ++k)
224#ifdef ESPRESSO_ELECTROSTATICS
226 auto const q1 =
aosoa.charge(i), q2 =
aosoa.charge(j);
227 if (q1 != 0. and q2 != 0.) {
229 for (std::size_t k = 0; k < 9; ++k)
236#ifdef ESPRESSO_DIPOLES
238 auto const d1d2 =
aosoa.dipm(i) *
aosoa.dipm(j);
240 auto const dir1 =
aosoa.get_vector_at(
aosoa.director, i);
241 auto const dir2 =
aosoa.get_vector_at(
aosoa.director, j);
242 auto const dist2 = d.norm2();
244 d1d2,
aosoa.dipm(i) * dir1,
aosoa.dipm(j) * dir2, d, dist, dist2));
245 for (std::size_t k = 0; k < 9; ++k)
255 Kokkos::View<double **, Kokkos::LayoutRight, Kokkos::HostSpace>
const
259 auto const nthreads = local_pressure.extent(0);
261 Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, local_pressure);
263 auto sum_tensor = [&](std::size_t bin, std::span<double> dest) {
264 for (std::size_t k = 0; k < 9; ++k) {
266 for (std::size_t t = 0; t < nthreads; ++t)
272 for (
int b = 0; b < int(layout.
n_bonded); ++b)
275 for (
int t1 = 0; t1 < n_types; ++t1)
276 for (
int t2 = 0; t2 <= t1; ++t2)
280 for (
int t1 = 0; t1 < n_types; ++t1)
281 for (
int t2 = 0; t2 <= t1; ++t2)
289 if (!obs.
dpd.empty())
Vector implementation and trait types for boost qvm interoperability.
#define ESPRESSO_ATTR_ALWAYS_INLINE
Data structures for bonded interactions.
container for bonded interactions.
Observable for the pressure and energy.
auto non_bonded_intra_contribution(int type1, int type2) const
Get contribution from a non-bonded intramolecular interaction.
std::span< double > coulomb
Contribution(s) from Coulomb interactions.
std::span< double > dpd
Contribution from DPD.
auto non_bonded_inter_contribution(int type1, int type2) const
Get contribution from a non-bonded intermolecular interaction.
std::span< double > bonded_contribution(int bond_id) const
Get contribution from a bonded interaction.
std::span< double > dipolar
Contribution(s) from dipolar interactions.
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)
Utils::Vector3d dpd_noise(DPDThermostat const &dpd, int pid1, int pid2)
Return a random uniform 3D vector with the Philox thermostat.
Routines to use DPD as thermostat or pair force soddemann03a.
bool do_nonbonded(Particle const &p1, Particle const &p2)
Determine if the non-bonded interactions between p1 and p2 should be calculated.
ParticleForce calc_non_central_force(Particle const &p1, Particle const &p2, IA_parameters const &ia_params, Utils::Vector3d const &d, double const dist)
ESPRESSO_ATTR_ALWAYS_INLINE Utils::Vector3d calc_central_radial_force(IA_parameters const &ia_params, Utils::Vector3d const &d, double const dist)
void flatten(Range const &v, OutputIterator out)
Flatten a range of ranges.
DEVICE_QUALIFIER T lower_triangular(T i, T j)
Linear index into a lower triangular matrix.
Matrix< T, N, M > tensor_product(const Vector< T, N > &x, const Vector< T, M > &y)
Various procedures concerning interactions between particles.
static void reduce_cabana_pressure(Kokkos::View< double **, Kokkos::LayoutRight, Kokkos::HostSpace > const &local_pressure, PressureBinLayout const &layout, Observable_stat &obs, BondedInteractionsMap const &bonded_ias, int n_types)
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)
Solver::ShortRangeForceKernel kernel_type
Solver::ShortRangePressureKernel kernel_type
Thermostat for dissipative particle dynamics.
Solver::ShortRangePressureKernel kernel_type
KOKKOS_INLINE_FUNCTION std::size_t dpd_idx() const
KOKKOS_INLINE_FUNCTION std::size_t tensor_offset(std::size_t bin, std::size_t k) const
KOKKOS_INLINE_FUNCTION std::size_t coulomb_idx() const
KOKKOS_INLINE_FUNCTION std::size_t nb_intra_idx(int t1, int t2) const
KOKKOS_INLINE_FUNCTION std::size_t bonded_idx(int b) const
PressureBinLayout(std::size_t n_bonded_, std::size_t n_types_)
KOKKOS_INLINE_FUNCTION std::size_t dipolar_idx() const
KOKKOS_INLINE_FUNCTION std::size_t nb_inter_idx(int t1, int t2) const
Coulomb::ShortRangePressureKernel::kernel_type const * coulomb_p_kernel
Coulomb::Solver const & coulomb
PressureKernel(BondedInteractionsMap const &bonded_ias_, InteractionsNonBonded const &nonbonded_ias_, Coulomb::Solver const &coulomb_, Coulomb::ShortRangeForceKernel::kernel_type const *coulomb_f_kernel_, Coulomb::ShortRangePressureKernel::kernel_type const *coulomb_p_kernel_, Dipoles::ShortRangePressureKernel::kernel_type const *dipoles_p_kernel_, BoxGeometry const &box_geo_, DPDThermostat const *dpd_, std::vector< Particle * > const &unique_particles_, Kokkos::View< double **, Kokkos::LayoutRight, execution_space > const &local_pressure_, PressureBinLayout layout_, CellStructure::AoSoA_pack const &aosoa_, Kokkos::View< int *, execution_space > mol_id_view_, double system_max_cutoff_, int thermo_switch_)
InteractionsNonBonded const & nonbonded_ias
ESPRESSO_ATTR_ALWAYS_INLINE void operator()(std::size_t i, std::size_t j) const
std::vector< Particle * > const & unique_particles
Dipoles::ShortRangePressureKernel::kernel_type const * dipoles_p_kernel
BondedInteractionsMap const & bonded_ias
Coulomb::ShortRangeForceKernel::kernel_type const * coulomb_f_kernel
CellStructure::AoSoA_pack const & aosoa
Kokkos::View< int *, Kokkos::LayoutRight, execution_space > mol_id_view
BoxGeometry const & box_geo
Kokkos::View< double **, Kokkos::LayoutRight, execution_space > local_pressure
DPDThermostat const * dpd
Kokkos::HostSpace execution_space
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.