28#include "constraints/Constraints.hpp"
33#include "system/System.hpp"
50 1ul,
static_cast<std::size_t
>(bonded_ias->get_next_key()),
51 nonbonded_ias->get_max_seen_particle_type());
53 if (long_range_interactions_sanity_checks()) {
58#if defined(ESPRESSO_CUDA) and \
59 (defined(ESPRESSO_ELECTROSTATICS) or defined(ESPRESSO_DIPOLES))
60 gpu->clear_energy_on_device();
65 auto const local_parts = cell_structure->local_particles();
72 auto const coulomb_kernel = coulomb.pair_energy_kernel();
73 auto const dipoles_kernel = dipoles.pair_energy_kernel();
78 auto const &
iaparams = *bonded_ias->at(bond_id);
82 obs_energy.bonded_contribution(bond_id)[0] += result.value();
91 nonbonded_ias->get_ia_param(
p1.type(),
p2.type());
93 p1,
p2, d.vec21, sqrt(d.dist2), d.dist2,
ia_params, *bonded_ias,
96 *cell_structure, maximal_cutoff(), bonded_ias->maximal_cutoff());
98#ifdef ESPRESSO_ELECTROSTATICS
100 obs_energy.coulomb[1] = coulomb.calc_energy_long_range();
103#ifdef ESPRESSO_DIPOLES
105 obs_energy.dipolar[1] = dipoles.calc_energy_long_range();
110#if defined(ESPRESSO_CUDA) and \
111 (defined(ESPRESSO_ELECTROSTATICS) or defined(ESPRESSO_DIPOLES))
112 auto const energy_host = gpu->copy_energy_to_host();
125 if (cell_structure->get_resort_particles()) {
126 cell_structure->update_ghosts_and_resort_particle(get_global_ghost_flags());
130 if (
auto const p = cell_structure->get_local_particle(pid)) {
131 auto const coulomb_kernel = coulomb.pair_energy_kernel();
134#ifdef ESPRESSO_EXCLUSIONS
138 auto const &
ia_params = nonbonded_ias->get_ia_param(p.type(),
p1.type());
141 *bonded_ias, coulomb,
nullptr);
143 cell_structure->run_on_particle_short_range_neighbors(*p, kernel);
150 if (cell_structure->get_resort_particles()) {
151 cell_structure->update_ghosts_and_resort_particle(get_global_ghost_flags());
153 Particle const *p = cell_structure->get_local_particle(pid);
156 auto const &
iaparams = *bonded_ias->at(bond_id);
159 auto const coulomb_kernel = coulomb.pair_energy_kernel();
void bond_broken_error(int id, std::span< const int > partner_ids)
double particle_short_range_energy_contribution(int pid)
Compute the short-range energy of a particle.
std::optional< double > particle_bond_energy(int pid, int bond_id, std::vector< int > partners)
Compute the energy of a given bond which has to exist on the given particle.
std::shared_ptr< Observable_stat > calculate_energy()
Calculate the total energy.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
const T * get_ptr(std::optional< T > const &opt)
void add_non_bonded_pair_energy(Particle const &p1, Particle const &p2, Utils::Vector3d const &d, double const dist, double const dist2, IA_parameters const &ia_params, BondedInteractionsMap const &bonded_ias, Coulomb::Solver const &coulomb, Coulomb::ShortRangeEnergyKernel::kernel_type const *coulomb_kernel, Dipoles::ShortRangeEnergyKernel::kernel_type const *dipoles_kernel, Observable_stat &obs_energy)
Add non-bonded and short-range Coulomb energies between a pair of particles to the energy observable.
std::optional< double > calc_bonded_energy(Bonded_IA_Parameters const &iaparams, Particle const &p1, std::span< Particle * > partners, BoxGeometry const &box_geo, Coulomb::ShortRangeEnergyKernel::kernel_type const *kernel)
double translational_kinetic_energy(Particle const &p)
Calculate kinetic energies from translation for one particle.
double rotational_kinetic_energy(Particle const &p)
Calculate kinetic energies from rotation for one particle.
double calc_non_bonded_pair_energy(Particle const &p1, Particle const &p2, IA_parameters const &ia_params, Utils::Vector3d const &d, double const dist, BondedInteractionsMap const &bonded_ias, Coulomb::Solver const &coulomb, Coulomb::ShortRangeEnergyKernel::kernel_type const *coulomb_kernel)
Calculate non-bonded energies between a pair of particles.
bool do_nonbonded(Particle const &p1, Particle const &p2)
Determine if the non-bonded interactions between p1 and p2 should be calculated.
Various procedures concerning interactions between particles.
void short_range_loop(BondKernel bond_kernel, PairKernel pair_kernel, CellStructure &cell_structure, double pair_cutoff, double bond_cutoff, VerletCriterion const &verlet_criterion={})
Exception indicating that a particle id could not be resolved.
Distance vector and length handed to pair kernels.
Struct holding all information for one particle.