ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
core/electrostatics/scafacos.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 <utils/Vector.hpp>
33
34#include <memory>
35#include <string>
36
37struct CoulombScafacos : virtual public ScafacosContextBase,
38 public Coulomb::Actor<CoulombScafacos> {
39 ~CoulombScafacos() override = default;
40
44 tune();
45 }
46 /** @brief Recalculate all box-length-dependent parameters. */
48 void on_node_grid_change() const {}
51 void init() const {}
52
54
55 bool is_tuned() const { return m_is_tuned; }
56 void tune() {
57 if (not is_tuned()) {
58 tune_impl();
59 }
60 }
61 virtual double get_r_cut() const = 0;
62 virtual double get_pair_force(double dist) const = 0;
63 virtual double get_pair_energy(double dist) const = 0;
64 virtual void set_near_field_delegation(bool delegate) = 0;
65 virtual bool get_near_field_delegation() const = 0;
66
67 /** @brief Calculate near-field pair force. */
69 double dist) const {
70 if (dist > get_r_cut())
71 return {};
72
73 return d * (-q1q2 * prefactor * get_pair_force(dist) / dist);
74 }
75
76 /** @brief Calculate near-field pair energy. */
77 double pair_energy(double q1q2, double dist) const {
78 if (dist > get_r_cut())
79 return 0.;
80
81 return q1q2 * prefactor * get_pair_energy(dist);
82 }
83
84protected:
85 virtual void tune_impl() = 0;
86
87private:
88 bool m_is_tuned = false;
89};
90
91std::shared_ptr<CoulombScafacos>
92make_coulomb_scafacos(std::string const &method, std::string const &parameters);
93
94#endif // SCAFACOS
ScafacosContextBase provides the public interface of the ScaFaCoS bridge.
Vector implementation and trait types for boost qvm interoperability.
double prefactor
Electrostatics prefactor.
This file contains the defaults for ESPResSo.
std::shared_ptr< CoulombScafacos > make_coulomb_scafacos(std::string const &method, std::string const &parameters)
~CoulombScafacos() override=default
virtual double get_r_cut() const =0
virtual void set_near_field_delegation(bool delegate)=0
void sanity_checks() const override
virtual void tune_impl()=0
void on_boxl_change()
Recalculate all box-length-dependent parameters.
virtual bool get_near_field_delegation() const =0
virtual double get_pair_energy(double dist) const =0
double pair_energy(double q1q2, double dist) const
Calculate near-field pair energy.
Utils::Vector3d pair_force(double q1q2, Utils::Vector3d const &d, double dist) const
Calculate near-field pair force.
virtual double get_pair_force(double dist) const =0
Public interface to the ScaFaCoS context.
virtual void update_system_params()=0
Reinitialize number of particles, box shape and periodicity.