ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
electrostatics/scafacos_impl.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
4 * Max-Planck-Institute for Polymer Research, Theory Group
5 *
6 * This file is part of ESPResSo.
7 *
8 * ESPResSo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * ESPResSo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include "config/config.hpp"
25
26#ifdef SCAFACOS
27
29
31
32#include <scafacos/Coulomb.hpp>
33
34#include <boost/range/numeric.hpp>
35
36#include <vector>
37
39 public ScafacosContext<::Scafacos::Coulomb> {
41 using CoulombScafacos::CoulombScafacos;
42 using ScafacosContext::ScafacosContext;
43
44 void update_particle_data() override;
45 void update_particle_forces() const override;
46
47 double long_range_energy() override {
49 run(charges, positions, fields, potentials);
50 return 0.5 * prefactor * boost::inner_product(charges, potentials, 0.);
51 }
52
53 void add_long_range_forces() override {
55 run(charges, positions, fields, potentials);
57 }
58
59 double get_pair_force(double dist) const override {
60 return ScafacosContext::pair_force(dist);
61 }
62
63 double get_pair_energy(double dist) const override {
64 return ScafacosContext::pair_energy(dist);
65 }
66
67 void set_near_field_delegation(bool delegate) override {
68 return ScafacosContext::set_near_field_delegation(delegate);
69 }
70
71 bool get_near_field_delegation() const override {
72 return ScafacosContext::get_near_field_delegation();
73 }
74
75 double get_r_cut() const override { return ScafacosContext::r_cut(); }
76
77private:
78 /** Inputs */
79 std::vector<double> positions, charges;
80 /** Outputs */
81 std::vector<double> fields, potentials;
82
83 /** Determine runtime for a specific cutoff */
84 double time_r_cut(double r_cut);
85
86 /** Determine the optimal cutoff by bisection */
87 void tune_r_cut();
88 void tune_impl() override;
89 void set_r_cut_and_tune(double r_cut) {
91 set_r_cut(r_cut);
92 ScafacosContext::tune(charges, positions);
93 }
94};
95
96#endif // SCAFACOS
ScafacosContext implements the interface of the ScaFaCoS bridge.
double prefactor
Electrostatics prefactor.
This file contains the defaults for ESPResSo.
void update_particle_forces() const override
double get_pair_force(double dist) const override
void set_near_field_delegation(bool delegate) override
double get_pair_energy(double dist) const override
bool get_near_field_delegation() const override
double get_r_cut() const override