115 sanity_checks_cell_structure();
122 sanity_checks_boxl();
123 sanity_checks_node_grid();
124 sanity_checks_periodicity();
125 sanity_checks_cell_structure();
200#if USE_ERFC_APPROXIMATION
203 auto const erfc_part_ri = erfc(adist) / dist;
207 auto const mimj = dip1 * dip2;
209 auto const mir = dip1 * d;
210 auto const mjr = dip2 * d;
213 auto const dist2i = 1. / dist2;
214 auto const exp_adist2 = exp(-
Utils::sqr(adist));
217 ? (erfc_part_ri + coeff) * exp_adist2 * dist2i
218 : (erfc(adist) / dist + coeff * exp_adist2) * dist2i;
220 auto const common_term = alpsq * coeff * exp_adist2;
221 auto const C_r = dist2i * (3. * B_r + 2. * common_term);
222 auto const D_r = dist2i * (5. * C_r + 4. * common_term * alpsq);
225 auto const force =
prefactor * ((mimj * d + dip1 * mjr + dip2 * mir) * C_r -
226 mir * mjr * D_r * d);
235#if USE_ERFC_APPROXIMATION
240 auto const energy = fac * (mimj * B_r - mir * mjr * C_r);
260#if USE_ERFC_APPROXIMATION
263 auto const erfc_part_ri = erfc(adist) / dist;
267 auto const mimj = dip1 * dip2;
268 auto const mir = dip1 * d;
269 auto const mjr = dip2 * d;
272 auto const dist2i = 1. / dist2;
273 auto const exp_adist2 = exp(-
Utils::sqr(adist));
276 ? dist2i * (erfc_part_ri + coeff) * exp_adist2
277 : dist2i * (erfc(adist) / dist + coeff * exp_adist2);
278 auto const C_r = (3. * B_r + 2. * alpsq * coeff * exp_adist2) * dist2i;
280 return prefactor * (mimj * B_r - mir * mjr * C_r);
287 double calc_average_self_energy_k_space()
const;
292 void calc_energy_correction();
295 void calc_influence_function_force();
298 void calc_influence_function_energy();
301 double calc_surface_term(
bool force_flag,
bool energy_flag,
305 void sanity_checks_boxl()
const;
306 void sanity_checks_node_grid()
const;
307 void sanity_checks_periodicity()
const;
308 void sanity_checks_cell_structure()
const;
310 void scaleby_box_l();
Vector implementation and trait types for boost qvm interoperability.
__global__ float float * torque
double prefactor
Magnetostatics prefactor.
Cache for interpolation weights.
Structure for send/recv meshes.
Common functions for dipolar and charge P3M.
This file contains the defaults for ESPResSo.
__device__ void vector_product(float const *a, float const *b, float *out)
void npt_add_virial_magnetic_contribution(double energy)
Update the NpT virial.
Routines, row decomposition, data structures and communication for the 3D-FFT.
std::vector< T, fft_allocator< T > > fft_vector
constexpr T AS_erfc_part(T d)
Approximate by applying a formula from chapter 7.
DEVICE_QUALIFIER constexpr T sqr(T x)
Calculates the SQuaRe of x.
DEVICE_QUALIFIER constexpr T sqrt_pi_i()
One over square root of pi.
void init()
Recalculate all derived parameters.
int tune_timings
Magnetostatics prefactor.
void sanity_checks() const
void dipole_assign(ParticleRange const &particles)
Assign the physical dipoles using the tabulated assignment function.
void on_node_grid_change() const
dp3m_data_struct dp3m
Dipolar P3M parameters.
void on_boxl_change()
Recalculate all box-length-dependent parameters.
double long_range_kernel(bool force_flag, bool energy_flag, ParticleRange const &particles)
Compute the k-space part of forces and energies.
void count_magnetic_particles()
Count the number of magnetic particles and calculate the sum of the squared dipole moments.
double long_range_energy(ParticleRange const &particles)
Compute the k-space part of energies.
void add_long_range_forces(ParticleRange const &particles)
Compute the k-space part of forces.
void tune()
Tune dipolar P3M parameters to desired accuracy.
double pair_energy(Particle const &p1, Particle const &p2, Utils::Vector3d const &d, double dist2, double dist) const
Calculate real-space contribution of dipolar pair energy.
void on_periodicity_change() const
void on_cell_structure_change()
ParticleForce pair_force(Particle const &p1, Particle const &p2, Utils::Vector3d const &d, double dist2, double dist) const
Calculate real-space contribution of p3m dipolar pair forces and torques.
Structure for local mesh parameters.
Structure to hold P3M parameters and some dependent variables.
double alpha
unscaled alpha_L for use with fast inline functions only
double accuracy
accuracy of the actual parameter set.
double r_cut
unscaled r_cut_iL for use with fast inline functions only
Force information on a particle.
Struct holding all information for one particle.
auto const & dipm() const
p3m_send_mesh sm
send/recv mesh sizes
P3MLocalMesh local_mesh
local mesh.
dp3m_data_struct(P3MParameters &¶meters)
fft_vector< double > rs_mesh
real space mesh (local) for CA/FFT.
double sum_mu2
Sum of square of magnetic dipoles (only on head node).
std::array< fft_vector< double >, 3 > rs_mesh_dip
real space mesh (local) for CA/FFT of the dipolar field.
int sum_dip_part
number of dipolar particles (only on head node).
p3m_interpolation_cache inter_weights
double pos_shift
position shift for calculation of first assignment mesh point.
std::vector< double > ks_mesh
k-space mesh (local) for k-space calculation and FFT.
double energy_correction
cached k-space self-energy correction
Information about the three one dimensional FFTs and how the nodes have to communicate inbetween.