![]() |
ESPResSo 3.2.0-159-gf5c8922-git
Extensible Simulation Package for Soft Matter Research
|
code for calculating the MDLC (magnetic dipolar layer correction). More...


Go to the source code of this file.
Data Structures | |
| struct | p3m_data_struct |
Variables | |
| p3m_data_struct | p3m |
| P3M parameters. | |
Exported Functions | |
| enum | P3M_TUNE_ERROR { P3M_TUNE_FAIL = 1, P3M_TUNE_NOCUTOFF = 2, P3M_TUNE_CAOTOLARGE = 4, P3M_TUNE_ELCTEST = 8, P3M_TUNE_CUTOFF_TOO_LARGE = 16 } |
| Error Codes for p3m tuning (version 2) : P3M_TUNE_FAIL: force evaluation failes, P3M_TUNE_NO_CUTOFF: could not finde a valid realspace cutoff radius, P3M_TUNE_CAOTOLARGE: Charge asignment order to large for mesh size, P3M_TUNE_ELCTEST: conflict with ELC gap size. More... | |
| void | p3m_pre_init (void) |
| void | p3m_set_bjerrum (void) |
| int | p3m_adaptive_tune (char **log) |
| void | p3m_init (void) |
| Initialize all structures, parameters and arrays needed for the P3M algorithm for charge-charge interactions. | |
| void | p3m_scaleby_box_l () |
| Updates p3m_parameter_struct::alpha and p3m_parameter_struct::r_cut if box_l changed. | |
| double | p3m_calc_kspace_forces (int force_flag, int energy_flag) |
| compute the k-space part of forces and energies for the charge-charge interaction | |
| void | p3m_calc_kspace_stress (double *stress) |
| computer the k-space part of the stress tensor | |
| int | p3m_sanity_checks () |
| sanity checks | |
| void | p3m_count_charged_particles () |
| Calculate number of charged particles, the sum of the squared charges and the squared sum of the charges. | |
| void | p3m_charge_assign () |
| Tune P3M parameters to desired accuracy. | |
| void | p3m_assign_charge (double q, double real_pos[3], int cp_cnt) |
| assign a single charge into the current charge grid. | |
| void | p3m_shrink_wrap_charge_grid (int n_charges) |
| shrink wrap the charge grid | |
| MDINLINE double | p3m_add_pair_force (double chgfac, double *d, double dist2, double dist, double force[3]) |
| Calculate real space contribution of coulomb pair forces. | |
| void | p3m_set_tune_params (double r_cut, int mesh[3], int cao, double alpha, double accuracy, int n_interpol) |
| int | p3m_set_params (double r_cut, int *mesh, int cao, double alpha, double accuracy) |
| int | p3m_set_mesh_offset (double x, double y, double z) |
| int | p3m_set_eps (double eps) |
| int | p3m_set_ninterpol (int n) |
| MDINLINE double | p3m_pair_energy (double chgfac, double *d, double dist2, double dist) |
| Calculate real space contribution of coulomb pair energy. | |
| void | p3m_free () |
| Clean up P3M memory allocations. | |
code for calculating the MDLC (magnetic dipolar layer correction).
P3M algorithm for long range coulomb interaction.
main header-file for MDLC (magnetic dipolar layer correction).
Purpose: get the corrections for dipolar 3D algorithms when applied to a slab geometry and dipolar particles. DLC & co Article: A. Brodka, Chemical Physics Letters 400, 62-67 (2004).
We also include a tuning function that returns the cut-off necessary to attend a certain accuracy.
Restrictions: the slab must be such that the z is the short direction. Othewise we get trash.
Developer: Joan J. Cerda. Purpose: get the corrections for dipolar 3D algorithms when applied to a slab geometry and dipolar particles. DLC & co Article: A. Brodka, Chemical Physics Letters 400, 62-67 (2004).
We also include a tuning function that returns the cut-off necessary to attend a certain accuracy.
Restrictions: the slab must be such that the z is the short direction. Othewise we get trash.
Limitations: at this moment it is restricted to work with 1 cpu
We use a P3M (Particle-Particle Particle-Mesh) method based on the Ewald summation. Details of the used method can be found in Hockney/Eastwood and Deserno/Holm.
Further reading:
Definition in file p3m.h.
| enum P3M_TUNE_ERROR |
Error Codes for p3m tuning (version 2) : P3M_TUNE_FAIL: force evaluation failes, P3M_TUNE_NO_CUTOFF: could not finde a valid realspace cutoff radius, P3M_TUNE_CAOTOLARGE: Charge asignment order to large for mesh size, P3M_TUNE_ELCTEST: conflict with ELC gap size.
| int p3m_adaptive_tune | ( | char ** | log | ) |
Definition at line 1469 of file p3m.c.
References p3m_parameter_struct::accuracy, p3m_parameter_struct::alpha_L, box_l, box_l_i, p3m_parameter_struct::cao, dmin(), p3m_parameter_struct::epsilon, 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_CHARGES, P3M_EPSILON_METALLIC, p3m_m_time(), p3m_print(), p3m_scaleby_box_l(), P3M_TIME_GRAN, P3M_TRACE, p3m_data_struct::params, p3m_parameter_struct::r_cut_iL, skin, strcat_alloc(), p3m_data_struct::sum_q2, p3m_data_struct::sum_qpart, and this_node.
Referenced by tclcommand_inter_coulomb_parse_p3m_tune().
| MDINLINE double p3m_add_pair_force | ( | double | chgfac, |
| double * | d, | ||
| double | dist2, | ||
| double | dist, | ||
| double | force[3] | ||
| ) |
Calculate real space contribution of coulomb pair forces.
If NPT is compiled in, it returns the energy, which is needed for NPT.
Definition at line 212 of file p3m.h.
References p3m_parameter_struct::alpha, AS_erfc_part(), coulomb, ESR_TRACE, p3m_data_struct::params, Coulomb_parameters::prefactor, p3m_parameter_struct::r_cut, this_node, and wupii.
Referenced by add_non_bonded_pair_force(), add_non_bonded_pair_force_iccp3m(), ELC_P3M_dielectric_layers_force_contribution(), and ELC_P3M_self_forces().
| void p3m_assign_charge | ( | double | q, |
| double | real_pos[3], | ||
| int | cp_cnt | ||
| ) |
assign a single charge 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 ca_frac arrays.
Definition at line 536 of file p3m.c.
References p3m_parameter_struct::ai, p3m_data_struct::ca_fmp, p3m_data_struct::ca_frac, p3m_data_struct::ca_num, p3m_parameter_struct::cao, p3m_parameter_struct::cao3, p3m_local_mesh::dim, p3m_data_struct::int_caf, p3m_parameter_struct::inter, p3m_parameter_struct::inter2, p3m_local_mesh::ld_pos, p3m_data_struct::local_mesh, my_left, my_right, p3m_caf(), p3m_realloc_ca_fields(), p3m_data_struct::params, p3m_data_struct::pos_shift, p3m_local_mesh::q_21_off, p3m_local_mesh::q_2_off, p3m_data_struct::rs_mesh, skin, and this_node.
Referenced by ELC_p3m_charge_assign_both(), ELC_p3m_charge_assign_image(), and p3m_charge_assign().
| double p3m_calc_kspace_forces | ( | int | force_flag, |
| int | energy_flag | ||
| ) |
compute the k-space part of forces and energies for the charge-charge interaction
Definition at line 745 of file p3m.c.
References p3m_parameter_struct::alpha, box_l, comm_cart, coulomb, p3m_data_struct::d_op, p3m_parameter_struct::epsilon, fft, fft_perform_back(), fft_perform_forw(), p3m_data_struct::g_energy, p3m_data_struct::g_force, i, p3m_data_struct::ks_mesh, p3m_data_struct::ks_pnum, KX, KY, KZ, MPI_DOUBLE, MPI_Reduce(), MPI_SUM, fft_forw_plan::new_mesh, fft_forw_plan::new_size, P3M_assign_forces(), p3m_calc_dipole_term(), P3M_EPSILON_METALLIC, p3m_gather_fft_grid(), p3m_spread_force_grid(), P3M_TRACE, p3m_data_struct::params, PI, fft_data_struct::plan, Coulomb_parameters::prefactor, p3m_data_struct::rs_mesh, RX, RY, RZ, SQR(), p3m_data_struct::square_sum_q, fft_forw_plan::start, p3m_data_struct::sum_q2, this_node, and wupii.
Referenced by calc_long_range_energies(), calc_long_range_forces(), calc_long_range_forces_iccp3m(), and calc_long_range_virials().
| void p3m_calc_kspace_stress | ( | double * | stress | ) |
computer the k-space part of the stress tensor
Definition at line 2000 of file p3m.c.
References p3m_parameter_struct::alpha, box_l, comm_cart, coulomb, p3m_data_struct::d_op, fft, fft_perform_forw(), free, p3m_data_struct::g_energy, i, malloc, MPI_DOUBLE, MPI_Reduce(), MPI_SUM, fft_forw_plan::new_mesh, p3m_gather_fft_grid(), p3m_data_struct::params, PI, fft_data_struct::plan, Coulomb_parameters::prefactor, p3m_data_struct::rs_mesh, SQR(), fft_forw_plan::start, and p3m_data_struct::sum_q2.
Referenced by calc_long_range_virials().
| void p3m_charge_assign | ( | ) |
Tune P3M parameters to desired accuracy.
Usage:
inter coulomb <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 P3M method in the book of Hockney and Eastwood (Eqn. 8.23) 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 charged 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 of the program HE_Q.c written by M. Deserno. assign the physical charges using the tabulated charge assignment function. If store_ca_frac is true, then the charge fractions are buffered in cur_ca_fmp and cur_ca_frac.
Definition at line 509 of file p3m.c.
References CellPList::cell, i, local_cells, p3m_data_struct::local_mesh, CellPList::n, ParticleList::n, ParticlePosition::p, p3m_assign_charge(), p3m_shrink_wrap_charge_grid(), ParticleList::part, Particle::r, p3m_data_struct::rs_mesh, and p3m_local_mesh::size.
Referenced by calc_long_range_energies(), calc_long_range_forces(), calc_long_range_forces_iccp3m(), and calc_long_range_virials().
| void p3m_count_charged_particles | ( | ) |
Calculate number of charged particles, the sum of the squared charges and the squared sum of the charges.
Definition at line 1645 of file p3m.c.
References CellPList::cell, comm_cart, i, local_cells, MPI_Allreduce(), MPI_DOUBLE, MPI_SUM, CellPList::n, ParticleList::n, Particle::p, P3M_TRACE, ParticleList::part, ParticleProperties::q, SQR(), p3m_data_struct::square_sum_q, p3m_data_struct::sum_q2, p3m_data_struct::sum_qpart, and this_node.
Referenced by mpi_bcast_event_slave(), on_observable_calc(), and p3m_init().
| void p3m_free | ( | ) |
Clean up P3M memory allocations.
Definition at line 265 of file p3m.c.
References p3m_data_struct::ca_fmp, p3m_data_struct::ca_frac, p3m_parameter_struct::cao, free, i, p3m_data_struct::int_caf, p3m_data_struct::ks_mesh, p3m_data_struct::params, p3m_data_struct::recv_grid, p3m_data_struct::rs_mesh, and p3m_data_struct::send_grid.
| void p3m_init | ( | void | ) |
Initialize all structures, parameters and arrays needed for the P3M algorithm for charge-charge interactions.
Definition at line 291 of file p3m.c.
References Coulomb_parameters::bjerrum, CA_INCREMENT, p3m_data_struct::ca_num, p3m_parameter_struct::cao, p3m_parameter_struct::cao3, coulomb, p3m_local_mesh::dim, fft_init(), p3m_parameter_struct::inter, p3m_data_struct::ks_mesh, p3m_data_struct::ks_pnum, p3m_data_struct::local_mesh, p3m_local_mesh::margin, p3m_send_mesh::max, p3m_parameter_struct::mesh, p3m_parameter_struct::mesh_off, p3m_calc_differential_operator(), p3m_calc_influence_function_energy(), p3m_calc_influence_function_force(), p3m_calc_local_ca_mesh(), p3m_calc_send_mesh(), p3m_count_charged_particles(), p3m_init_a_ai_cao_cut(), p3m_interpolate_charge_assignment_function(), p3m_p3m_print_local_mesh(), p3m_p3m_print_send_mesh(), p3m_realloc_ca_fields(), p3m_sanity_checks(), p3m_scaleby_box_l(), P3M_TRACE, p3m_data_struct::params, p3m_data_struct::pos_shift, p3m_parameter_struct::r_cut, p3m_parameter_struct::r_cut_iL, realloc, p3m_data_struct::recv_grid, p3m_data_struct::rs_mesh, p3m_data_struct::send_grid, p3m_data_struct::sm, and this_node.
Referenced by on_cell_structure_change(), and on_coulomb_change().
| MDINLINE double p3m_pair_energy | ( | double | chgfac, |
| double * | d, | ||
| double | dist2, | ||
| double | dist | ||
| ) |
Calculate real space contribution of coulomb pair energy.
Definition at line 254 of file p3m.h.
References p3m_parameter_struct::alpha, AS_erfc_part(), coulomb, p3m_data_struct::params, Coulomb_parameters::prefactor, and p3m_parameter_struct::r_cut.
Referenced by add_non_bonded_pair_energy(), add_non_bonded_pair_virials(), ELC_P3M_dielectric_layers_energy_contribution(), and ELC_P3M_dielectric_layers_energy_self().
| void p3m_pre_init | ( | void | ) |
Definition at line 228 of file p3m.c.
References p3m_data_struct::ca_fmp, p3m_data_struct::ca_frac, p3m_data_struct::ca_num, p3m_data_struct::d_op, fft_pre_init(), p3m_data_struct::g_energy, p3m_data_struct::g_force, i, p3m_data_struct::int_caf, p3m_data_struct::ks_mesh, p3m_data_struct::ks_pnum, p3m_data_struct::meshift_x, p3m_data_struct::meshift_y, p3m_data_struct::meshift_z, p3m_common_parameter_pre_init(), P3M_STORE_CA_FRAC, p3m_data_struct::params, p3m_data_struct::pos_shift, p3m_data_struct::recv_grid, p3m_data_struct::rs_mesh, p3m_data_struct::send_grid, p3m_data_struct::square_sum_q, p3m_data_struct::sum_q2, and p3m_data_struct::sum_qpart.
Referenced by on_program_start().
| int p3m_sanity_checks | ( | ) |
sanity checks
Definition at line 1844 of file p3m.c.
References p3m_parameter_struct::alpha, p3m_parameter_struct::cao, cell_structure, CELL_STRUCTURE_DOMDEC, p3m_parameter_struct::epsilon, ERROR_SPRINTF, p3m_parameter_struct::mesh, node_grid, P3M_EPSILON_METALLIC, p3m_sanity_checks_boxl(), p3m_data_struct::params, PERIODIC, runtime_error(), skin, and CellStructure::type.
Referenced by check_obs_calc_initialized(), and p3m_init().
| void p3m_scaleby_box_l | ( | ) |
Updates p3m_parameter_struct::alpha and p3m_parameter_struct::r_cut if box_l changed.
Definition at line 1984 of file p3m.c.
References p3m_parameter_struct::alpha, p3m_parameter_struct::alpha_L, Coulomb_parameters::bjerrum, box_l, box_l_i, coulomb, p3m_calc_influence_function_energy(), p3m_calc_influence_function_force(), p3m_calc_lm_ld_pos(), p3m_init_a_ai_cao_cut(), p3m_sanity_checks_boxl(), p3m_data_struct::params, p3m_parameter_struct::r_cut, and p3m_parameter_struct::r_cut_iL.
Referenced by on_boxl_change(), p3m_adaptive_tune(), p3m_init(), and p3m_mcr_time().
| void p3m_set_bjerrum | ( | void | ) |
Definition at line 280 of file p3m.c.
References p3m_parameter_struct::alpha, p3m_parameter_struct::alpha_L, p3m_parameter_struct::cao, p3m_parameter_struct::mesh, p3m_data_struct::params, p3m_parameter_struct::r_cut, and p3m_parameter_struct::r_cut_iL.
Referenced by coulomb_set_bjerrum().
| int p3m_set_eps | ( | double | eps | ) |
Definition at line 457 of file p3m.c.
References p3m_parameter_struct::epsilon, ES_OK, mpi_bcast_coulomb_params(), and p3m_data_struct::params.
Referenced by tclcommand_inter_coulomb_parse_p3m_opt_params().
| int p3m_set_mesh_offset | ( | double | x, |
| double | y, | ||
| double | z | ||
| ) |
Definition at line 439 of file p3m.c.
References ES_ERROR, ES_OK, p3m_parameter_struct::mesh_off, mpi_bcast_coulomb_params(), and p3m_data_struct::params.
Referenced by tclcommand_inter_coulomb_parse_p3m_opt_params().
| int p3m_set_ninterpol | ( | int | n | ) |
Definition at line 468 of file p3m.c.
References ES_ERROR, ES_OK, p3m_parameter_struct::inter, mpi_bcast_coulomb_params(), and p3m_data_struct::params.
Referenced by tclcommand_inter_coulomb_parse_p3m_opt_params().
| int p3m_set_params | ( | double | r_cut, |
| int * | mesh, | ||
| int | cao, | ||
| double | alpha, | ||
| double | accuracy | ||
| ) |
Definition at line 397 of file p3m.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_ELC_P3M, COULOMB_P3M, COULOMB_P3M_GPU, p3m_parameter_struct::mesh, Coulomb_parameters::method, mpi_bcast_coulomb_params(), p3m_data_struct::params, p3m_parameter_struct::r_cut, and p3m_parameter_struct::r_cut_iL.
Referenced by tclcommand_inter_coulomb_parse_p3m().
| void p3m_set_tune_params | ( | double | r_cut, |
| int | mesh[3], | ||
| int | cao, | ||
| double | alpha, | ||
| double | accuracy, | ||
| int | n_interpol | ||
| ) |
Definition at line 362 of file p3m.c.
References p3m_parameter_struct::accuracy, p3m_parameter_struct::alpha, p3m_parameter_struct::alpha_L, Coulomb_parameters::bjerrum, box_l, box_l_i, p3m_parameter_struct::cao, coulomb, p3m_parameter_struct::inter, p3m_parameter_struct::mesh, p3m_data_struct::params, Coulomb_parameters::prefactor, p3m_parameter_struct::r_cut, p3m_parameter_struct::r_cut_iL, and temperature.
Referenced by tclcommand_inter_coulomb_parse_p3m_tune().
| void p3m_shrink_wrap_charge_grid | ( | int | n_charges | ) |
shrink wrap the charge grid
Definition at line 636 of file p3m.c.
References p3m_data_struct::ca_num, and p3m_realloc_ca_fields().
Referenced by ELC_p3m_charge_assign_both(), and p3m_charge_assign().
P3M parameters.
Definition at line 46 of file p3m.c.
Referenced by ELC_init(), ELC_p3m_charge_assign_both(), ELC_p3m_charge_assign_image(), ELC_P3M_modify_p3m_sums_both(), ELC_P3M_modify_p3m_sums_image(), ELC_P3M_restore_p3m_sums(), ELC_set_params(), mpi_bcast_coulomb_params_slave(), on_coulomb_change(), recalc_global_maximal_nonbonded_cutoff(), and tclprint_to_result_p3m().
1.7.5.1