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

Model that implements the linked cell algorithm. More...

#include <LinkedCells.h>

Inheritance diagram for LinkedCells:
Inheritance graph
Collaboration diagram for LinkedCells:
Collaboration graph

Public Member Functions

 LinkedCells (Force &force, double deltaT, std::array< double, 3 > domainSize, double rCutOff, FileHandler::outputFormat outputFormat, BoundarySet boundaryConditions, bool gravityOn, std::array< double, 3 > g={}, MembraneParameters membraneParameters=MembraneParameters{}, enumsStructs::ParallelizationStrategy parallelizationStrategy=enumsStructs::ParallelizationStrategy::none)
 Contruct a new Linked Cells model. More...
 
void step (int iteration) override
 Perform one time step in the linked cells model. More...
 
void updateForcesOptimized ()
 Implements the optimization we presented as our second idea. At the moment this is dead code, because we did not have time yet to make it compatible with our current program structure and only integrated it once when doing the time measurements. 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 Member Functions

void processBoundaryForces ()
 Apply forces to all particles in boundary cells according to the specified boundary conditions. More...
 
void processHaloCells ()
 Process all particles which have left the domain at the end of a simulation step according to the specified boundary conditions. More...
 
void pullMarkedParticles ()
 Apply to all particles that are marked a constant force. More...
 
void updateForcesMembrane ()
 Calculate forces between particles in a membrane structure. More...
 

Private Attributes

bool membraneSetting
 
bool pull
 
int pullingActiveUntil
 
std::array< double, 3 > pullingForce {}
 
std::unique_ptr< ForceforceBetweenDiagonalNeighborsInMembrane
 
std::unique_ptr< ForceforceBetweenDirectNeighborsInMembrane
 
enumsStructs::ParallelizationStrategy parallelizationStrategy
 
LinkedCellsContainer particles
 
std::vector< std::pair< Side, enumsStructs::BoundaryCondition > > boundarySettings
 

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 linked cell algorithm.

The linked-cells algorithm is significantly faster than the direct sum algorithm. It reduces the time complexity from O(n²) to O(n). The following plot shows some benchmarks.

Benchmarks

Constructor & Destructor Documentation

◆ LinkedCells()

LinkedCells::LinkedCells ( Force force,
double  deltaT,
std::array< double, 3 >  domainSize,
double  rCutOff,
FileHandler::outputFormat  outputFormat,
BoundarySet  boundaryConditions,
bool  gravityOn,
std::array< double, 3 >  g = {},
MembraneParameters  membraneParameters = MembraneParameters{},
enumsStructs::ParallelizationStrategy  parallelizationStrategy = enumsStructs::ParallelizationStrategy::none 
)

Contruct a new Linked Cells model.

Parameters
forceForce to use.
deltaTDiscretisation step.
domainSizeDomain size.
rCutOffCutoff radius.
outputFormatOutput format.
boundaryConditionsBoundary conditions.
gravityOnToggle gravity on or off.
gGravitational factor.
membraneParametersContains specification if a membrane is simulated
parallelizationStrategyStrategy to use for parallelization.
Here is the call graph for this function:

Member Function Documentation

◆ initializeForces()

void LinkedCells::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:

◆ processBoundaryForces()

void LinkedCells::processBoundaryForces ( )
private

Apply forces to all particles in boundary cells according to the specified boundary conditions.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processHaloCells()

void LinkedCells::processHaloCells ( )
private

Process all particles which have left the domain at the end of a simulation step according to the specified boundary conditions.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pullMarkedParticles()

void LinkedCells::pullMarkedParticles ( )
private

Apply to all particles that are marked a constant force.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ step()

void LinkedCells::step ( int  iteration)
overridevirtual

Perform one time step in the linked cells model.

Parameters
iterationCurrent iteration the simulator is in.

Implements Model.

Here is the call graph for this function:

◆ updateForcesMembrane()

void LinkedCells::updateForcesMembrane ( )
private

Calculate forces between particles in a membrane structure.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateForcesOptimized()

void LinkedCells::updateForcesOptimized ( )

Implements the optimization we presented as our second idea. At the moment this is dead code, because we did not have time yet to make it compatible with our current program structure and only integrated it once when doing the time measurements.

Here is the call graph for this function:

Member Data Documentation

◆ boundarySettings

std::vector<std::pair<Side, enumsStructs::BoundaryCondition> > LinkedCells::boundarySettings
private

Definition of the boundary condition for each side.

◆ forceBetweenDiagonalNeighborsInMembrane

std::unique_ptr<Force> LinkedCells::forceBetweenDiagonalNeighborsInMembrane
private

◆ forceBetweenDirectNeighborsInMembrane

std::unique_ptr<Force> LinkedCells::forceBetweenDirectNeighborsInMembrane
private

◆ membraneSetting

bool LinkedCells::membraneSetting
private

◆ parallelizationStrategy

enumsStructs::ParallelizationStrategy LinkedCells::parallelizationStrategy
private

◆ particles

LinkedCellsContainer LinkedCells::particles
private

This model uses the LinkedCellsContainer to store its particles

◆ pull

bool LinkedCells::pull
private

◆ pullingActiveUntil

int LinkedCells::pullingActiveUntil
private

◆ pullingForce

std::array<double, 3> LinkedCells::pullingForce {}
private

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