ESPResSo 3.2.0-159-gf5c8922-git
Extensible Simulation Package for Soft Matter Research
Data Structures | Variables
p3m.h File Reference

code for calculating the MDLC (magnetic dipolar layer correction). More...

#include "utils.h"
#include "p3m-common.h"
#include "interaction_data.h"
Include dependency graph for p3m.h:
This graph shows which files directly or indirectly include this file:

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.

Detailed Description

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.


Enumeration Type Documentation

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.

Enumerator:
P3M_TUNE_FAIL 
P3M_TUNE_NOCUTOFF 
P3M_TUNE_CAOTOLARGE 
P3M_TUNE_ELCTEST 
P3M_TUNE_CUTOFF_TOO_LARGE 

Definition at line 159 of file p3m.h.


Function Documentation

int p3m_adaptive_tune ( char **  log)
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 
)
double p3m_calc_kspace_forces ( int  force_flag,
int  energy_flag 
)
void p3m_calc_kspace_stress ( double *  stress)
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 ( )
void p3m_init ( void  )
MDINLINE double p3m_pair_energy ( double  chgfac,
double *  d,
double  dist2,
double  dist 
)
void p3m_pre_init ( void  )
int p3m_sanity_checks ( )
void p3m_scaleby_box_l ( )
void p3m_set_bjerrum ( void  )
int p3m_set_eps ( double  eps)
int p3m_set_mesh_offset ( double  x,
double  y,
double  z 
)
int p3m_set_ninterpol ( int  n)
int p3m_set_params ( double  r_cut,
int *  mesh,
int  cao,
double  alpha,
double  accuracy 
)
void p3m_set_tune_params ( double  r_cut,
int  mesh[3],
int  cao,
double  alpha,
double  accuracy,
int  n_interpol 
)
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().


Variable Documentation