Molecular Dynamics  v0.4
Project for the Practical hosted by the Scientific Computing Chair
Public Member Functions | Private Attributes | List of all members
DirectSum Class Referencefinal

Model that implements the direct sum algorithm. More...

#include <DirectSum.h>

Inheritance diagram for DirectSum:
Inheritance graph
Collaboration diagram for DirectSum:
Collaboration graph

Public Member Functions

 DirectSum (Force &force, double deltaT, FileHandler::outputFormat outputFormat, bool gravityOn, std::array< double, 3 > g={})
 Construct a new Direct Sum model. More...
 
void step (int iteration) override
 Perform one time step in the direct sum model. More...
 
void initializeForces () override
 Calculate forces at the beginning of the simulation that the old force is not 0. More...
 
- Public Member Functions inherited from Model
virtual ~Model ()=default
 Virtual default constructor to guarantee appropriate memory clean up. More...
 
void plot (int iteration, std::string &baseName)
 Write current state of the model to a file. More...
 
void addCuboid (const std::array< double, 3 > &position, unsigned N1, unsigned N2, unsigned N3, double h, double mass, const std::array< double, 3 > &initVelocity, int dimensions, double brownianMotionAverageVelocity, double epsilon=5, double sigma=1, bool fixed=false)
 Add a cuboid structure to this model. More...
 
void addDisc (const std::array< double, 3 > &center, const std::array< double, 3 > &initVelocity, int N, double h, double mass, int dimensions, double brownianMotionAverageVelocity, double epsilon=5, double sigma=1, bool fixed=false)
 Add a 2D disc structure to this model. More...
 
void addSphere (const std::array< double, 3 > &center, const std::array< double, 3 > &initVelocity, int N, double h, double mass, int dimensions, double brownianMotionAverageVelocity, double epsilon=5, double sigma=1, bool fixed=false)
 Add a 3D sphere structure to this model. More...
 
void addParticle (Particle &p)
 Add a single particle to this model. More...
 
void addViaFile (std::string &filepath, FileHandler::inputFormat inputFormat)
 Add new particles / particle structures to the model via a file. More...
 
void saveState ()
 Export the current state of all molecules to a txt file for using them in a new simulation. More...
 
void updateForces () const
 Helper method to calculate the force between all particles. More...
 
ParticleContainergetParticles () const
 Get the Particles of this model. More...
 

Private Attributes

DefaultParticleContainer particles
 

Additional Inherited Members

- Protected Member Functions inherited from Model
 Model (ParticleContainer &particles, Force &force, double deltaT, FileHandler::outputFormat outputFormat, bool gravityOn, std::array< double, 3 > g={})
 Constructor for this model. Cannot be called from any other class but classes that extend this class, because this class is a base class and should not be instantiated. More...
 
void updatePositions () const
 Helper method to calculate the position of all particles. More...
 
void updateVelocities () const
 Helper method to calculate the velocity of all particles. More...
 
void applyGravity ()
 Add a gravitational force of g * m along the y-axis to each particle inside the simulation domain. More...
 
- Protected Attributes inherited from Model
ParticleContainerparticles
 
Forceforce
 
double deltaT
 
bool gravityOn
 
std::array< double, 3 > g
 

Detailed Description

Model that implements the direct sum algorithm.

Constructor & Destructor Documentation

◆ DirectSum()

DirectSum::DirectSum ( Force force,
double  deltaT,
FileHandler::outputFormat  outputFormat,
bool  gravityOn,
std::array< double, 3 >  g = {} 
)

Construct a new Direct Sum model.

Parameters
forceForce to use.
deltaTDiscretisation step.
outputFormatOutput format.
gravityOnToggle gravity on or off.
gGravitational factor g.

Member Function Documentation

◆ initializeForces()

void DirectSum::initializeForces ( )
overridevirtual

Calculate forces at the beginning of the simulation that the old force is not 0.

Implements Model.

Here is the call graph for this function:

◆ step()

void DirectSum::step ( int  iteration)
overridevirtual

Perform one time step in the direct sum model.

Parameters
iterationCurrent iteration the simulator is in.

Implements Model.

Here is the call graph for this function:

Member Data Documentation

◆ particles

DefaultParticleContainer DirectSum::particles
private

This model uses the DefaultParticleContainer to store its particles.


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