32#include "communication.hpp"
33#include "system/System.hpp"
39#include <boost/range/algorithm/min_element.hpp>
47std::shared_ptr<CoulombScafacos>
49 std::string
const ¶meters) {
50 return std::make_shared<CoulombScafacosImpl>(
comm_cart, method, parameters);
55 auto const &box_geo = *system.box_geo;
56 auto const &cell_structure = *system.cell_structure;
61 for (
auto const &p : cell_structure.local_particles()) {
62 auto const pos = box_geo.folded_position(p.pos());
63 positions.push_back(
pos[0]);
64 positions.push_back(
pos[1]);
65 positions.push_back(
pos[2]);
66 charges.push_back(p.q());
71 if (positions.empty())
74 auto const &cell_structure = *
get_system().cell_structure;
76 auto it_fields = fields.begin();
77 for (
auto &p : cell_structure.local_particles()) {
84 assert(it_fields == fields.end());
87double CoulombScafacosImpl::time_r_cut(
double r_cut) {
88 set_r_cut_and_tune(r_cut);
93void CoulombScafacosImpl::tune_r_cut() {
94 auto constexpr convergence_threshold = 1e-3;
96 auto const &box_geo = *system.box_geo;
97 auto const &local_geo = *system.local_geo;
98 auto const verlet_skin = system.cell_structure->get_verlet_skin();
100 auto const min_box_l = *boost::min_element(box_geo.length());
101 auto const min_local_box_l = *boost::min_element(local_geo.length());
107 auto r_max = std::min(min_local_box_l, min_box_l / 2.0) - verlet_skin;
108 assert(r_max >= r_min);
110 auto t_max = std::numeric_limits<double>::max();
114 while (std::fabs(r_min - r_max) > convergence_threshold) {
115 r_opt = (r_max + r_min) / 2.;
116 auto const dr = 0.5 * (r_max - r_min);
117 auto const t_mid = time_r_cut(r_min +
dr);
118 t_min = time_r_cut(r_min);
119 t_max = time_r_cut(r_max);
121 if (t_min <= 0.0 or t_max <= 0.0) {
140 if (ScafacosContext::get_near_field_delegation() and
141 ScafacosContext::r_cut() <= 0.0) {
145 ScafacosContext::tune(charges, positions);
Vector implementation and trait types for boost qvm interoperability.
__shared__ int pos[MAXDEPTH *THREADS5/WARPSIZE]
double prefactor
Electrostatics prefactor.
A stripped-down version of std::span from C++17.
boost::mpi::communicator comm_cart
The communicator.
This file contains the defaults for ESPResSo.
std::shared_ptr< CoulombScafacos > make_coulomb_scafacos(std::string const &method, std::string const ¶meters)
void update_particle_data() override
void update_particle_forces() const override
void tune_impl() override
double benchmark_integration_step(System::System &system, int int_steps)
Benchmark the integration loop.