Molecular Dynamics Simulation  1.0
Public Member Functions | Private Attributes | List of all members
SmoothedLennardJonesForce Class Reference

Class to calculate the smoothed Lennard-Jones force between particles. Implements the interface PairwiseForceSource. More...

#include <SmoothedLennardJonesForce.h>

Inheritance diagram for SmoothedLennardJonesForce:
Inheritance graph
Collaboration diagram for SmoothedLennardJonesForce:
Collaboration graph

Public Member Functions

 SmoothedLennardJonesForce (double r_c, double r_l)
 Construct a new SmoothedLennardJonesForce object. More...
 
std::array< double, 3UL > calculateForce (const Particle &p, const Particle &q) const override
 Calculates the smoothed Lennard-Jones forces between two particles. More...
 
 operator std::string () const override
 Returns "SmoothedLennardJones" as the name of the force. More...
 
- Public Member Functions inherited from PairwiseForceSource
virtual ~PairwiseForceSource ()=default
 Virtual destructor for correct cleanup of derived classes. More...
 

Private Attributes

double r_c
 the radius after which the force is 0 More...
 
double r_l
 the radius whithin the normal Lennard-Jones force is applied. Between r_l and r_c the force is smoothed out More...
 

Detailed Description

Class to calculate the smoothed Lennard-Jones force between particles. Implements the interface PairwiseForceSource.

This class behaves similar like the normal Lennard-Jones force, but it is smoothed out between the smoothing radius r_l and the cutoff radius r_c.

Implementation of the force calculation to simulate a smooth Lennard-Jones forces between particles.

Definition at line 13 of file SmoothedLennardJonesForce.h.

Constructor & Destructor Documentation

◆ SmoothedLennardJonesForce()

SmoothedLennardJonesForce::SmoothedLennardJonesForce ( double  r_c,
double  r_l 
)
inline

Construct a new SmoothedLennardJonesForce object.

Parameters
r_ccutoff radius
r_lsmoothing radius

Definition at line 21 of file SmoothedLennardJonesForce.h.

21 : r_c(r_c), r_l(r_l){};
double r_c
the radius after which the force is 0
double r_l
the radius whithin the normal Lennard-Jones force is applied. Between r_l and r_c the force is smooth...

Member Function Documentation

◆ calculateForce()

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

Calculates the smoothed Lennard-Jones forces between two particles.

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

Calculates the Lennard-Jones force which q exerts on p

Implements PairwiseForceSource.

Definition at line 6 of file SmoothedLennardJonesForce.cpp.

6  {
7  const auto displacement = q.getX() - p.getX();
8  const double dist = ArrayUtils::L2Norm(displacement);
9 
10  if (dist <= r_l) {
11  static LennardJonesForce lennard_jones_force;
12  return lennard_jones_force.calculateForce(p, q);
13  } else if (dist <= r_c) {
14  const double sigma = (p.getSigma() + q.getSigma()) / 2;
15  const double epsilon = std::sqrt(p.getEpsilon() * q.getEpsilon());
16 
17  const double sigma_pow_6 = std::pow(sigma, 6);
18  const double dist_pow_6 = std::pow(dist, 6);
19 
20  const auto f_smoothed_lennard_jones =
21  (-24 * sigma_pow_6 * epsilon) / (std::pow(dist, 14) * std::pow(r_c - r_l, 3)) * (r_c - dist) *
22  (r_c * r_c * (2 * sigma_pow_6 - dist_pow_6) + r_c * (3 * r_l - dist) * (dist_pow_6 - 2 * sigma_pow_6) +
23  dist * (5 * r_l * sigma_pow_6 - 2 * r_l * dist_pow_6 - 3 * sigma_pow_6 * dist + std::pow(dist, 7))) *
24  displacement;
25 
26  return f_smoothed_lennard_jones;
27  } else {
28  return {0, 0, 0};
29  }
30 };
Class to calculate the Lennard-Jones force between particles. Implements the interface PairwiseForceS...
std::array< double, 3UL > calculateForce(const Particle &p, const Particle &q) const override
Calculates the Lennard-Jones forces between two particles.
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()

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

Returns "SmoothedLennardJones" as the name of the force.

Implements PairwiseForceSource.

Definition at line 32 of file SmoothedLennardJonesForce.cpp.

32 { return "SmoothedLennardJones"; }

Member Data Documentation

◆ r_c

double SmoothedLennardJonesForce::r_c
private

the radius after which the force is 0

Definition at line 43 of file SmoothedLennardJonesForce.h.

◆ r_l

double SmoothedLennardJonesForce::r_l
private

the radius whithin the normal Lennard-Jones force is applied. Between r_l and r_c the force is smoothed out

Definition at line 48 of file SmoothedLennardJonesForce.h.


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