32#include "communication.hpp"
33#include "system/System.hpp"
46std::shared_ptr<CoulombScafacos>
48 std::string
const ¶meters) {
49 return std::make_shared<CoulombScafacosImpl>(
comm_cart, method, parameters);
54 auto const &box_geo = *system.box_geo;
55 auto const &cell_structure = *system.cell_structure;
60 for (
auto const &p : cell_structure.local_particles()) {
61 auto const pos = box_geo.folded_position(p.pos());
62 positions.push_back(pos[0]);
63 positions.push_back(pos[1]);
64 positions.push_back(pos[2]);
65 charges.push_back(p.q());
70 if (positions.empty())
73 auto const &cell_structure = *
get_system().cell_structure;
75 auto it_fields = fields.begin();
76 for (
auto &p : cell_structure.local_particles()) {
79 std::advance(it_fields, 3);
83 assert(it_fields == fields.end());
86double CoulombScafacosImpl::time_r_cut(
double r_cut) {
87 set_r_cut_and_tune(r_cut);
92void CoulombScafacosImpl::tune_r_cut() {
93 auto constexpr convergence_threshold = 1e-3;
95 auto const &box_geo = *system.box_geo;
96 auto const &local_geo = *system.local_geo;
97 auto const verlet_skin = system.cell_structure->get_verlet_skin();
99 auto const min_box_l = std::ranges::min(box_geo.length());
100 auto const min_local_box_l = std::ranges::min(local_geo.length());
106 auto r_max = std::min(min_local_box_l, min_box_l / 2.0) - verlet_skin;
107 assert(r_max >= r_min);
109 auto t_max = std::numeric_limits<double>::max();
113 while (std::fabs(r_min - r_max) > convergence_threshold) {
114 r_opt = (r_max + r_min) / 2.;
115 auto const dr = 0.5 * (r_max - r_min);
116 auto const t_mid = time_r_cut(r_min + dr);
117 t_min = time_r_cut(r_min);
118 t_max = time_r_cut(r_max);
120 if (t_min <= 0.0 or t_max <= 0.0) {
139 if (ScafacosContext::get_near_field_delegation() and
140 ScafacosContext::r_cut() <= 0.0) {
144 ScafacosContext::tune(charges, positions);
Vector implementation and trait types for boost qvm interoperability.
double prefactor
Electrostatics prefactor.
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.