62 [[nodiscard]]
virtual bool is_tuned() const noexcept = 0;
63 [[nodiscard]] virtual
bool is_gpu() const noexcept = 0;
148#if USE_ERFC_APPROXIMATION
151 auto const erfc_part_ri = erfc(adist) / dist;
155 auto const mimj = dip1 * dip2;
157 auto const mir = dip1 * d;
158 auto const mjr = dip2 * d;
161 auto const dist2i = 1. / dist2;
162 auto const exp_adist2 = exp(-
Utils::sqr(adist));
165 ? (erfc_part_ri + coeff) * exp_adist2 * dist2i
166 : (erfc(adist) / dist + coeff * exp_adist2) * dist2i;
168 auto const common_term = alpsq * coeff * exp_adist2;
169 auto const C_r = dist2i * (3. * B_r + 2. * common_term);
170 auto const D_r = dist2i * (5. * C_r + 4. * common_term * alpsq);
173 auto const force =
prefactor * ((mimj * d + dip1 * mjr + dip2 * mir) * C_r -
174 mir * mjr * D_r * d);
181 auto const torque =
prefactor * (-mixmj * B_r + mixr * (mjr * C_r));
183#if USE_ERFC_APPROXIMATION
188 auto const energy = fac * (mimj * B_r - mir * mjr * C_r);
208#if USE_ERFC_APPROXIMATION
211 auto const erfc_part_ri = erfc(adist) / dist;
215 auto const mimj = dip1 * dip2;
216 auto const mir = dip1 * d;
217 auto const mjr = dip2 * d;
220 auto const dist2i = 1. / dist2;
221 auto const exp_adist2 = exp(-
Utils::sqr(adist));
224 ? dist2i * (erfc_part_ri + coeff) * exp_adist2
225 : dist2i * (erfc(adist) / dist + coeff * exp_adist2);
226 auto const C_r = (3. * B_r + 2. * alpsq * coeff * exp_adist2) * dist2i;
228 return prefactor * (mimj * B_r - mir * mjr * C_r);
Vector implementation and trait types for boost qvm interoperability.
double prefactor
Magnetostatics prefactor.
This file contains the defaults for ESPResSo.
__device__ void vector_product(float const *a, float const *b, float *out)
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.
Common functions for dipolar and charge P3M.
void sanity_checks_boxl() const
Checks for correctness of the k-space cutoff.
virtual void init()=0
Recalculate all derived parameters.
virtual bool is_gpu() const noexcept=0
void sanity_checks() const
virtual void scaleby_box_l()=0
virtual void tune()=0
Tune dipolar P3M parameters to desired accuracy.
virtual void npt_add_virial_contribution(double energy) const =0
Update the NpT virial.
virtual void calc_energy_correction()=0
Calculate energy correction that minimizes the error.
void on_node_grid_change() const
virtual bool is_double_precision() const noexcept=0
void on_boxl_change()
Recalculate all box-length-dependent parameters.
void sanity_checks_cell_structure() const
virtual double long_range_energy(ParticleRange const &particles)=0
Compute the k-space part of energies.
virtual ~DipolarP3M()=default
virtual void dipole_assign(ParticleRange const &particles)=0
Assign the physical dipoles using the tabulated assignment function.
P3MParameters const & dp3m_params
virtual void on_activation()=0
virtual void calc_influence_function_force()=0
Calculate the influence function for the dipolar forces and torques.
virtual double calc_average_self_energy_k_space() const =0
Calculate self-energy in k-space.
virtual bool is_tuned() const noexcept=0
void sanity_checks_periodicity() const
DipolarP3M(P3MParameters const &dp3m_params)
void sanity_checks_node_grid() const
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
virtual void count_magnetic_particles()=0
Count the number of magnetic particles and calculate the sum of the squared dipole moments.
virtual double calc_surface_term(bool force_flag, bool energy_flag, ParticleRange const &particles)=0
Compute the dipolar surface terms.
void on_cell_structure_change()
virtual void calc_influence_function_energy()=0
Calculate the influence function for the dipolar energy.
virtual void add_long_range_forces(ParticleRange const &particles)=0
Compute the k-space part of forces.
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 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