54 auto obs_energy_ptr = std::make_shared<Observable_stat>(
55 1ul,
static_cast<std::size_t
>(bonded_ias->get_next_key()),
56 nonbonded_ias->get_max_seen_particle_type());
58 if (long_range_interactions_sanity_checks()) {
59 return obs_energy_ptr;
62 auto &obs_energy = *obs_energy_ptr;
63#if defined(ESPRESSO_CUDA) and \
64 (defined(ESPRESSO_ELECTROSTATICS) or defined(ESPRESSO_DIPOLES))
65 gpu->clear_energy_on_device();
70 auto const local_parts = cell_structure->local_particles();
72 for (
auto const &p : local_parts) {
77 auto const coulomb_kernel = coulomb.pair_energy_kernel();
78 auto const dipoles_kernel = dipoles.pair_energy_kernel();
80#ifdef ESPRESSO_CALIPER
81 CALI_MARK_BEGIN(
"cabana_short_range");
84 cell_structure->get_verlet_skin(),
85 get_interaction_range(),
90 get_interaction_range(), propagation->integ_switch);
93 static_cast<std::size_t
>(bonded_ias->get_next_key()),
94 std::size_t(nonbonded_ias->get_max_seen_particle_type() + 1)};
96 using exec = Kokkos::DefaultExecutionSpace;
98 "local_energy", exec().concurrency(), layout.total);
99 auto const &unique_particles = cell_structure->get_unique_particles();
100 auto const n_particles =
static_cast<int>(unique_particles.size());
102 auto mol_id_host = Kokkos::create_mirror_view(mol_id_view);
103 for (
int i = 0; i < n_particles; ++i) {
104 mol_id_host(i) = unique_particles[i]->mol_id();
106 Kokkos::deep_copy(mol_id_view, mol_id_host);
115 cell_structure->get_unique_particles(),
118 cell_structure->get_aosoa(),
123 auto &bs = cell_structure->bond_state();
125 layout, cell_structure->get_aosoa()};
134 pair_e_kernel, *cell_structure, get_interaction_range(),
135 bonded_ias->maximal_cutoff(), verlet_criterion,
136 propagation->integ_switch);
139 nonbonded_ias->get_max_seen_particle_type() + 1);
140#ifdef ESPRESSO_CALIPER
141 CALI_MARK_END(
"cabana_short_range");
144#ifdef ESPRESSO_ELECTROSTATICS
146 obs_energy.coulomb[1] = coulomb.calc_energy_long_range();
149#ifdef ESPRESSO_DIPOLES
151 obs_energy.dipolar[1] = dipoles.calc_energy_long_range();
154 constraints->add_energy(local_parts, get_sim_time(), obs_energy);
156#if defined(ESPRESSO_CUDA) and \
157 (defined(ESPRESSO_ELECTROSTATICS) or defined(ESPRESSO_DIPOLES))
158 auto const energy_host = gpu->copy_energy_to_host();
159 if (!obs_energy.coulomb.empty())
160 obs_energy.coulomb[1] +=
static_cast<double>(energy_host.coulomb);
161 if (!obs_energy.dipolar.empty())
162 obs_energy.dipolar[1] +=
static_cast<double>(energy_host.dipolar);
165 obs_energy.mpi_reduce();
166 return obs_energy_ptr;
171 if (cell_structure->get_resort_particles()) {
172 cell_structure->update_ghosts_and_resort_particle(get_global_ghost_flags());
176 if (
auto const p = cell_structure->get_local_particle(pid)) {
177 auto const coulomb_kernel = coulomb.pair_energy_kernel();
180#ifdef ESPRESSO_EXCLUSIONS
184 auto const &ia_params = nonbonded_ias->get_ia_param(p.type(), p1.type());
187 *bonded_ias, coulomb,
nullptr);
189 cell_structure->run_on_particle_short_range_neighbors(*p, kernel);
195 std::vector<int> partners) {
196 if (cell_structure->get_resort_particles()) {
197 cell_structure->update_ghosts_and_resort_particle(get_global_ghost_flags());
199 Particle const *p = cell_structure->get_local_particle(pid);
202 auto const &iaparams = *bonded_ias->at(bond_id);
204 auto resolved_partners = cell_structure->resolve_bond_partners(partners);
205 auto const coulomb_kernel = coulomb.pair_energy_kernel();
208 std::span(resolved_partners.data(), resolved_partners.size()), *box_geo,
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.
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 &verlet_criterion, auto const integ_switch)
Struct holding all information for one particle.