Molecular Dynamics Simulation  1.0
Public Member Functions | List of all members
LennardJonesRepulsiveForce Class Reference

Class to calculate the only the repulisve part of the Lennard-Jones force between particles. Implements the interface PairwiseForceSource. More...

#include <LennardJonesRepulsiveForce.h>

Inheritance diagram for LennardJonesRepulsiveForce:
Inheritance graph
Collaboration diagram for LennardJonesRepulsiveForce:
Collaboration graph

Public Member Functions

std::array< double, 3UL > calculateForce (const Particle &p, const Particle &q) const override
 Calculates only the repulsive part of the Lennard-Jones forces between two particles. More...
 
 operator std::string () const override
 Returns "Lennard-Jones (Repulsive Only)" as name of the force. More...
 
- Public Member Functions inherited from PairwiseForceSource
virtual ~PairwiseForceSource ()=default
 Virtual destructor for correct cleanup of derived classes. More...
 

Detailed Description

Class to calculate the only the repulisve part of the Lennard-Jones force between particles. Implements the interface PairwiseForceSource.

Implementation of the force calculation to simulate the repulsive part of Lennard-Jones forces between particles.

Definition at line 11 of file LennardJonesRepulsiveForce.h.

Member Function Documentation

◆ calculateForce()

std::array< double, 3UL > LennardJonesRepulsiveForce::calculateForce ( const Particle p,
const Particle q 
) const
overridevirtual

Calculates only the repulsive part of the Lennard-Jones forces between two particles.

Parameters
pParticle
qParticle
Returns
Repulsive Lennard-Jones force exerted by q on p

Calculates the Lennard-Jones force which q exerts on p

Implements PairwiseForceSource.

Definition at line 5 of file LennardJonesRepulsiveForce.cpp.

5  {
6  const auto displacement = q.getX() - p.getX();
7  const double dist = ArrayUtils::L2Norm(displacement);
8  const double sigma = (p.getSigma() + q.getSigma()) / 2;
9 
10  if (dist > std::pow(2, 1.0 / 6.0) * sigma) return std::array<double, 3UL>{0, 0, 0};
11 
12  const double epsilon = std::sqrt(p.getEpsilon() * q.getEpsilon());
13 
14  const auto f_lennard_jones =
15  (24 * epsilon / (std::pow(dist, 2))) * (std::pow(sigma / dist, 6) - 2 * std::pow(sigma / dist, 12)) * displacement;
16 
17  return f_lennard_jones;
18 };
double getSigma() const
Gets the Lennard-Jones potential parameter sigma.
Definition: Particle.h:192
const std::array< double, 3 > & getX() const
Gets the position of the particle.
Definition: Particle.h:157
double getEpsilon() const
Gets the Lennard-Jones potential parameter epsilon.
Definition: Particle.h:187
auto L2Norm(const Container &c)
Definition: ArrayUtils.h:174

◆ operator std::string()

LennardJonesRepulsiveForce::operator std::string ( ) const
explicitoverridevirtual

Returns "Lennard-Jones (Repulsive Only)" as name of the force.

Implements PairwiseForceSource.

Definition at line 20 of file LennardJonesRepulsiveForce.cpp.

20 { return "Lennard-Jones (Repulsive Only)"; }

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