AutoPas  3.0.0
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs > Class Template Reference

A functor to handle Axilrod-Teller(-Muto) interactions between three particles (molecules). More...

#include <AxilrodTellerFunctor.h>

Inheritance diagram for mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >:
Inheritance graph
[legend]
Collaboration diagram for mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >:
Collaboration graph
[legend]

Public Member Functions

 AxilrodTellerFunctor ()=delete
 Deleted default constructor.
 
 AxilrodTellerFunctor (double cutoff)
 Constructor for Functor with mixing disabled.
 
 AxilrodTellerFunctor (double cutoff, ParticlePropertiesLibrary< double, size_t > &particlePropertiesLibrary)
 Constructor for Functor with mixing active.
 
std::string getName () final
 Returns name of functor.
 
bool isRelevantForTuning () final
 Specifies whether the functor should be considered for the auto-tuning process.
 
bool allowsNewton3 () final
 Specifies whether the functor is capable of Newton3-like functors.
 
bool allowsNonNewton3 () final
 Specifies whether the functor is capable of non-Newton3-like functors.
 
void AoSFunctor (Particle_T &i, Particle_T &j, Particle_T &k, bool newton3) final
 TriwiseFunctor for arrays of structures (AoS).
 
void setParticleProperties (SoAFloatPrecision nu)
 Sets the particle properties constants for this functor.
 
void initTraversal () final
 Reset the global values.
 
void endTraversal (bool newton3) final
 Accumulates global values, e.g.
 
double getPotentialEnergy ()
 Get the potential Energy.
 
double getVirial ()
 Get the virial.
 
size_t getNumFLOPs () const override
 Gets the number of useful FLOPs.
 
double getHitRate () const override
 Get the hit rate.
 
- Public Member Functions inherited from autopas::TriwiseFunctor< Particle_T, CRTP_T >
 TriwiseFunctor (double cutoff)
 Constructor.
 
virtual void AoSFunctor (Particle_T &i, Particle_T &j, Particle_T &k, bool newton3)
 TriwiseFunctor for arrays of structures (AoS).
 
virtual void SoAFunctorSingle (SoAView< SoAArraysType > soa, bool newton3)
 TriwiseFunctor for structure of arrays (SoA)
 
virtual void SoAFunctorPair (SoAView< SoAArraysType > soa1, SoAView< SoAArraysType > soa2, bool newton3)
 TriwiseFunctor for structure of arrays (SoA)
 
virtual void SoAFunctorTriple (SoAView< SoAArraysType > soa1, SoAView< SoAArraysType > soa2, SoAView< SoAArraysType > soa3, bool newton3)
 TriwiseFunctor for structure of arrays (SoA)
 
virtual void SoAFunctorVerlet (SoAView< SoAArraysType > soa, const size_t indexFirst, const std::vector< size_t, AlignedAllocator< size_t > > &neighborList, bool newton3)
 TriwiseFunctor for structure of arrays (SoA) for neighbor lists.
 
- Public Member Functions inherited from autopas::Functor< Particle_T, CRTP_T >
 Functor (double cutoff)
 Constructor.
 
virtual void initTraversal ()
 This function is called at the start of each traversal.
 
virtual void endTraversal (bool newton3)
 This function is called at the end of each traversal.
 
template<class ParticleCell >
void SoALoader (ParticleCell &cell, SoA< SoAArraysType > &soa, size_t offset, bool skipSoAResize)
 Copies the AoS data of the given cell in the given soa.
 
template<typename ParticleCell >
void SoAExtractor (ParticleCell &cell, SoA< SoAArraysType > &soa, size_t offset)
 Copies the data stored in the soa back into the cell.
 
virtual bool allowsNewton3 ()=0
 Specifies whether the functor is capable of Newton3-like functors.
 
virtual bool allowsNonNewton3 ()=0
 Specifies whether the functor is capable of non-Newton3-like functors.
 
virtual bool isRelevantForTuning ()=0
 Specifies whether the functor should be considered for the auto-tuning process.
 
virtual std::string getName ()=0
 Returns name of functor.
 
double getCutoff () const
 Getter for the functor's cutoff.
 
virtual size_t getNumFLOPs () const
 Get the number of FLOPs.
 
virtual double getHitRate () const
 Get the hit rate.
 

Static Public Member Functions

static constexpr auto getNeededAttr ()
 Get attributes needed for computation.
 
static constexpr auto getNeededAttr (std::false_type)
 Get attributes needed for computation without N3 optimization.
 
static constexpr auto getComputedAttr ()
 Get attributes computed by this functor.
 
static constexpr bool getMixing ()
 
- Static Public Member Functions inherited from autopas::Functor< Particle_T, CRTP_T >
static constexpr std::array< typename Particle_T::AttributeNames, 0 > getNeededAttr ()
 Get attributes needed for computation.
 
static constexpr std::array< typename Particle_T::AttributeNames, 0 > getNeededAttr (std::false_type)
 Get attributes needed for computation without N3 optimization.
 
static constexpr std::array< typename Particle_T::AttributeNames, 0 > getComputedAttr ()
 Get attributes computed by this functor.
 

Additional Inherited Members

- Public Types inherited from autopas::TriwiseFunctor< Particle_T, CRTP_T >
using SoAArraysType = typename Particle_T::SoAArraysType
 Structure of the SoAs defined by the particle.
 
- Public Types inherited from autopas::Functor< Particle_T, CRTP_T >
using SoAArraysType = typename Particle_T::SoAArraysType
 Structure of the SoAs defined by the particle.
 
using Functor_T = CRTP_T
 Make the Implementation type template publicly available.
 

Detailed Description

template<class Particle_T, bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
class mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >

A functor to handle Axilrod-Teller(-Muto) interactions between three particles (molecules).

The Axilrod-Teller potential

The reference paper of Axilrod and Teller can be found here: https://doi.org/10.1063/1.1723844

Sketch of three particles that are used in the Axilrod-Teller Functor

The Axilrod-Teller potential is a model for the interactions of three molecules which appear when the van der Waals forces are approximated to the third order. It is usually combined with a model for pairwise interaction as e.g. the Lennard-Jones potential.

\[ U_{AT} = \nu \frac{3 \cos\gamma_1 \cos\gamma_2 \cos\gamma_3 + 1}{r_{12}^3 r_{23}^3 r_{31}^3} \]

, where \(r_{ij}\) is the distance between particles \(i\) and \(j\) and \(\gamma_i\) is the angle between the sides \(r_{ij}\) and \(r_{ik}\). \(\nu\) is a material dependent parameter of the order \(V\alpha^3\), where \(V\) is the ionization energy and \(\alpha\) the polarizability.

The cosines can also be expressed as:

\[ \cos\gamma_1 = \frac{ \vec{r}_{12} \cdot \vec{r}_{13}}{|\vec{r}_{12}||\vec{r}_{13}|} \]

, where \(\vec{r}_{ij}\) is the vector from particle \(i\) to particle \(j\) ( \(i \longrightarrow j\) ). It is calculated as \(\vec{x}_j - \vec{x}_i\), where \(\vec{x}_i\) is the position of particle \(i\).

Therefore, the potential can also be expressed as:

\[ U_{AT} = \nu\frac{-3 (\vec{r}_{12} \cdot \vec{r}_{31}) (\vec{r}_{12} \cdot \vec{r}_{23}) (\vec{r}_{31} \cdot \vec{r}_{23}) + r_{12}^2 r_{23}^2 r_{31}^2}{r_{12}^5 r_{23}^5 r_{31}^5} \]

Note that we have \(-3\) because we use the circular vectors \(\vec{r}_ {12}, \vec{r}_ {23}, \vec{r}_ {31}\).

The derivative can be calculated by applying the chain rule and leads to a resulting Force exerted on particle \(1\):

\[ \vec{F}_ {1} = - \frac{\partial U_ {AT}}{\partial \vec{x}_ 1} \]

\[ \vec{F}_ {1} = \frac{3}{r_ {12}^5 r_ {23}^5 r_ {31}^5}\cdot \left[ \left( -5\frac{<>_ 1<>_ 2<>_ 3}{r_ {12}^2} - <>_ 1<>_ 3 + r_ {23}^2r_ {31}^2\right)\cdot \vec{r}_ {12} +\left( 5\frac{<>_ 1<>_ 2<>_ 3}{r_ {23}^2} + <>_ 1<>_ 3 - r_ {12}^2r_ {31}^2\right)\cdot\vec{r}_ {23} +\left( <>_ 2<>_ 3 - <>_ 2<>_ 1 \right)\cdot \vec{r}_ {31} \right] \]

, where \(<>_ 1=\vec{r}_ {12}\cdot\vec{r}_ {31}\) and so on. The terms are already ordered to show the contribution from all three distance vectors.

Newton's third law

To apply Newton's third law, the force on particle \(2\) needs to be calculated in a similar fashion as for particle \(1\). The force on particle \(3\) can then be written as the negative sum of the other two forces:

\[ \vec{F}_3 = -(\vec{F}_1 + \vec{F}_2) \]

This functor assumes that duplicated calculations are always happening, which is characteristic for a Full-Shell scheme.

Template Parameters
Particle_TThe type of particle.
useMixingSwitch for the functor to be used with multiple particle types. If set to false, _epsilon and _sigma need to be set and the constructor with PPL can be omitted.
useNewton3Switch for the functor to support newton3 on, off or both. See FunctorN3Modes for possible values.
calculateGlobalsDefines whether the global values are to be calculated (energy, virial).
countFLOPscounts FLOPs and hitrate

Constructor & Destructor Documentation

◆ AxilrodTellerFunctor() [1/2]

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::AxilrodTellerFunctor ( double  cutoff)
inlineexplicit

Constructor for Functor with mixing disabled.

When using this functor it is necessary to call setParticleProperties() to set internal constants because it does not use a particle properties library.

Note
Only to be used with mixing == false.
Parameters
cutoff

◆ AxilrodTellerFunctor() [2/2]

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::AxilrodTellerFunctor ( double  cutoff,
ParticlePropertiesLibrary< double, size_t > &  particlePropertiesLibrary 
)
inlineexplicit

Constructor for Functor with mixing active.

This functor takes a ParticlePropertiesLibrary to look up (mixed) properties like nu.

Parameters
cutoff
particlePropertiesLibrary

Member Function Documentation

◆ allowsNewton3()

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
bool mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::allowsNewton3 ( )
inlinefinalvirtual

Specifies whether the functor is capable of Newton3-like functors.

If the functor provides an interface to soa or aos functions that utilize Newton's third law of motion (actio = reactio) to reduce the computational complexity this function should return true. If this is not the case this function should return false.

Returns
true if and only if this functor provides an interface to Newton3-like functions.

Implements autopas::Functor< Particle_T, CRTP_T >.

◆ allowsNonNewton3()

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
bool mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::allowsNonNewton3 ( )
inlinefinalvirtual

Specifies whether the functor is capable of non-Newton3-like functors.

If the functor provides an interface to soa or aos functions that do not utilize Newton's third law of motion (actio = reactio) this function should return true. If this is not the case this function should return false.

Returns
true if and only if this functor provides an interface to functions that do not utilize Newton3.

Implements autopas::Functor< Particle_T, CRTP_T >.

◆ AoSFunctor()

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
void mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::AoSFunctor ( Particle_T &  i,
Particle_T &  j,
Particle_T &  k,
bool  newton3 
)
inlinefinalvirtual

TriwiseFunctor for arrays of structures (AoS).

This functor should calculate the forces or any triwise interaction between three particles. This should include a cutoff check if needed!

Parameters
iParticle i
jParticle j
kParticle k
newton3defines whether or whether not to use newton 3

Reimplemented from autopas::TriwiseFunctor< Particle_T, CRTP_T >.

◆ endTraversal()

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
void mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::endTraversal ( bool  newton3)
inlinefinalvirtual

Accumulates global values, e.g.

potential energy and virial.

Parameters
newton3

Reimplemented from autopas::Functor< Particle_T, CRTP_T >.

◆ getComputedAttr()

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
static constexpr auto mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::getComputedAttr ( )
inlinestaticconstexpr

Get attributes computed by this functor.

Returns
Attributes computed by this functor.
Todo:
C++20: make this function virtual

◆ getHitRate()

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
double mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::getHitRate ( ) const
inlineoverridevirtual

Get the hit rate.

Implementation required if FLOPLogger used.

If derived class provides no implementation, the FLOPLogger interprets the default NaN output as invalid and leaves "Not Implemented" in the log.

Returns
(number of kernel calls) / (number of distance calculations)

Reimplemented from autopas::Functor< Particle_T, CRTP_T >.

◆ getMixing()

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
static constexpr bool mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::getMixing ( )
inlinestaticconstexpr
Returns
useMixing

◆ getName()

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
std::string mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::getName ( )
inlinefinalvirtual

Returns name of functor.

Intended for use with the iteration logger, to differentiate between calls to computeInteractions using different functors in the logs.

Returns
name of functor.

Implements autopas::Functor< Particle_T, CRTP_T >.

◆ getNeededAttr() [1/2]

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
static constexpr auto mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::getNeededAttr ( )
inlinestaticconstexpr

Get attributes needed for computation.

Returns
Attributes needed for computation.
Todo:
C++20: make this function virtual

◆ getNeededAttr() [2/2]

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
static constexpr auto mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::getNeededAttr ( std::false_type  )
inlinestaticconstexpr

Get attributes needed for computation without N3 optimization.

Returns
Attributes needed for computation.
Todo:
C++20: make this function virtual

◆ getNumFLOPs()

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
size_t mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::getNumFLOPs ( ) const
inlineoverridevirtual

Gets the number of useful FLOPs.

For the three distance squared calculations, this is:

  • Displacement: 3
  • DistanceSquared: 5
  • Total: 8 * 3 = 24

For the force kernel, this is:

  • calculation of prefactor: 7
  • dot products: 3 * 5 = 15
  • all dot products: 2
  • forceIDirectionJK: 5
  • forceIDirectionIJ: 9
  • forceIDirectionKI: 9
  • add force vectors and multiply: 9
  • add force to mol i: 3
  • If N3:
  • forceJDirectionKI: 5
  • forceJDirectionIJ: 9
  • forceJDirectionJK: 9
  • add force vectors and multiply: 9
  • add force to mol j: 3
  • sum forceK: 3 (don't count multiplication with -1.0)
  • add force to mol k: 3
  • Total: 59 without n3, 100 with n3

For the globals calculation, this is:

  • potential: 3
  • virial: 3 without n3, 9 with n3
  • accumulation: 4 without n3, 12 with n3
  • Total: 10 without n3, 24 with n3
Returns
number of FLOPs since initTraversal() is called.

Reimplemented from autopas::Functor< Particle_T, CRTP_T >.

◆ getPotentialEnergy()

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
double mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::getPotentialEnergy ( )
inline

Get the potential Energy.

Returns
the potential Energy

◆ getVirial()

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
double mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::getVirial ( )
inline

Get the virial.

Returns

◆ initTraversal()

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
void mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::initTraversal ( )
inlinefinalvirtual

Reset the global values.

Will set the global values to zero to prepare for the next iteration.

Reimplemented from autopas::Functor< Particle_T, CRTP_T >.

◆ isRelevantForTuning()

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
bool mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::isRelevantForTuning ( )
inlinefinalvirtual

Specifies whether the functor should be considered for the auto-tuning process.

Returns
true if and only if this functor is relevant for auto-tuning.

Implements autopas::Functor< Particle_T, CRTP_T >.

◆ setParticleProperties()

template<class Particle_T , bool useMixing = false, autopas::FunctorN3Modes useNewton3 = autopas::FunctorN3Modes::Both, bool calculateGlobals = false, bool countFLOPs = false>
void mdLib::AxilrodTellerFunctor< Particle_T, useMixing, useNewton3, calculateGlobals, countFLOPs >::setParticleProperties ( SoAFloatPrecision  nu)
inline

Sets the particle properties constants for this functor.

This is only necessary if no particlePropertiesLibrary is used.

Parameters
nuThe Axilrod-Teller potential parameter

The documentation for this class was generated from the following file: