ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
CoulombP3M Struct Referenceabstract

P3M solver. More...

#include <p3m.hpp>

+ Inheritance diagram for CoulombP3M:
+ Collaboration diagram for CoulombP3M:

Public Member Functions

 CoulombP3M (P3MParameters const &p3m_params)
 
virtual ~CoulombP3M ()=default
 
virtual bool is_tuned () const noexcept=0
 
virtual bool is_gpu () const noexcept=0
 
virtual bool is_double_precision () const noexcept=0
 
virtual void init ()=0
 Recalculate all derived parameters.
 
virtual void on_activation ()=0
 
void on_boxl_change ()
 Recalculate all box-length-dependent parameters.
 
void on_node_grid_change () const
 
void on_periodicity_change () const
 
void on_cell_structure_change ()
 
void sanity_checks () const
 
virtual void count_charged_particles ()=0
 Count the number of charged particles and calculate the sum of the squared charges.
 
virtual void count_charged_particles_elc (int, double, double)=0
 
virtual void adapt_epsilon_elc ()=0
 
virtual void tune ()=0
 Tune P3M parameters to desired accuracy.
 
virtual void charge_assign (ParticleRange const &particles)=0
 Assign the physical charges using the tabulated charge assignment function.
 
virtual void assign_charge (double q, Utils::Vector3d const &real_pos, bool skip_cache)=0
 Assign a single charge into the current charge grid.
 
virtual void prepare_fft_mesh (bool reset_weights)=0
 
Utils::Vector3d pair_force (double q1q2, Utils::Vector3d const &d, double dist) const
 Calculate real-space contribution of p3m Coulomb pair forces.
 
double pair_energy (double q1q2, double dist) const
 Calculate real-space contribution of Coulomb pair energy.
 
virtual Utils::Vector9d long_range_pressure (ParticleRange const &)=0
 Compute the k-space part of the pressure tensor.
 
virtual double long_range_energy (ParticleRange const &)=0
 Compute the k-space part of energies.
 
virtual void add_long_range_forces (ParticleRange const &)=0
 Compute the k-space part of forces.
 
- Public Member Functions inherited from Coulomb::Actor< CoulombP3M >
void set_prefactor (double new_prefactor)
 
void sanity_checks_charge_neutrality () const
 
- Public Member Functions inherited from System::Leaf< Class >
void bind_system (std::shared_ptr< System > const &system)
 
void detach_system (std::shared_ptr< System > const &system)
 

Public Attributes

P3MParameters const & p3m_params
 
- Public Attributes inherited from Coulomb::Actor< CoulombP3M >
double prefactor
 Electrostatics prefactor.
 
double charge_neutrality_tolerance
 Relative tolerance for the charge excess during neutrality checks.
 

Protected Member Functions

virtual void calc_influence_function_force ()=0
 
virtual void calc_influence_function_energy ()=0
 
void sanity_checks_boxl () const
 Checks for correctness of the k-space cutoff.
 
void sanity_checks_node_grid () const
 
void sanity_checks_periodicity () const
 
void sanity_checks_cell_structure () const
 
virtual void scaleby_box_l ()=0
 
- Protected Member Functions inherited from System::Leaf< Class >
auto & get_system ()
 
auto & get_system () const
 

Additional Inherited Members

- Static Public Attributes inherited from Coulomb::Actor< CoulombP3M >
static auto constexpr charge_neutrality_tolerance_default
 
- Protected Attributes inherited from System::Leaf< Class >
std::weak_ptr< Systemm_system
 

Detailed Description

P3M solver.

Definition at line 55 of file p3m.hpp.

Constructor & Destructor Documentation

◆ CoulombP3M()

CoulombP3M::CoulombP3M ( P3MParameters const &  p3m_params)
inline

Definition at line 59 of file p3m.hpp.

◆ ~CoulombP3M()

virtual CoulombP3M::~CoulombP3M ( )
virtualdefault

Member Function Documentation

◆ adapt_epsilon_elc()

virtual void CoulombP3M::adapt_epsilon_elc ( )
pure virtual

◆ add_long_range_forces()

virtual void CoulombP3M::add_long_range_forces ( ParticleRange const &  )
pure virtual

Compute the k-space part of forces.

Implemented in CoulombP3MImpl< FloatType, Architecture >.

◆ assign_charge()

virtual void CoulombP3M::assign_charge ( double  q,
Utils::Vector3d const &  real_pos,
bool  skip_cache 
)
pure virtual

Assign a single charge into the current charge grid.

Parameters
[in]qParticle charge
[in]real_posParticle position in real space
[in]skip_cacheSkip interpolation weights caching.

Implemented in CoulombP3MImpl< FloatType, Architecture >.

Referenced by charge_assign().

◆ calc_influence_function_energy()

virtual void CoulombP3M::calc_influence_function_energy ( )
protectedpure virtual

◆ calc_influence_function_force()

virtual void CoulombP3M::calc_influence_function_force ( )
protectedpure virtual

◆ charge_assign()

virtual void CoulombP3M::charge_assign ( ParticleRange const &  particles)
pure virtual

Assign the physical charges using the tabulated charge assignment function.

Implemented in CoulombP3MImpl< FloatType, Architecture >.

◆ count_charged_particles()

virtual void CoulombP3M::count_charged_particles ( )
pure virtual

Count the number of charged particles and calculate the sum of the squared charges.

Implemented in CoulombP3MImpl< FloatType, Architecture >.

◆ count_charged_particles_elc()

virtual void CoulombP3M::count_charged_particles_elc ( int  ,
double  ,
double   
)
pure virtual

◆ init()

virtual void CoulombP3M::init ( )
pure virtual

Recalculate all derived parameters.

Implemented in CoulombP3MImpl< FloatType, Architecture >.

Referenced by on_cell_structure_change().

◆ is_double_precision()

virtual bool CoulombP3M::is_double_precision ( ) const
pure virtualnoexcept

◆ is_gpu()

virtual bool CoulombP3M::is_gpu ( ) const
pure virtualnoexcept

◆ is_tuned()

virtual bool CoulombP3M::is_tuned ( ) const
pure virtualnoexcept

◆ long_range_energy()

virtual double CoulombP3M::long_range_energy ( ParticleRange const &  )
pure virtual

Compute the k-space part of energies.

Implemented in CoulombP3MImpl< FloatType, Architecture >.

◆ long_range_pressure()

virtual Utils::Vector9d CoulombP3M::long_range_pressure ( ParticleRange const &  )
pure virtual

Compute the k-space part of the pressure tensor.

Implemented in CoulombP3MImpl< FloatType, Architecture >.

◆ on_activation()

virtual void CoulombP3M::on_activation ( )
pure virtual

◆ on_boxl_change()

void CoulombP3M::on_boxl_change ( )
inline

Recalculate all box-length-dependent parameters.

Definition at line 72 of file p3m.hpp.

References scaleby_box_l().

◆ on_cell_structure_change()

void CoulombP3M::on_cell_structure_change ( )
inline

Definition at line 75 of file p3m.hpp.

References init(), and sanity_checks_cell_structure().

◆ on_node_grid_change()

void CoulombP3M::on_node_grid_change ( ) const
inline

Definition at line 73 of file p3m.hpp.

References sanity_checks_node_grid().

◆ on_periodicity_change()

void CoulombP3M::on_periodicity_change ( ) const
inline

Definition at line 74 of file p3m.hpp.

References sanity_checks_periodicity().

◆ pair_energy()

double CoulombP3M::pair_energy ( double  q1q2,
double  dist 
) const
inline

Calculate real-space contribution of Coulomb pair energy.

Definition at line 168 of file p3m.hpp.

References P3MParameters::alpha, Utils::AS_erfc_part(), p3m_params, Coulomb::Actor< CoulombP3M >::prefactor, and P3MParameters::r_cut.

◆ pair_force()

Utils::Vector3d CoulombP3M::pair_force ( double  q1q2,
Utils::Vector3d const &  d,
double  dist 
) const
inline

Calculate real-space contribution of p3m Coulomb pair forces.

Definition at line 146 of file p3m.hpp.

References P3MParameters::alpha, Utils::AS_erfc_part(), p3m_params, Coulomb::Actor< CoulombP3M >::prefactor, and P3MParameters::r_cut.

◆ prepare_fft_mesh()

virtual void CoulombP3M::prepare_fft_mesh ( bool  reset_weights)
pure virtual

◆ sanity_checks()

◆ sanity_checks_boxl()

void CoulombP3M::sanity_checks_boxl ( ) const
protected

◆ sanity_checks_cell_structure()

void CoulombP3M::sanity_checks_cell_structure ( ) const
protected

Definition at line 878 of file p3m.cpp.

References communicator, System::Leaf< Class >::get_system(), HYBRID, and REGULAR.

Referenced by on_cell_structure_change(), and sanity_checks().

◆ sanity_checks_node_grid()

void CoulombP3M::sanity_checks_node_grid ( ) const
protected

Definition at line 893 of file p3m.cpp.

References communicator, and Communicator::node_grid.

Referenced by on_node_grid_change(), and sanity_checks().

◆ sanity_checks_periodicity()

void CoulombP3M::sanity_checks_periodicity ( ) const
protected

Definition at line 870 of file p3m.cpp.

References System::Leaf< Class >::get_system().

Referenced by on_periodicity_change(), and sanity_checks().

◆ scaleby_box_l()

virtual void CoulombP3M::scaleby_box_l ( )
protectedpure virtual

◆ tune()

virtual void CoulombP3M::tune ( )
pure virtual

Tune P3M parameters to desired accuracy.

The parameters mesh, cao, r_cut_iL and alpha_L are tuned to obtain the target accuracy in optimal time. These parameters are stored in the p3m_params object.

The function utilizes the analytic expression of the error estimate for the P3M method in [22] (eq. (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 ranges if not given explicitly in the constructor:

  • mesh explores the range 0-512 (biased toward values less than 128)
  • cao explores all possible values
  • alpha_L is tuned for each tuple (r_cut_iL, mesh, cao) and calculated assuming that the error contributions of real and reciprocal space should be equal

After checking if the total error lies below the target accuracy, the time needed for one force calculation is measured. Parameters that minimize the runtime are kept.

The function is based on routines of the program HE_Q.cpp written by M. Deserno.

Implemented in CoulombP3MImpl< FloatType, Architecture >.

Member Data Documentation

◆ p3m_params

P3MParameters const& CoulombP3M::p3m_params

Definition at line 56 of file p3m.hpp.

Referenced by pair_energy(), pair_force(), and sanity_checks_boxl().


The documentation for this struct was generated from the following files: