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

Dipolar all with all and no replica. More...

#include <dipolar_direct_sum.hpp>

+ Inheritance diagram for DipolarDirectSum:
+ Collaboration diagram for DipolarDirectSum:

Public Member Functions

 DipolarDirectSum (double prefactor, int n_replicas, bool gpu)
 
bool is_gpu () const
 
void on_activation () const
 
void on_activation_gpu () const
 
void on_boxl_change () const
 
void on_node_grid_change () const
 
void on_periodicity_change () const
 
void on_cell_structure_change () const
 
void init () const
 
void sanity_checks () const
 
double long_range_energy () const
 Calculate long-range dipolar energy.
 
void add_long_range_forces () const
 
double long_range_energy_cpu () const
 Calculate the interaction potential.
 
void add_long_range_forces_cpu () const
 Calculate and add the interaction forces/torques to the particles.
 
void long_range_energy_gpu () const
 
void add_long_range_forces_gpu () const
 
Utils::Vector9d long_range_pressure () const
 Calculate the dipolar pressure tensor.
 
void dipole_field_at_part_cpu () const
 Calculate total dipole field of each particle.
 
- Public Member Functions inherited from Dipoles::Actor< DipolarDirectSum >
void set_prefactor (double new_prefactor)
 
- 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

int n_replicas
 
bool m_is_gpu
 
- Public Attributes inherited from Dipoles::Actor< DipolarDirectSum >
double prefactor
 Magnetostatics prefactor.
 

Additional Inherited Members

- Protected Member Functions inherited from System::Leaf< Class >
autoget_system ()
 
autoget_system () const
 
- Protected Attributes inherited from System::Leaf< Class >
std::weak_ptr< Systemm_system
 

Detailed Description

Dipolar all with all and no replica.

Handling of a system of dipoles where no replicas exist. Assumes minimum image convention for those axis in which the system is periodic.

Definition at line 38 of file dipolar_direct_sum.hpp.

Constructor & Destructor Documentation

◆ DipolarDirectSum()

DipolarDirectSum::DipolarDirectSum ( double  prefactor,
int  n_replicas,
bool  gpu 
)

Member Function Documentation

◆ add_long_range_forces()

void DipolarDirectSum::add_long_range_forces ( ) const
inline

◆ add_long_range_forces_cpu()

void DipolarDirectSum::add_long_range_forces_cpu ( ) const

Calculate and add the interaction forces/torques to the particles.

This employs a parallel N-square loop over all particle pairs. The computation the partitioned into several steps so that the communication latency can be hidden behind some local computation:

  1. The local particle positions and momenta are packed into one array.
  2. The asynchronous distribution of the local arrays to all ranks is started.
  3. The interaction for the local pairs is started, here every pair is visited only once, and the force is added to both particles.
  4. Wait for the data from the other nodes.
  5. Calculate the interaction with the rest of the particles. Here every pair is visited twice (not necessarily on the same rank) so that no reduction of the forces is needed.

Logically this is equivalent to the potential calculation in DipolarDirectSum::long_range_energy, which calculates a naive N-square sum, but has better performance and scaling.

Definition at line 156 of file dipolar_direct_sum.cpp.

References dipole_field_at_part_cpu(), gather_particle_data(), get_n_cut(), System::Leaf< Class >::get_system(), long_range_pressure(), m_is_gpu, make_image_shifts(), n_replicas, pair_force(), Dipoles::Actor< DipolarDirectSum >::prefactor, pressure_tensor, stream, and vector_product().

Referenced by add_long_range_forces().

◆ add_long_range_forces_gpu()

◆ dipole_field_at_part_cpu()

void DipolarDirectSum::dipole_field_at_part_cpu ( ) const

Calculate total dipole field of each particle.

This employs a parallel N-square loop over all particles. Logically this is equivalent to the potential calculation in DipolarDirectSum::long_range_energy, which calculates a naive N-square sum. The difference is summation range, and the kernel calculates the dipole field rather than the energy.

Definition at line 541 of file dipolar_direct_sum.cpp.

References dipole_field(), gather_particle_data(), get_n_cut(), System::Leaf< Class >::get_system(), m_is_gpu, make_image_shifts(), n_replicas, Dipoles::Actor< DipolarDirectSum >::prefactor, and stream.

Referenced by add_long_range_forces_cpu().

◆ init()

void DipolarDirectSum::init ( ) const
inline

Definition at line 58 of file dipolar_direct_sum.hpp.

◆ is_gpu()

bool DipolarDirectSum::is_gpu ( ) const
inline

Definition at line 43 of file dipolar_direct_sum.hpp.

References m_is_gpu.

◆ long_range_energy()

double DipolarDirectSum::long_range_energy ( ) const
inline

Calculate long-range dipolar energy.

The GPU implementation stores the energy on a GPU accumulator and zero is returned from this method.

Definition at line 66 of file dipolar_direct_sum.hpp.

References long_range_energy_cpu(), long_range_energy_gpu(), and m_is_gpu.

◆ long_range_energy_cpu()

double DipolarDirectSum::long_range_energy_cpu ( ) const

Calculate the interaction potential.

This employs a parallel N-square loop over all particle pairs.

Definition at line 322 of file dipolar_direct_sum.cpp.

References gather_particle_data(), get_n_cut(), System::Leaf< Class >::get_system(), m_is_gpu, make_image_shifts(), n_replicas, pair_potential(), Dipoles::Actor< DipolarDirectSum >::prefactor, and stream.

Referenced by long_range_energy().

◆ long_range_energy_gpu()

◆ long_range_pressure()

Utils::Vector9d DipolarDirectSum::long_range_pressure ( ) const

Calculate the dipolar pressure tensor.

Not implemented for the GPU variant: emits a runtime warning and returns a zero tensor in that case.

This employs a parallel N-square loop over all particle pairs. The dipole-dipole force is not central (unlike Coulomb), so the pair contribution to the virial only accounts for the force, not the torque, matching the convention used by DipolarP3M.

Definition at line 420 of file dipolar_direct_sum.cpp.

References Utils::flatten(), gather_particle_data(), get_n_cut(), System::Leaf< Class >::get_system(), m_is_gpu, make_image_shifts(), n_replicas, pair_force(), Dipoles::Actor< DipolarDirectSum >::prefactor, runtimeWarningMsg, stream, and Utils::tensor_product().

Referenced by add_long_range_forces_cpu().

◆ on_activation()

void DipolarDirectSum::on_activation ( ) const
inline

Definition at line 44 of file dipolar_direct_sum.hpp.

References m_is_gpu, and on_activation_gpu().

◆ on_activation_gpu()

◆ on_boxl_change()

void DipolarDirectSum::on_boxl_change ( ) const
inline

Definition at line 54 of file dipolar_direct_sum.hpp.

◆ on_cell_structure_change()

void DipolarDirectSum::on_cell_structure_change ( ) const
inline

Definition at line 57 of file dipolar_direct_sum.hpp.

◆ on_node_grid_change()

void DipolarDirectSum::on_node_grid_change ( ) const
inline

Definition at line 55 of file dipolar_direct_sum.hpp.

◆ on_periodicity_change()

void DipolarDirectSum::on_periodicity_change ( ) const
inline

Definition at line 56 of file dipolar_direct_sum.hpp.

◆ sanity_checks()

void DipolarDirectSum::sanity_checks ( ) const
inline

Definition at line 59 of file dipolar_direct_sum.hpp.

Member Data Documentation

◆ m_is_gpu

◆ n_replicas


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