![]() |
ESPResSo 3.2.0-11-g9950804-git
Extensible Simulation Package for Soft Matter Research
|
P3M algorithm for long range magnetic dipole-dipole interaction. More...
#include "p3m-dipolar.h"#include <mpi.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "utils.h"#include "integrate.h"#include "global.h"#include "grid.h"#include "domain_decomposition.h"#include "particle_data.h"#include "communication.h"#include "fft-dipolar.h"#include "thermostat.h"#include "cells.h"#include "tuning.h"
Go to the source code of this file.
Defines | |
| #define | REQ_P3M_INIT_D 2001 |
| Tag for communication in P3M_init() -> send_calc_mesh(). | |
| #define | REQ_P3M_GATHER_D 2011 |
| Tag for communication in p3m_gather_fft_grid(). | |
| #define | REQ_P3M_SPREAD_D 2021 |
| Tag for communication in p3m_spread_force_grid(). | |
| #define | P3M_TUNE_MAX_CUTS 50 |
Functions | |
| static double | calc_surface_term (int force_flag, int energy_flag) |
| static double | dp3m_average_dipolar_self_energy (double box_l, int mesh) |
| static double | dp3m_perform_aliasing_sums_dipolar_self_energy (int n[3]) |
| void | dp3m_pre_init (void) |
| void | dp3m_init () |
| Initialize all structures, parameters and arrays needed for the P3M algorithm for dipole-dipole interactions. | |
| void | dp3m_free_dipoles () |
| void | dp3m_set_tune_params (double r_cut, int mesh, int cao, double alpha, double accuracy, int n_interpol) |
| int | dp3m_set_params (double r_cut, int mesh, int cao, double alpha, double accuracy) |
| int | dp3m_set_mesh_offset (double x, double y, double z) |
| int | dp3m_set_eps (double eps) |
| int | dp3m_set_ninterpol (int n) |
| void | dp3m_dipole_assign (void) |
| assign the physical dipoles using the tabulated assignment function. | |
| void | dp3m_assign_dipole (double real_pos[3], double mu, double dip[3], int cp_cnt) |
| assign a single dipole into the current charge grid. | |
| void | dp3m_shrink_wrap_dipole_grid (int n_dipoles) |
| shrink wrap the dipoles grid | |
| static void | P3M_assign_torques (double prefac, int d_rs) |
| static void | dp3m_assign_forces_dip (double prefac, int d_rs) |
| double | dp3m_calc_kspace_forces (int force_flag, int energy_flag) |
| compute the k-space part of forces and energies for the magnetic dipole-dipole interaction | |
| double | dp3m_get_accuracy (int mesh, int cao, double r_cut_iL, double *_alpha_L, double *_rs_err, double *_ks_err) |
| Tune dipolar P3M parameters to desired accuracy. | |
| static double | dp3m_mcr_time (int mesh, int cao, double r_cut_iL, double alpha_L) |
| get the optimal alpha and the corresponding computation time for fixed mesh, cao, r_cut and alpha | |
| static double | dp3m_mc_time (char **log, int mesh, int cao, double r_cut_iL_min, double r_cut_iL_max, double *_r_cut_iL, double *_alpha_L, double *_accuracy) |
| get the optimal alpha and the corresponding computation time for fixed mesh, cao. | |
| static double | dp3m_m_time (char **log, int mesh, int cao_min, int cao_max, int *_cao, double r_cut_iL_min, double r_cut_iL_max, double *_r_cut_iL, double *_alpha_L, double *_accuracy) |
| get the optimal alpha and the corresponding computation time for fixed mesh. | |
| int | dp3m_adaptive_tune (char **logger) |
| Tuning of dipolar P3M. | |
| void | p3m_print_dp3m_struct (p3m_parameter_struct ps) |
| void | dp3m_count_magnetic_particles () |
| Calculate number of magnetic particles, the sum of the squared charges and the squared sum of the charges. | |
| int | dp3m_sanity_checks () |
| sanity checks | |
| void | dp3m_scaleby_box_l () |
| Updates p3m_parameter_struct::alpha and p3m_parameter_struct::r_cut if box_l changed. | |
Private Functions | |
| static void | dp3m_calc_send_mesh () |
| Calculates for magnetic dipoles the properties of the send/recv sub-meshes of the local FFT mesh. | |
| static void | dp3m_init_a_ai_cao_cut () |
| Initializes for magnetic dipoles the (inverse) mesh constant p3m_parameter_struct::a (p3m_parameter_struct::ai) and the cutoff for charge assignment p3m_parameter_struct::cao_cut, which has to be done by dp3m_init once and by dp3m_scaleby_box_l whenever the box_l changed. | |
| static void | dp3m_calc_lm_ld_pos () |
| Calculate for magnetic dipoles the spacial position of the left down mesh point of the local mesh, to be stored in p3m_local_mesh::ld_pos; function called by dp3m_calc_local_ca_mesh once and by dp3m_scaleby_box_l whenever the box_l changed. | |
| static void | dp3m_gather_fft_grid (double *mesh) |
| Gather FFT grid. | |
| static void | dp3m_spread_force_grid (double *mesh) |
| Spread force grid. | |
| static void | dp3m_realloc_ca_fields (int newsize) |
| realloc charge assignment fields. | |
| static int | dp3m_sanity_checks_boxl (void) |
| checks for correctness for magnetic dipoles in P3M of the cao_cut, necessary when the box length changes | |
| static void | dp3m_calc_local_ca_mesh () |
| Calculates properties of the local FFT mesh for the charge assignment process. | |
| static void | dp3m_interpolate_dipole_assignment_function () |
| Interpolates the P-th order charge assignment function from Hockney/Eastwood 5-189 (or 8-61). | |
| static void | dp3m_calc_meshift () |
| shifts the mesh points by mesh/2 | |
| static void | dp3m_calc_differential_operator () |
| Calculates the Fourier transformed differential operator. | |
| static void | dp3m_calc_influence_function_force () |
| Calculates the influence function optimized for the dipolar forces. | |
| static void | dp3m_calc_influence_function_energy () |
| Calculates the influence function optimized for the dipolar energy and torques. | |
| static void | dp3m_compute_constants_energy_dipolar () |
| Calculates the constants necessary to correct the dipolar energy to minimize the error. | |
| static double | dp3m_perform_aliasing_sums_force (int n[3], double nominator[1]) |
| Calculates the aliasing sums for the optimal influence function. | |
| static double | dp3m_perform_aliasing_sums_energy (int n[3], double nominator[1]) |
| static double | dp3m_k_space_error (double box_size, double prefac, int mesh, int cao, int n_c_part, double sum_q2, double alpha_L) |
P3M Tuning Functions (private) | |
| double | P3M_DIPOLAR_real_space_error (double box_size, double prefac, double r_cut_iL, int n_c_part, double sum_q2, double alpha_L) |
| static void | dp3m_tune_aliasing_sums (int nx, int ny, int nz, int mesh, double mesh_i, int cao, double alpha_L_i, double *alias1, double *alias2) |
| double | dp3m_rtbisection (double box_size, double prefac, double r_cut_iL, int n_c_part, double sum_q2, double x1, double x2, double xacc, double tuned_accuracy) |
Exported Functions | |
| void | dp3m_set_bjerrum () |
| set bjerrum length for dipolar p3m | |
Variables | |
| dp3m_data_struct | dp3m |
| dipolar P3M parameters. | |
P3M algorithm for long range magnetic dipole-dipole interaction.
NB: In general the magnetic dipole-dipole functions bear the same name than the charge-charge but, adding in front of the name a D and replacing where "charge" appears by "dipole". In this way one can recognize the similarity of the functions but avoiding nasty confusions in their use.
PS: By default the magnetic epsilon is metallic = 0.
Definition in file p3m-dipolar.c.
| #define P3M_TUNE_MAX_CUTS 50 |
Definition at line 1531 of file p3m-dipolar.c.
| #define REQ_P3M_GATHER_D 2011 |
Tag for communication in p3m_gather_fft_grid().
Definition at line 61 of file p3m-dipolar.c.
Referenced by dp3m_gather_fft_grid().
| #define REQ_P3M_INIT_D 2001 |
Tag for communication in P3M_init() -> send_calc_mesh().
Definition at line 59 of file p3m-dipolar.c.
Referenced by dp3m_calc_send_mesh().
| #define REQ_P3M_SPREAD_D 2021 |
Tag for communication in p3m_spread_force_grid().
Definition at line 63 of file p3m-dipolar.c.
Referenced by dp3m_spread_force_grid().
| double calc_surface_term | ( | int | force_flag, |
| int | energy_flag | ||
| ) | [static] |
Definition at line 1119 of file p3m-dipolar.c.
References box_l_i, CellPList::cell, comm_cart, coulomb, ParticlePosition::dip, Coulomb_parameters::Dprefactor, p3m_parameter_struct::epsilon, Particle::f, free, i, local_cells, M_PI, malloc, MPI_Allreduce(), MPI_DOUBLE, MPI_IN_PLACE, MPI_SUM, CellPList::n, ParticleList::n, dp3m_data_struct::params, part, ParticleList::part, Particle::r, and ParticleForce::torque.
Referenced by dp3m_calc_kspace_forces().
| int dp3m_adaptive_tune | ( | char ** | logger | ) |
Tuning of dipolar P3M.
The algorithm basically determines the mesh, cao and then the real space cutoff, in this nested order.
For each mesh, the cao optimal for the mesh tested previously is used as an initial guess, and the algorithm tries whether increasing or decreasing it leads to a better solution. This is efficient, since the optimal cao only changes little with the meshes in general.
The real space cutoff for a given mesh and cao is determined via a bisection on the error estimate, which determines where the error estimate equals the required accuracy. Therefore the smallest possible, i.e. fastest real space cutoff is determined.
Both the search over mesh and cao stop to search in a specific direction once the computation time is significantly higher than the currently known optimum.
Definition at line 1865 of file p3m-dipolar.c.
References p3m_parameter_struct::accuracy, p3m_parameter_struct::alpha_L, box_l, box_l_i, p3m_parameter_struct::cao, dmin(), dp3m_m_time(), dp3m_scaleby_box_l(), ES_DOUBLE_SPACE, ES_ERROR, ES_INTEGER_SPACE, ES_OK, p3m_parameter_struct::mesh, min_box_l, min_local_box_l, mpi_bcast_coulomb_params(), mpi_bcast_event(), P3M_COUNT_DIPOLES, P3M_MAX_MESH, P3M_TIME_GRAN, P3M_TRACE, dp3m_data_struct::params, p3m_parameter_struct::r_cut_iL, skin, strcat_alloc(), dp3m_data_struct::sum_dip_part, dp3m_data_struct::sum_mu2, and this_node.
Referenced by tclcommand_inter_magnetic_parse_dp3m_tune_params().
| void dp3m_assign_dipole | ( | double | real_pos[3], |
| double | mu, | ||
| double | dip[3], | ||
| int | cp_cnt | ||
| ) |
assign a single dipole into the current charge grid.
cp_cnt gives the a running index, which may be smaller than 0, in which case the charge is assumed to be virtual and is not stored in the Dca_frac arrays.
Definition at line 657 of file p3m-dipolar.c.
References ADDITIONAL_CHECKS, p3m_parameter_struct::ai, dp3m_data_struct::ca_fmp, dp3m_data_struct::ca_frac, dp3m_data_struct::ca_num, p3m_parameter_struct::cao, p3m_parameter_struct::cao3, p3m_local_mesh::dim, dp3m_realloc_ca_fields(), i, dp3m_data_struct::int_caf, p3m_parameter_struct::inter, p3m_parameter_struct::inter2, p3m_local_mesh::ld_pos, dp3m_data_struct::local_mesh, my_left, my_right, p3m_caf(), dp3m_data_struct::params, dp3m_data_struct::pos_shift, p3m_local_mesh::q_21_off, p3m_local_mesh::q_2_off, dp3m_data_struct::rs_mesh_dip, skin, and this_node.
Referenced by dp3m_dipole_assign().
| static void dp3m_assign_forces_dip | ( | double | prefac, |
| int | d_rs | ||
| ) | [static] |
Definition at line 845 of file p3m-dipolar.c.
References dp3m_data_struct::ca_fmp, dp3m_data_struct::ca_frac, p3m_parameter_struct::cao, CellPList::cell, check_id, p3m_local_mesh::dim, ParticlePosition::dip, ParticleForce::f, Particle::f, i, local_cells, dp3m_data_struct::local_mesh, CellPList::n, ParticleList::n, ONEPART_TRACE, dp3m_data_struct::params, ParticleList::part, Particle::r, dp3m_data_struct::rs_mesh_dip, and this_node.
Referenced by dp3m_calc_kspace_forces().
| double dp3m_average_dipolar_self_energy | ( | double | box_l, |
| int | mesh | ||
| ) | [static] |
Definition at line 410 of file p3m-dipolar.c.
References comm_cart, dp3m_data_struct::d_op, dfft, dp3m_perform_aliasing_sums_dipolar_self_energy(), dp3m_data_struct::g_energy, i, p3m_parameter_struct::mesh, MPI_DOUBLE, MPI_Reduce(), MPI_SUM, fft_forw_plan::new_mesh, dp3m_data_struct::params, PI, fft_data_struct::plan, SQR(), and fft_forw_plan::start.
Referenced by dp3m_compute_constants_energy_dipolar().
| void dp3m_calc_differential_operator | ( | ) | [static] |
Calculates the Fourier transformed differential operator.
Remark: This is done on the level of n-vectors and not k-vectors, i.e. the prefactor i*2*PI/L is missing!
Definition at line 1345 of file p3m-dipolar.c.
References dp3m_data_struct::d_op, dround(), i, p3m_parameter_struct::mesh, dp3m_data_struct::params, and realloc.
Referenced by dp3m_init().
| void dp3m_calc_influence_function_energy | ( | ) | [static] |
Calculates the influence function optimized for the dipolar energy and torques.
Definition at line 1444 of file p3m-dipolar.c.
References box_l, dp3m_data_struct::d_op, dfft, dp3m_calc_meshift(), dp3m_perform_aliasing_sums_energy(), dp3m_data_struct::g_energy, i, p3m_parameter_struct::mesh, fft_forw_plan::new_mesh, dp3m_data_struct::params, fft_data_struct::plan, realloc, SQR(), and fft_forw_plan::start.
Referenced by dp3m_init(), and dp3m_scaleby_box_l().
| void dp3m_calc_influence_function_force | ( | ) | [static] |
Calculates the influence function optimized for the dipolar forces.
Definition at line 1362 of file p3m-dipolar.c.
References box_l, dp3m_data_struct::d_op, dfft, dp3m_calc_meshift(), dp3m_perform_aliasing_sums_force(), dp3m_data_struct::g_force, i, p3m_parameter_struct::mesh, fft_forw_plan::new_mesh, dp3m_data_struct::params, fft_data_struct::plan, realloc, SQR(), and fft_forw_plan::start.
Referenced by dp3m_init(), and dp3m_scaleby_box_l().
| double dp3m_calc_kspace_forces | ( | int | force_flag, |
| int | energy_flag | ||
| ) |
compute the k-space part of forces and energies for the magnetic dipole-dipole interaction
Definition at line 893 of file p3m-dipolar.c.
References p3m_parameter_struct::alpha_L, box_l, box_l_i, calc_surface_term(), comm_cart, coulomb, dp3m_data_struct::d_op, dfft, dfft_perform_back(), dfft_perform_forw(), dp3m_assign_forces_dip(), dp3m_compute_constants_energy_dipolar(), dp3m_gather_fft_grid(), dp3m_spread_force_grid(), Coulomb_parameters::Dprefactor, dp3m_data_struct::energy_correction, p3m_parameter_struct::epsilon, dp3m_data_struct::g_energy, dp3m_data_struct::g_force, i, dp3m_data_struct::ks_mesh, dp3m_data_struct::ks_pnum, p3m_parameter_struct::mesh, MPI_DOUBLE, MPI_Reduce(), MPI_SUM, fft_forw_plan::new_mesh, P3M_assign_torques(), P3M_EPSILON_METALLIC, P3M_TRACE, dp3m_data_struct::params, PI, fft_data_struct::plan, dp3m_data_struct::rs_mesh, dp3m_data_struct::rs_mesh_dip, SQR(), fft_forw_plan::start, dp3m_data_struct::sum_mu2, this_node, and wupii.
Referenced by calc_long_range_energies(), calc_long_range_forces(), and calc_long_range_virials().
| void dp3m_calc_lm_ld_pos | ( | ) | [static] |
Calculate for magnetic dipoles the spacial position of the left down mesh point of the local mesh, to be stored in p3m_local_mesh::ld_pos; function called by dp3m_calc_local_ca_mesh once and by dp3m_scaleby_box_l whenever the box_l changed.
Calculate the spacial position of the left down mesh point of the local mesh, to be stored in p3m_local_mesh::ld_pos; function called by dp3m_calc_local_ca_mesh once and by dp3m_scaleby_box_l whenever the box_l changed.
Definition at line 2205 of file p3m-dipolar.c.
References p3m_parameter_struct::a, i, p3m_local_mesh::ld_ind, p3m_local_mesh::ld_pos, dp3m_data_struct::local_mesh, p3m_parameter_struct::mesh_off, and dp3m_data_struct::params.
Referenced by dp3m_calc_local_ca_mesh(), and dp3m_scaleby_box_l().
| void dp3m_calc_local_ca_mesh | ( | ) | [static] |
Calculates properties of the local FFT mesh for the charge assignment process.
Definition at line 2230 of file p3m-dipolar.c.
References p3m_parameter_struct::additional_mesh, p3m_parameter_struct::ai, p3m_parameter_struct::cao, p3m_parameter_struct::cao_cut, p3m_local_mesh::dim, dp3m_calc_lm_ld_pos(), i, p3m_local_mesh::in_ld, p3m_local_mesh::in_ur, p3m_local_mesh::inner, p3m_local_mesh::ld_ind, dp3m_data_struct::local_mesh, p3m_local_mesh::margin, p3m_parameter_struct::mesh_off, my_left, my_right, dp3m_data_struct::params, p3m_local_mesh::q_21_off, p3m_local_mesh::q_2_off, ROUND_ERROR_PREC, p3m_local_mesh::size, and skin.
Referenced by dp3m_init().
| void dp3m_calc_meshift | ( | void | ) | [static] |
shifts the mesh points by mesh/2
Definition at line 1331 of file p3m-dipolar.c.
References dround(), i, p3m_parameter_struct::mesh, dp3m_data_struct::meshift, dp3m_data_struct::params, and realloc.
Referenced by dp3m_calc_influence_function_energy(), and dp3m_calc_influence_function_force().
| void dp3m_calc_send_mesh | ( | ) | [static] |
Calculates for magnetic dipoles the properties of the send/recv sub-meshes of the local FFT mesh.
In order to calculate the recv sub-meshes there is a communication of the margins between neighbouring nodes.
Definition at line 2368 of file p3m-dipolar.c.
References comm_cart, p3m_local_mesh::dim, i, p3m_local_mesh::in_ur, dp3m_data_struct::local_mesh, p3m_local_mesh::margin, p3m_send_mesh::max, MPI_INT, MPI_Recv(), MPI_Send(), node_neighbors, node_pos, p3m_send_mesh::r_dim, p3m_send_mesh::r_ld, p3m_local_mesh::r_margin, p3m_send_mesh::r_size, p3m_send_mesh::r_ur, REQ_P3M_INIT_D, p3m_send_mesh::s_dim, p3m_send_mesh::s_ld, p3m_send_mesh::s_size, p3m_send_mesh::s_ur, dp3m_data_struct::sm, and this_node.
Referenced by dp3m_init().
| void dp3m_compute_constants_energy_dipolar | ( | ) | [static] |
Calculates the constants necessary to correct the dipolar energy to minimize the error.
Definition at line 2466 of file p3m-dipolar.c.
References p3m_parameter_struct::alpha_L, box_l, dp3m_average_dipolar_self_energy(), dp3m_data_struct::energy_correction, p3m_parameter_struct::mesh, P3M_TRACE, dp3m_data_struct::params, PI, dp3m_data_struct::sum_mu2, this_node, and wupii.
Referenced by dp3m_calc_kspace_forces().
| void dp3m_count_magnetic_particles | ( | ) |
Calculate number of magnetic particles, the sum of the squared charges and the squared sum of the charges.
Definition at line 2017 of file p3m-dipolar.c.
References CellPList::cell, comm_cart, i, local_cells, MPI_Allreduce(), MPI_DOUBLE, MPI_SUM, CellPList::n, ParticleList::n, part, ParticleList::part, SQR(), dp3m_data_struct::sum_dip_part, and dp3m_data_struct::sum_mu2.
Referenced by dp3m_init(), mpi_bcast_event_slave(), and on_observable_calc().
| void dp3m_dipole_assign | ( | void | ) |
assign the physical dipoles using the tabulated assignment function.
If Dstore_ca_frac is true, then the charge fractions are buffered in Dcur_ca_fmp and Dcur_ca_frac.
Definition at line 628 of file p3m-dipolar.c.
References CellPList::cell, ParticlePosition::dip, ParticleProperties::dipm, dp3m_assign_dipole(), dp3m_shrink_wrap_dipole_grid(), i, local_cells, dp3m_data_struct::local_mesh, CellPList::n, ParticleList::n, Particle::p, ParticleList::part, Particle::r, dp3m_data_struct::rs_mesh_dip, and p3m_local_mesh::size.
Referenced by calc_long_range_energies(), calc_long_range_forces(), and calc_long_range_virials().
| void dp3m_free_dipoles | ( | ) |
Definition at line 400 of file p3m-dipolar.c.
References dp3m_data_struct::ca_fmp, dp3m_data_struct::ca_frac, free, i, dp3m_data_struct::ks_mesh, dp3m_data_struct::recv_grid, dp3m_data_struct::rs_mesh, dp3m_data_struct::rs_mesh_dip, and dp3m_data_struct::send_grid.
| void dp3m_gather_fft_grid | ( | double * | mesh | ) | [static] |
Gather FFT grid.
After the charge assignment Each node needs to gather the information for the FFT grid in his spatial domain.
Definition at line 1222 of file p3m-dipolar.c.
References comm_cart, p3m_local_mesh::dim, fft_pack_block(), dp3m_data_struct::local_mesh, MPI_DOUBLE, MPI_Recv(), MPI_Send(), node_neighbors, node_pos, p3m_add_block(), P3M_TRACE, p3m_send_mesh::r_dim, p3m_send_mesh::r_ld, p3m_send_mesh::r_size, dp3m_data_struct::recv_grid, REQ_P3M_GATHER_D, p3m_send_mesh::s_dim, p3m_send_mesh::s_ld, p3m_send_mesh::s_size, dp3m_data_struct::send_grid, dp3m_data_struct::sm, and this_node.
Referenced by dp3m_calc_kspace_forces().
| double dp3m_get_accuracy | ( | int | mesh, |
| int | cao, | ||
| double | r_cut_iL, | ||
| double * | _alpha_L, | ||
| double * | _rs_err, | ||
| double * | _ks_err | ||
| ) |
Tune dipolar P3M parameters to desired accuracy.
Usage:
inter dipolar <bjerrum> p3m tune accuracy <value> [r_cut <value> mesh <value> cao <value>]
The parameters are tuned to obtain the desired accuracy in best time, by running mpi_integrate(0) for several parameter sets.
The function utilizes the analytic expression of the error estimate for the dipolar P3M method see JCP,2008 paper by J.J.Cerda et al in order to obtain the rms error in the force for a system of N randomly distributed particles in a cubic box. For the real space error the estimate of Kolafa/Perram is used.
Parameter range if not given explicit values: For p3m_parameter_struct::r_cut_iL the function uses the values (min_local_box_l -skin) / (n * box_l), n being an integer (this implies the assumption that p3m_parameter_struct::r_cut_iL is the largest cutoff in the system!). For p3m_parameter_struct::mesh the function uses the two values which matches best the equation: number of mesh point = number of magnetic dipolar particles. For p3m_parameter_struct::cao the function considers all possible values.
For each setting p3m_parameter_struct::alpha_L is calculated assuming that the error contributions of real and reciprocal space should be equal.
After checking if the total error fulfils the accuracy goal the time needed for one force calculation (including verlet list update) is measured via mpi_integrate (0).
The function returns a log of the performed tuning.
The function is based on routines for charges. get the minimal error for this combination of parameters. In fact, the real space error is tuned such that it contributes half of the total error, and then the Fourier space error is calculated. Returns the error and the optimal alpha, or 0 if this combination does not work at all
Definition at line 1573 of file p3m-dipolar.c.
References p3m_parameter_struct::accuracy, box_l, coulomb, dp3m_k_space_error(), dp3m_rtbisection(), Coulomb_parameters::Dprefactor, M_SQRT2, P3M_DIPOLAR_real_space_error(), P3M_TRACE, dp3m_data_struct::params, SQR(), dp3m_data_struct::sum_dip_part, and dp3m_data_struct::sum_mu2.
Referenced by dp3m_mc_time().
| void dp3m_init | ( | void | ) |
Initialize all structures, parameters and arrays needed for the P3M algorithm for dipole-dipole interactions.
Definition at line 316 of file p3m-dipolar.c.
References CA_INCREMENT, dp3m_data_struct::ca_num, p3m_parameter_struct::cao, p3m_parameter_struct::cao3, coulomb, Coulomb_parameters::Dbjerrum, dfft_init(), p3m_local_mesh::dim, dp3m_calc_differential_operator(), dp3m_calc_influence_function_energy(), dp3m_calc_influence_function_force(), dp3m_calc_local_ca_mesh(), dp3m_calc_send_mesh(), dp3m_count_magnetic_particles(), dp3m_init_a_ai_cao_cut(), dp3m_interpolate_dipole_assignment_function(), dp3m_realloc_ca_fields(), dp3m_sanity_checks(), dp3m_scaleby_box_l(), p3m_parameter_struct::inter, dp3m_data_struct::ks_mesh, dp3m_data_struct::ks_pnum, dp3m_data_struct::local_mesh, p3m_local_mesh::margin, p3m_send_mesh::max, p3m_parameter_struct::mesh, p3m_parameter_struct::mesh_off, n_nodes, p3m_p3m_print_local_mesh(), p3m_p3m_print_send_mesh(), P3M_TRACE, dp3m_data_struct::params, dp3m_data_struct::pos_shift, p3m_parameter_struct::r_cut, p3m_parameter_struct::r_cut_iL, realloc, dp3m_data_struct::recv_grid, dp3m_data_struct::rs_mesh, dp3m_data_struct::rs_mesh_dip, dp3m_data_struct::send_grid, dp3m_data_struct::sm, and this_node.
Referenced by on_cell_structure_change(), and on_coulomb_change().
| void dp3m_init_a_ai_cao_cut | ( | ) | [static] |
Initializes for magnetic dipoles the (inverse) mesh constant p3m_parameter_struct::a (p3m_parameter_struct::ai) and the cutoff for charge assignment p3m_parameter_struct::cao_cut, which has to be done by dp3m_init once and by dp3m_scaleby_box_l whenever the box_l changed.
Initializes the (inverse) mesh constant p3m_parameter_struct::a (p3m_parameter_struct::ai) and the cutoff for charge assignment p3m_parameter_struct::cao_cut, which has to be done by dp3m_init once and by dp3m_scaleby_box_l whenever the box_l changed.
Definition at line 2217 of file p3m-dipolar.c.
References p3m_parameter_struct::a, p3m_parameter_struct::ai, box_l, p3m_parameter_struct::cao, p3m_parameter_struct::cao_cut, i, p3m_parameter_struct::mesh, and dp3m_data_struct::params.
Referenced by dp3m_init(), and dp3m_scaleby_box_l().
| void dp3m_interpolate_dipole_assignment_function | ( | ) | [static] |
Interpolates the P-th order charge assignment function from Hockney/Eastwood 5-189 (or 8-61).
The following charge fractions are also tabulated in Deserno/Holm.
Definition at line 603 of file p3m-dipolar.c.
References p3m_parameter_struct::cao, i, dp3m_data_struct::int_caf, p3m_parameter_struct::inter, p3m_parameter_struct::inter2, p3m_caf(), P3M_TRACE, dp3m_data_struct::params, realloc, and this_node.
Referenced by dp3m_init().
| static double dp3m_k_space_error | ( | double | box_size, |
| double | prefac, | ||
| int | mesh, | ||
| int | cao, | ||
| int | n_c_part, | ||
| double | sum_q2, | ||
| double | alpha_L | ||
| ) | [static] |
Definition at line 2065 of file p3m-dipolar.c.
References dp3m_tune_aliasing_sums(), p3m_analytic_cotangent_sum(), PI, ROUND_ERROR_PREC, and SQR().
Referenced by dp3m_get_accuracy().
| static double dp3m_m_time | ( | char ** | log, |
| int | mesh, | ||
| int | cao_min, | ||
| int | cao_max, | ||
| int * | _cao, | ||
| double | r_cut_iL_min, | ||
| double | r_cut_iL_max, | ||
| double * | _r_cut_iL, | ||
| double * | _alpha_L, | ||
| double * | _accuracy | ||
| ) | [static] |
get the optimal alpha and the corresponding computation time for fixed mesh.
*cao should contain an initial guess, which is then adapted by stepping up and down. Returns the time upon completion, -1 if the force evaluation does not work, and -2 if the accuracy cannot be met
Definition at line 1729 of file p3m-dipolar.c.
References dp3m_mc_time(), P3M_TIME_GRAN, and P3M_TRACE.
Referenced by dp3m_adaptive_tune().
| static double dp3m_mc_time | ( | char ** | log, |
| int | mesh, | ||
| int | cao, | ||
| double | r_cut_iL_min, | ||
| double | r_cut_iL_max, | ||
| double * | _r_cut_iL, | ||
| double * | _alpha_L, | ||
| double * | _accuracy | ||
| ) | [static] |
get the optimal alpha and the corresponding computation time for fixed mesh, cao.
The r_cut is determined via a simple bisection. Returns -1 if the force evaluation does not work, -2 if there is no valid r_cut, and -3 if the charge assigment order is to large for this grid
Definition at line 1639 of file p3m-dipolar.c.
References p3m_parameter_struct::accuracy, box_l, coulomb, DIPOLAR_MDLC_P3M, Coulomb_parameters::Dmethod, dmin(), dp3m_get_accuracy(), dp3m_mcr_time(), ERROR_SPRINTF, ES_DOUBLE_SPACE, ES_INTEGER_SPACE, i, local_box_l, min_box_l, min_local_box_l, min_num_cells, n_cells, P3M_RCUT_PREC, P3M_TRACE, dp3m_data_struct::params, runtime_error(), skin, and strcat_alloc().
Referenced by dp3m_m_time().
| static double dp3m_mcr_time | ( | int | mesh, |
| int | cao, | ||
| double | r_cut_iL, | ||
| double | alpha_L | ||
| ) | [static] |
get the optimal alpha and the corresponding computation time for fixed mesh, cao, r_cut and alpha
Definition at line 1614 of file p3m-dipolar.c.
References p3m_parameter_struct::alpha_L, p3m_parameter_struct::cao, coulomb, DIPOLAR_MDLC_P3M, DIPOLAR_P3M, Coulomb_parameters::Dmethod, dp3m_scaleby_box_l(), p3m_parameter_struct::mesh, mpi_bcast_coulomb_params(), dp3m_data_struct::params, p3m_parameter_struct::r_cut_iL, dp3m_data_struct::sum_dip_part, and time_force_calc().
Referenced by dp3m_mc_time().
| double dp3m_perform_aliasing_sums_dipolar_self_energy | ( | int | n[3] | ) | [static] |
Definition at line 452 of file p3m-dipolar.c.
References p3m_parameter_struct::cao, p3m_parameter_struct::mesh, dp3m_data_struct::meshift, P3M_BRILLOUIN, dp3m_data_struct::params, and sinc().
Referenced by dp3m_average_dipolar_self_energy().
| double dp3m_perform_aliasing_sums_energy | ( | int | n[3], |
| double | nominator[1] | ||
| ) | [static] |
Definition at line 1483 of file p3m-dipolar.c.
References p3m_parameter_struct::alpha_L, p3m_parameter_struct::cao, dp3m_data_struct::d_op, p3m_parameter_struct::mesh, dp3m_data_struct::meshift, P3M_BRILLOUIN, dp3m_data_struct::params, PI, sinc(), and SQR().
Referenced by dp3m_calc_influence_function_energy().
| double dp3m_perform_aliasing_sums_force | ( | int | n[3], |
| double | nominator[1] | ||
| ) | [static] |
Calculates the aliasing sums for the optimal influence function.
Calculates the aliasing sums in the nominator and denominator of the expression for the optimal influence function (see Hockney/Eastwood: 8-22, p. 275).
| n | n-vector for which the aliasing sum is to be performed. |
| nominator | aliasing sums in the nominator. |
Definition at line 1402 of file p3m-dipolar.c.
References p3m_parameter_struct::alpha_L, p3m_parameter_struct::cao, dp3m_data_struct::d_op, p3m_parameter_struct::mesh, dp3m_data_struct::meshift, P3M_BRILLOUIN, dp3m_data_struct::params, PI, sinc(), and SQR().
Referenced by dp3m_calc_influence_function_force().
| void dp3m_pre_init | ( | void | ) |
Definition at line 267 of file p3m-dipolar.c.
References dp3m_data_struct::ca_fmp, dp3m_data_struct::ca_frac, dp3m_data_struct::ca_num, dp3m_data_struct::d_op, dfft_pre_init(), dp3m_data_struct::energy_correction, p3m_parameter_struct::epsilon, dp3m_data_struct::g_energy, dp3m_data_struct::g_force, i, dp3m_data_struct::int_caf, dp3m_data_struct::ks_mesh, dp3m_data_struct::ks_pnum, dp3m_data_struct::meshift, p3m_common_parameter_pre_init(), P3M_EPSILON_MAGNETIC, dp3m_data_struct::params, dp3m_data_struct::pos_shift, dp3m_data_struct::recv_grid, dp3m_data_struct::rs_mesh, dp3m_data_struct::rs_mesh_dip, dp3m_data_struct::send_grid, dp3m_data_struct::sum_dip_part, and dp3m_data_struct::sum_mu2.
Referenced by on_program_start().
| void dp3m_realloc_ca_fields | ( | int | newsize | ) | [static] |
realloc charge assignment fields.
Definition at line 1314 of file p3m-dipolar.c.
References dp3m_data_struct::ca_fmp, dp3m_data_struct::ca_frac, CA_INCREMENT, dp3m_data_struct::ca_num, p3m_parameter_struct::cao3, P3M_TRACE, dp3m_data_struct::params, realloc, and this_node.
Referenced by dp3m_assign_dipole(), dp3m_init(), and dp3m_shrink_wrap_dipole_grid().
| double dp3m_rtbisection | ( | double | box_size, |
| double | prefac, | ||
| double | r_cut_iL, | ||
| int | n_c_part, | ||
| double | sum_q2, | ||
| double | x1, | ||
| double | x2, | ||
| double | xacc, | ||
| double | tuned_accuracy | ||
| ) |
Definition at line 2178 of file p3m-dipolar.c.
References P3M_DIPOLAR_real_space_error().
Referenced by dp3m_get_accuracy().
| int dp3m_sanity_checks | ( | ) |
sanity checks
Definition at line 2303 of file p3m-dipolar.c.
References box_l, p3m_parameter_struct::cao, cell_structure, CELL_STRUCTURE_DOMDEC, dp3m_sanity_checks_boxl(), ERROR_SPRINTF, p3m_parameter_struct::mesh, node_grid, dp3m_data_struct::params, PERIODIC, runtime_error(), skin, and CellStructure::type.
Referenced by check_obs_calc_initialized(), and dp3m_init().
| int dp3m_sanity_checks_boxl | ( | void | ) | [static] |
checks for correctness for magnetic dipoles in P3M of the cao_cut, necessary when the box length changes
Definition at line 2281 of file p3m-dipolar.c.
References box_l, p3m_parameter_struct::cao_cut, ERROR_SPRINTF, ES_DOUBLE_SPACE, i, local_box_l, dp3m_data_struct::params, and runtime_error().
Referenced by dp3m_sanity_checks(), and dp3m_scaleby_box_l().
| void dp3m_scaleby_box_l | ( | ) |
Updates p3m_parameter_struct::alpha and p3m_parameter_struct::r_cut if box_l changed.
Definition at line 2447 of file p3m-dipolar.c.
References p3m_parameter_struct::alpha, p3m_parameter_struct::alpha_L, box_l, box_l_i, coulomb, Coulomb_parameters::Dbjerrum, dp3m_calc_influence_function_energy(), dp3m_calc_influence_function_force(), dp3m_calc_lm_ld_pos(), dp3m_init_a_ai_cao_cut(), dp3m_sanity_checks_boxl(), dp3m_data_struct::params, p3m_parameter_struct::r_cut, and p3m_parameter_struct::r_cut_iL.
Referenced by dp3m_adaptive_tune(), dp3m_init(), dp3m_mcr_time(), and on_boxl_change().
| void dp3m_set_bjerrum | ( | ) |
set bjerrum length for dipolar p3m
Definition at line 304 of file p3m-dipolar.c.
References p3m_parameter_struct::alpha, p3m_parameter_struct::alpha_L, p3m_parameter_struct::cao, p3m_parameter_struct::mesh, dp3m_data_struct::params, p3m_parameter_struct::r_cut, and p3m_parameter_struct::r_cut_iL.
Referenced by dipolar_set_Dbjerrum().
| int dp3m_set_eps | ( | double | eps | ) |
Definition at line 575 of file p3m-dipolar.c.
References p3m_parameter_struct::epsilon, ES_OK, mpi_bcast_coulomb_params(), and dp3m_data_struct::params.
Referenced by tclcommand_inter_magnetic_parse_dp3m_opt_params().
| int dp3m_set_mesh_offset | ( | double | x, |
| double | y, | ||
| double | z | ||
| ) |
Definition at line 555 of file p3m-dipolar.c.
References ES_ERROR, ES_OK, p3m_parameter_struct::mesh_off, mpi_bcast_coulomb_params(), and dp3m_data_struct::params.
Referenced by tclcommand_inter_magnetic_parse_dp3m_opt_params().
| int dp3m_set_ninterpol | ( | int | n | ) |
Definition at line 588 of file p3m-dipolar.c.
References ES_ERROR, ES_OK, p3m_parameter_struct::inter, mpi_bcast_coulomb_params(), and dp3m_data_struct::params.
Referenced by tclcommand_inter_magnetic_parse_dp3m_opt_params().
| int dp3m_set_params | ( | double | r_cut, |
| int | mesh, | ||
| int | cao, | ||
| double | alpha, | ||
| double | accuracy | ||
| ) |
Definition at line 515 of file p3m-dipolar.c.
References p3m_parameter_struct::accuracy, p3m_parameter_struct::alpha, p3m_parameter_struct::alpha_L, box_l, box_l_i, p3m_parameter_struct::cao, coulomb, DIPOLAR_MDLC_P3M, DIPOLAR_P3M, Coulomb_parameters::Dmethod, p3m_parameter_struct::mesh, mpi_bcast_coulomb_params(), dp3m_data_struct::params, p3m_parameter_struct::r_cut, and p3m_parameter_struct::r_cut_iL.
Referenced by tclcommand_inter_magnetic_parse_dp3m().
| void dp3m_set_tune_params | ( | double | r_cut, |
| int | mesh, | ||
| int | cao, | ||
| double | alpha, | ||
| double | accuracy, | ||
| int | n_interpol | ||
| ) |
Definition at line 483 of file p3m-dipolar.c.
References p3m_parameter_struct::accuracy, p3m_parameter_struct::alpha, p3m_parameter_struct::alpha_L, box_l, box_l_i, p3m_parameter_struct::cao, coulomb, Coulomb_parameters::Dbjerrum, Coulomb_parameters::Dprefactor, p3m_parameter_struct::inter, p3m_parameter_struct::mesh, dp3m_data_struct::params, p3m_parameter_struct::r_cut, p3m_parameter_struct::r_cut_iL, and temperature.
Referenced by tclcommand_inter_magnetic_parse_dp3m_tune_params().
| void dp3m_shrink_wrap_dipole_grid | ( | int | n_dipoles | ) |
shrink wrap the dipoles grid
Definition at line 774 of file p3m-dipolar.c.
References dp3m_data_struct::ca_num, and dp3m_realloc_ca_fields().
Referenced by dp3m_dipole_assign().
| void dp3m_spread_force_grid | ( | double * | mesh | ) | [static] |
Spread force grid.
After the k-space calculations each node needs to get all force information to reassigne the forces from the grid to the particles.
Definition at line 1270 of file p3m-dipolar.c.
References comm_cart, p3m_local_mesh::dim, fft_pack_block(), fft_unpack_block(), dp3m_data_struct::local_mesh, MPI_DOUBLE, MPI_Recv(), MPI_Send(), node_neighbors, node_pos, P3M_TRACE, p3m_send_mesh::r_dim, p3m_send_mesh::r_ld, p3m_send_mesh::r_size, dp3m_data_struct::recv_grid, REQ_P3M_SPREAD_D, p3m_send_mesh::s_dim, p3m_send_mesh::s_ld, p3m_send_mesh::s_size, dp3m_data_struct::send_grid, dp3m_data_struct::sm, and this_node.
Referenced by dp3m_calc_kspace_forces().
| void dp3m_tune_aliasing_sums | ( | int | nx, |
| int | ny, | ||
| int | nz, | ||
| int | mesh, | ||
| double | mesh_i, | ||
| int | cao, | ||
| double | alpha_L_i, | ||
| double * | alias1, | ||
| double * | alias2 | ||
| ) | [static] |
Definition at line 2091 of file p3m-dipolar.c.
References P3M_BRILLOUIN, PI, sinc(), and SQR().
Referenced by dp3m_k_space_error().
| static void P3M_assign_torques | ( | double | prefac, |
| int | d_rs | ||
| ) | [static] |
Definition at line 781 of file p3m-dipolar.c.
References dp3m_data_struct::ca_fmp, dp3m_data_struct::ca_frac, p3m_parameter_struct::cao, CellPList::cell, check_id, p3m_local_mesh::dim, ParticlePosition::dip, ParticleForce::f, Particle::f, i, local_cells, dp3m_data_struct::local_mesh, CellPList::n, ParticleList::n, ONEPART_TRACE, dp3m_data_struct::params, ParticleList::part, Particle::r, dp3m_data_struct::rs_mesh, this_node, and ParticleForce::torque.
Referenced by dp3m_calc_kspace_forces().
| double P3M_DIPOLAR_real_space_error | ( | double | box_size, |
| double | prefac, | ||
| double | r_cut_iL, | ||
| int | n_c_part, | ||
| double | sum_q2, | ||
| double | alpha_L | ||
| ) |
Definition at line 2138 of file p3m-dipolar.c.
Referenced by dp3m_get_accuracy(), and dp3m_rtbisection().
| void p3m_print_dp3m_struct | ( | p3m_parameter_struct | ps | ) |
Definition at line 2000 of file p3m-dipolar.c.
References p3m_parameter_struct::a, p3m_parameter_struct::ai, p3m_parameter_struct::alpha_L, p3m_parameter_struct::cao, p3m_parameter_struct::cao_cut, p3m_parameter_struct::epsilon, p3m_parameter_struct::inter, p3m_parameter_struct::mesh, p3m_parameter_struct::mesh_off, p3m_parameter_struct::r_cut_iL, and this_node.
dipolar P3M parameters.
Definition at line 69 of file p3m-dipolar.c.
Referenced by add_mdlc_energy_corrections(), add_mdlc_force_corrections(), mpi_bcast_coulomb_params_slave(), recalc_global_maximal_nonbonded_cutoff(), and tclprint_to_result_dp3m().
1.7.5.1