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

Implementation of the Strömer-Verlet integration method. Implements the interface IntegrationFunctor. More...

#include <VerletFunctor.h>

Inheritance diagram for VerletFunctor:
Inheritance graph
Collaboration diagram for VerletFunctor:
Collaboration graph

Public Member Functions

void step (std::unique_ptr< ParticleContainer > &particle_container, const std::vector< std::shared_ptr< SimpleForceSource >> &simple_force_sources, const std::vector< std::shared_ptr< PairwiseForceSource >> &pairwise_force_sources, const std::vector< std::shared_ptr< TargettedForceSource >> &targetted_force_sources, double delta_t, double curr_simulation_time) const override
 Performs one step with the respective integration method. More...
 
- Public Member Functions inherited from IntegrationFunctor
virtual ~IntegrationFunctor ()=default
 Virtual default destructor for the interface. More...
 

Detailed Description

Implementation of the Strömer-Verlet integration method. Implements the interface IntegrationFunctor.

Implements the IntegrationFunctor interface, and therefore updates all particles in the particle_container according to the Verlet integration method.

Definition at line 11 of file VerletFunctor.h.

Member Function Documentation

◆ step()

void VerletFunctor::step ( std::unique_ptr< ParticleContainer > &  particle_container,
const std::vector< std::shared_ptr< SimpleForceSource >> &  simple_force_sources,
const std::vector< std::shared_ptr< PairwiseForceSource >> &  pairwise_force_sources,
const std::vector< std::shared_ptr< TargettedForceSource >> &  targetted_force_sources,
double  delta_t,
double  curr_simulation_time 
) const
overridevirtual

Performs one step with the respective integration method.

Parameters
particle_containerContainer of particles on which the integration step is applied
simple_force_sourcesVector of simple force sources which are used to calculate the new forces
pairwise_force_sourcesVector of pairwise force sources which are used to calculate the new forces
targetted_force_sourcesVector of targetted force sources which are used to calculate the new forces
delta_tTime step
curr_simulation_timeCurrent simulation time

Implements IntegrationFunctor.

Definition at line 5 of file VerletFunctor.cpp.

9  {
10  for (auto& p : *particle_container) {
11  // update position
12  if (!p.isLocked()) {
13  const std::array<double, 3> new_x = p.getX() + delta_t * p.getV() + (delta_t * delta_t / (2 * p.getM())) * p.getF();
14  p.setX(new_x);
15  }
16 
17  // reset forces
18  p.setOldF(p.getF());
19  p.setF({0, 0, 0});
20  }
21 
22  // calculate new forces
23  particle_container->prepareForceCalculation();
24  particle_container->applySimpleForces(simple_force_sources);
25  particle_container->applyPairwiseForces(pairwise_force_sources);
26  particle_container->applyTargettedForces(targetted_force_sources, curr_simulation_time);
27 
28  // update velocity
29  for (auto& p : *particle_container) {
30  if (!p.isLocked()) {
31  const std::array<double, 3> new_v = p.getV() + (delta_t / (2 * p.getM())) * (p.getF() + p.getOldF());
32  p.setV(new_v);
33  } else {
34  p.setV({0, 0, 0});
35  }
36  }
37 }

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