48template <
typename FloatType>
class P3MFFT;
50template <
typename FloatType>
72 std::shared_ptr<P3MFFT<FloatType>>
fft;
79template <
typename FloatType, Arch Architecture>
87 std::unique_ptr<CoulombP3MState<FloatType>> p3m_state_ptr;
89 std::pair<std::optional<int>, std::optional<int>> tune_limits;
91 bool check_complex_residuals;
95 auto constexpr memory_order =
96 std::remove_reference<
decltype(
p3m)>::type::memory_order;
105 double prefactor,
int tune_timings,
bool tune_verbose,
106 decltype(tune_limits) tune_limits,
107 bool check_complex_residuals)
109 p3m_state_ptr{std::move(p3m_state)}, tune_timings{tune_timings},
110 tune_limits{std::move(tune_limits)}, tune_verbose{tune_verbose},
111 check_complex_residuals{check_complex_residuals} {
113 if (tune_timings <= 0) {
114 throw std::domain_error(
"Parameter 'timings' must be > 0");
116 m_is_tuned = not
p3m.params.tuning;
117 p3m.params.tuning =
false;
122 if constexpr (Architecture ==
Arch::CPU) {
126 if constexpr (Architecture ==
Arch::GPU) {
131 void tune()
override;
134 double square_sum_q)
override {
137 p3m.square_sum_q = square_sum_q;
143 [[nodiscard]]
bool is_tuned() const noexcept
override {
return m_is_tuned; }
144 [[nodiscard]]
bool is_gpu() const noexcept
override {
144 [[nodiscard]]
bool is_gpu() const noexcept
override {
…}
148 return std::is_same_v<FloatType, double>;
153 if constexpr (Architecture ==
Arch::GPU) {
160 if constexpr (Architecture ==
Arch::GPU) {
173 if constexpr (Architecture ==
Arch::CPU) {
177 if constexpr (Architecture ==
Arch::GPU) {
187 bool skip_cache)
override;
190 p3m.inter_weights.reset(
p3m.params.cao);
193 std::ranges::fill(
p3m.rs_charge_density, FloatType{});
211 void kernel_ks_charge_density();
212 void kernel_rs_electric_field();
215template <
typename FloatType,
Arch Architecture,
typename... Args>
219 std::make_unique<CoulombP3MState<FloatType>>(std::move(p3m_params));
220 auto obj = std::make_shared<CoulombP3MImpl<FloatType, Architecture>>(
221 std::move(state_ptr), std::forward<Args>(args)...);
Vector implementation and trait types for boost qvm interoperability.
void set_prefactor(double new_prefactor)
double prefactor
Electrostatics prefactor.
Cache for interpolation weights.
This file contains the defaults for ESPResSo.
T product(Vector< T, N > const &v)
Common functions for dipolar and charge P3M.
Arch
P3M kernel architecture.
auto constexpr P3M_EPSILON_METALLIC
This value indicates metallic boundary conditions.
P3M algorithm for long-range Coulomb interaction.
std::shared_ptr< CoulombP3M > new_coulomb_p3m(P3MParameters &&p3m_params, Args &&...args)
static SteepestDescentParameters params
Currently active steepest descent instance.
void charge_assign(ParticleRange const &particles) override
double long_range_energy(ParticleRange const &particles) override
bool is_gpu() const noexcept override
bool is_tuned() const noexcept override
void assign_charge(double q, Utils::Vector3d const &real_pos, bool skip_cache) override
void calc_influence_function_energy() override
Calculate the influence function optimized for the energy and the self energy correction.
void add_long_range_forces(ParticleRange const &particles) override
void count_charged_particles_elc(std::size_t n, double sum_q2, double square_sum_q) override
void scaleby_box_l() override
void calc_influence_function_force() override
Calculate the optimal influence function of .
Utils::Vector9d long_range_pressure(ParticleRange const &particles) override
bool is_double_precision() const noexcept override
~CoulombP3MImpl() override=default
void on_activation() override
void count_charged_particles() override
CoulombP3MImpl(std::unique_ptr< CoulombP3MState< FloatType > > &&p3m_state, double prefactor, int tune_timings, bool tune_verbose, decltype(tune_limits) tune_limits, bool check_complex_residuals)
CoulombP3MState< FloatType > & p3m
Coulomb P3M parameters.
double long_range_kernel(bool force_flag, bool energy_flag, ParticleRange const &particles)
Compute the k-space part of forces and energies.
std::shared_ptr< P3MGpuParams > m_gpu_data
void prepare_fft_mesh(bool reset_weights) override
void add_long_range_forces_gpu(ParticleRange const &particles)
void adapt_epsilon_elc() override
p3m_interpolation_cache inter_weights
std::vector< std::complex< FloatType > > ks_E_fields_storage
p3m_send_mesh< FloatType > halo_comm
std::array< std::vector< FloatType >, 3 > rs_E_fields
double square_sum_q
square of sum of charges.
std::shared_ptr< P3MFFT< FloatType > > fft
std::size_t sum_qpart
number of charged particles.
std::vector< FloatType > rs_charge_density
double sum_q2
Sum of square of charges.
std::vector< std::complex< FloatType > > ks_charge_density
static constexpr auto memory_order
std::vector< std::complex< FloatType > > rs_E_fields_no_halo
void sanity_checks() const
Structure to hold P3M parameters and some dependent variables.
State of the p3m methods, the part which applies to both, electrostatic and dipolar p3m.