30#include <Cabana_Core.hpp>
60 KOKKOS_INLINE_FUNCTION
66 KOKKOS_INLINE_FUNCTION
74 KOKKOS_INLINE_FUNCTION std::size_t
bonded_idx(
int b)
const {
100 std::vector<Particle *>
const &unique_particles_,
101 Kokkos::View<double **, Kokkos::LayoutRight>
const &local_energy_,
103 Kokkos::View<int *> mol_id_view_,
double system_max_cutoff_)
111 KOKKOS_INLINE_FUNCTION
116 auto const dist_sq = d.norm2();
119 auto const dist = std::sqrt(dist_sq);
126#if defined(ESPRESSO_EXCLUSIONS) or defined(ESPRESSO_THOLE)
127 bool need_particle_pointers =
false;
128#ifdef ESPRESSO_EXCLUSIONS
132 need_particle_pointers |=
138 if (need_particle_pointers) {
144 auto const tid = omp_get_thread_num();
147 if (dist <= ia_params.max_cut) {
148#ifdef ESPRESSO_EXCLUSIONS
165#ifdef ESPRESSO_GAY_BERNE
181#ifdef ESPRESSO_ELECTROSTATICS
184 if (q1 != 0. and q2 != 0.) {
187 double const e_c = (*coulomb_u_kernel)(pos1, pos2, q1 * q2, d, dist);
193#ifdef ESPRESSO_DIPOLES
198 double const e_d = (*dipoles_u_kernel)(
208 Kokkos::View<double **, Kokkos::LayoutRight>
const &local_energy,
211 auto const nthreads = local_energy.extent(0);
213 Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, local_energy);
215 auto sum_bin = [&](std::size_t bin) {
217 for (std::size_t t = 0; t < nthreads; ++t)
222 for (
int b = 0; b < int(layout.
n_bonded); ++b)
225 for (
int t1 = 0; t1 < n_types; ++t1)
226 for (
int t2 = 0; t2 <= t1; ++t2)
230 for (
int t1 = 0; t1 < n_types; ++t1)
231 for (
int t2 = 0; t2 <= t1; ++t2)
Vector implementation and trait types for boost qvm interoperability.
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.
auto & get_ia_param(int i, int j)
Get interaction parameters between particle types i and j.
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.
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.
static void reduce_cabana_energy(Kokkos::View< double **, Kokkos::LayoutRight > const &local_energy, EnergyBinLayout const &layout, Observable_stat &obs, BondedInteractionsMap const &bonded_ias, int n_types)
double calc_central_radial_energy(IA_parameters const &ia_params, double const dist)
bool do_nonbonded(Particle const &p1, Particle const &p2)
Determine if the non-bonded interactions between p1 and p2 should be calculated.
double gb_pair_energy(Utils::Vector3d const &ui, Utils::Vector3d const &uj, IA_parameters const &ia_params, Utils::Vector3d const &d, double dist)
Calculate Gay-Berne energy.
T lower_triangular(T i, T j)
Linear index into a lower triangular matrix.
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)
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
Solver::ShortRangeEnergyKernel kernel_type
Solver::ShortRangeEnergyKernel kernel_type
KOKKOS_INLINE_FUNCTION std::size_t nb_intra_idx(int t1, int t2) const
EnergyBinLayout(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 bonded_idx(int b) const
KOKKOS_INLINE_FUNCTION std::size_t coulomb_idx() const
KOKKOS_INLINE_FUNCTION std::size_t nb_inter_idx(int t1, int t2) const
CellStructure::AoSoA_pack const & aosoa
std::vector< Particle * > const & unique_particles
BondedInteractionsMap const & bonded_ias
Kokkos::View< double **, Kokkos::LayoutRight > local_energy
EnergyKernel(BondedInteractionsMap const &bonded_ias_, InteractionsNonBonded const &nonbonded_ias_, Coulomb::Solver const &coulomb_, Coulomb::ShortRangeEnergyKernel::kernel_type const *coulomb_u_kernel_, Dipoles::ShortRangeEnergyKernel::kernel_type const *dipoles_u_kernel_, BoxGeometry const &box_geo_, std::vector< Particle * > const &unique_particles_, Kokkos::View< double **, Kokkos::LayoutRight > const &local_energy_, EnergyBinLayout layout_, CellStructure::AoSoA_pack const &aosoa_, Kokkos::View< int * > mol_id_view_, double system_max_cutoff_)
InteractionsNonBonded const & nonbonded_ias
KOKKOS_INLINE_FUNCTION void operator()(std::size_t i, std::size_t j) const
Coulomb::Solver const & coulomb
Dipoles::ShortRangeEnergyKernel::kernel_type const * dipoles_u_kernel
Kokkos::View< int * > mol_id_view
BoxGeometry const & box_geo
Coulomb::ShortRangeEnergyKernel::kernel_type const * coulomb_u_kernel
double system_max_cutoff_sq
Struct holding all information for one particle.
double thole_pair_energy(Particle const &p1, Particle const &p2, IA_parameters const &ia_params, Utils::Vector3d const &d, double dist, BondedInteractionsMap const &bonded_ias, Coulomb::Solver const &coulomb, Coulomb::ShortRangeEnergyKernel::kernel_type const *kernel)
Calculate Thole energy.