ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
dipolar_direct_sum.cpp File Reference
#include "config/config.hpp"
#include "magnetostatics/dipolar_direct_sum.hpp"
#include "BoxGeometry.hpp"
#include "cells.hpp"
#include "communication.hpp"
#include "errorhandling.hpp"
#include "system/System.hpp"
#include <utils/cartesian_product.hpp>
#include <utils/math/sqr.hpp>
#include <utils/mpi/iall_gatherv.hpp>
#include <boost/mpi/collectives.hpp>
#include <boost/mpi/communicator.hpp>
#include <mpi.h>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iterator>
#include <ranges>
#include <stdexcept>
#include <tuple>
#include <utility>
#include <vector>
+ Include dependency graph for dipolar_direct_sum.cpp:

Go to the source code of this file.

Classes

struct  PosMom
 Position and dipole moment of one particle. More...
 

Functions

static auto pair_force (Utils::Vector3d const &d, Utils::Vector3d const &m1, Utils::Vector3d const &m2)
 Pair force of two interacting dipoles.
 
static auto pair_potential (Utils::Vector3d const &d, Utils::Vector3d const &m1, Utils::Vector3d const &m2)
 Pair potential for two interacting dipoles.
 
static auto dipole_field (Utils::Vector3d const &d, Utils::Vector3d const &m1)
 Dipole field contribution from a particle with dipole moment m1 at a distance d.
 
template<typename F >
void for_each_image (Utils::Vector3i const &ncut, F f)
 Call kernel for every 3d index in a sphere around the origin.
 
template<class InputIterator , class T , class F >
image_sum (InputIterator begin, InputIterator end, InputIterator it, bool with_replicas, Utils::Vector3i const &ncut, BoxGeometry const &box_geo, T init, F f)
 Sum over all pairs with periodic images.
 
static auto gather_particle_data (BoxGeometry const &box_geo, ParticleRange const &particles)
 
static auto get_n_cut (BoxGeometry const &box_geo, int n_replicas)
 

Function Documentation

◆ dipole_field()

static auto dipole_field ( Utils::Vector3d const &  d,
Utils::Vector3d const &  m1 
)
static

Dipole field contribution from a particle with dipole moment m1 at a distance d.

Parameters
dDistance vector.
m1Dipole moment of one particle.
Returns
Utils::Vector3d containing dipole field components.

Definition at line 115 of file dipolar_direct_sum.cpp.

◆ for_each_image()

template<typename F >
void for_each_image ( Utils::Vector3i const &  ncut,
f 
)

Call kernel for every 3d index in a sphere around the origin.

This calls a callable for all index-triples that are within ball around the origin with radius |ncut|.

Template Parameters
FCallable
Parameters
ncutLimits in the three directions, all non-zero elements have to be the same number.
fwill be called for each index triple within the limits of ncut.

Definition at line 139 of file dipolar_direct_sum.cpp.

References Utils::cartesian_product(), and Utils::Vector< T, N >::norm2().

Referenced by DipolarDirectSum::add_long_range_forces(), and image_sum().

◆ gather_particle_data()

◆ get_n_cut()

static auto get_n_cut ( BoxGeometry const &  box_geo,
int  n_replicas 
)
static

◆ image_sum()

template<class InputIterator , class T , class F >
T image_sum ( InputIterator  begin,
InputIterator  end,
InputIterator  it,
bool  with_replicas,
Utils::Vector3i const &  ncut,
BoxGeometry const &  box_geo,
init,
f 
)

Sum over all pairs with periodic images.

This implements the "primed" pair sum, the sum over all pairs between one particles and all other particles, including ncut periodic replicas in each direction. Primed means that in the primary replica the self-interaction is excluded, but not with the other periodic replicas. E.g. a particle does not interact with its self, but does with its periodically shifted versions.

Parameters
beginIterator pointing to begin of particle range
endIterator pointing past the end of particle range
itPointer to particle that is considered
with_replicasIf periodic replicas are to be considered at all. If false, distances are calculated as Euclidean distances, and not using minimum image convention.
ncutNumber of replicas in each direction.
box_geoBox geometry.
initInitial value of the sum.
fBinary operation mapping distance and moment of the interaction partner to the value to be summed up for this pair.
Returns
The total sum.

Definition at line 197 of file dipolar_direct_sum.cpp.

References for_each_image(), BoxGeometry::get_mi_vector(), and BoxGeometry::length().

Referenced by DipolarDirectSum::add_long_range_forces(), DipolarDirectSum::dipole_field_at_part(), and DipolarDirectSum::long_range_energy().

◆ pair_force()

static auto pair_force ( Utils::Vector3d const &  d,
Utils::Vector3d const &  m1,
Utils::Vector3d const &  m2 
)
static

Pair force of two interacting dipoles.

Parameters
dDistance vector.
m1Dipole moment of one particle.
m2Dipole moment of the other particle.
Returns
Resulting force.

Definition at line 62 of file dipolar_direct_sum.cpp.

References Utils::Vector< T, N >::norm2(), and vector_product().

Referenced by DipolarDirectSum::add_long_range_forces().

◆ pair_potential()

static auto pair_potential ( Utils::Vector3d const &  d,
Utils::Vector3d const &  m1,
Utils::Vector3d const &  m2 
)
static

Pair potential for two interacting dipoles.

Parameters
dDistance vector.
m1Dipole moment of one particle.
m2Dipole moment of the other particle.
Returns
Interaction energy.

Definition at line 92 of file dipolar_direct_sum.cpp.