67 [[nodiscard]]
virtual bool is_tuned() const noexcept = 0;
68 [[nodiscard]] virtual
bool is_gpu() const noexcept = 0;
153#if USE_ERFC_APPROXIMATION
156 auto const erfc_part_ri = erfc(adist) / dist;
160 auto const mimj = dip1 * dip2;
162 auto const mir = dip1 * d;
163 auto const mjr = dip2 * d;
166 auto const dist2i = 1. / dist2;
167 auto const exp_adist2 = exp(-
Utils::sqr(adist));
170 ? (erfc_part_ri + coeff) * exp_adist2 * dist2i
171 : (erfc(adist) / dist + coeff * exp_adist2) * dist2i;
173 auto const common_term = alpsq * coeff * exp_adist2;
174 auto const C_r = dist2i * (3. * B_r + 2. * common_term);
175 auto const D_r = dist2i * (5. * C_r + 4. * common_term * alpsq);
178 auto const force =
prefactor * ((mimj * d + dip1 * mjr + dip2 * mir) * C_r -
179 mir * mjr * D_r * d);
186 auto const torque =
prefactor * (-mixmj * B_r + mixr * (mjr * C_r));
188#if USE_ERFC_APPROXIMATION
193 auto const energy = fac * (mimj * B_r - mir * mjr * C_r);
213#if USE_ERFC_APPROXIMATION
216 auto const erfc_part_ri = erfc(adist) / dist;
220 auto const mimj = dip1 * dip2;
221 auto const mir = dip1 * d;
222 auto const mjr = dip2 * d;
225 auto const dist2i = 1. / dist2;
226 auto const exp_adist2 = exp(-
Utils::sqr(adist));
229 ? dist2i * (erfc_part_ri + coeff) * exp_adist2
230 : dist2i * (erfc(adist) / dist + coeff * exp_adist2);
231 auto const C_r = (3. * B_r + 2. * alpsq * coeff * exp_adist2) * dist2i;
233 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)
void npt_add_virial_magnetic_contribution(double energy)
Update the NpT virial.
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 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