|
Molecular Dynamics
v0.4
Project for the Practical hosted by the Scientific Computing Chair
|
Abstract base class for any model for molecule simulation. More...
#include <Model.h>


Public Member Functions | |
| 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 > ¢er, 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 > ¢er, 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... | |
| virtual void | step (int iteration)=0 |
| Perform one single step in the simulation. More... | |
| ParticleContainer & | getParticles () const |
| Get the Particles of this model. More... | |
| virtual void | initializeForces ()=0 |
| Calculate forces at the beginning of the simulation that the old force is not 0. More... | |
Protected Member Functions | |
| 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 | |
| ParticleContainer & | particles |
| Force & | force |
| double | deltaT |
| bool | gravityOn |
| std::array< double, 3 > | g |
Private Attributes | |
| FileHandler | fileHandler |
| FileHandler::outputFormat | outputFormat |
Friends | |
| class | DefaultThermostat |
| class | Thermostat |
| class | FlowThermostat |
Abstract base class for any model for molecule simulation.
Each specific model should extend this class. At the moment there are two different models: -Direct Sum -Linked Cells
|
protected |
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.
| particles | Particle container of the model. This parameter is instantiated with the appropriated container by the derived models. |
| force | Force to use in the simulation. |
| deltaT | Duration of one time step. Small time step will result in a better simulation, but will demand more computational resources. |
| outputFormat | Format of the output file. Supported formats are vtk and xyz. |
| gravityOn | Toggle gravtiy on or of |
| g | Gravity factor |
|
virtualdefault |
Virtual default constructor to guarantee appropriate memory clean up.
| void Model::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.
| position | The coordinates of the lower left front-side corner. |
| N1 | Number of particles in dimension N1. |
| N2 | Number of particles in dimension N2. |
| N3 | Number of particles in dimension N3. |
| h | Distance of the particles (mesh width of the grid). |
| mass | Mass of one particle. |
| initVelocity | Initial velocity of the of the particles. |
| dimensions | Number of dimensions to which the Brownian Motion will be added. Valid values are 0, 1, 2 and 3. |
| brownianMotionAverageVelocity | |
| epsilon | Leonard Jones parameter epsilon |
| sigma | Leonard Jones parameter sigma |
| fixed | Fix particles. |

| void Model::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.
| center | The coordinates of the center of the disc. |
| initVelocity | Initial velocity of the of the particles. |
| N | Number of particles along the radius, including the particle in the center. |
| h | Distance of the particles (mesh width of the grid). |
| mass | Mass of one particle. |
| dimensions | Number of dimensions to which the Brownian Motion will be added. Valid values are 0, 1, 2 and 3. |
| brownianMotionAverageVelocity | Constant, specifying the average velocity of the Brownian Motion. |
| epsilon | Leonard Jones parameter epsilon |
| sigma | Leonard Jones parameter sigma |
| fixed | Fix particles. |

| void Model::addParticle | ( | Particle & | p | ) |
Add a single particle to this model.
| p | Particle to add to this model. |

| void Model::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.
| center | The coordinates of the center of the disc. |
| initVelocity | Initial velocity of the of the particles. |
| N | Number of particles along the radius, including the particle in the center. |
| h | Distance of the particles (mesh width of the grid). |
| mass | Mass of one particle. |
| dimensions | Number of dimensions to which the Brownian Motion will be added. Valid values are 0, 1, 2 and 3. |
| brownianMotionAverageVelocity | Constant, specifying the average velocity of the Brownian Motion. |
| epsilon | Leonard Jones parameter epsilon |
| sigma | Leonard Jones parameter sigma |
| fixed | Fix particles. |

| void Model::addViaFile | ( | std::string & | filepath, |
| FileHandler::inputFormat | inputFormat | ||
| ) |
Add new particles / particle structures to the model via a file.
| filepath | Path to the file. Example: ../input/eingabe-sonne.txt |
| inputFormat | Format of the input file (txt, xml) |

|
protected |
Add a gravitational force of g * m along the y-axis to each particle inside the simulation domain.


|
inline |
Get the Particles of this model.
Should be only used for testing purposes.
|
pure virtual |
Calculate forces at the beginning of the simulation that the old force is not 0.
Implemented in LinkedCells, and DirectSum.
| void Model::plot | ( | int | iteration, |
| std::string & | baseName | ||
| ) |
Write current state of the model to a file.
| iteration | Current iteration. |
| baseName | Base name of the output file. |

| void Model::saveState | ( | ) |
Export the current state of all molecules to a txt file for using them in a new simulation.

|
pure virtual |
Perform one single step in the simulation.
@parameter Current iteration the simulator is in.
Each step consists of force, velocity and position updates. For each concrete model the exact implementation might differ.
Implemented in LinkedCells, and DirectSum.
| void Model::updateForces | ( | ) | const |
Helper method to calculate the force between all particles.
After each time step the forces acting between the particles have changed due to their new positions, so they have to be recalculated. This method uses Newtons third law of motion to simplify calculations and make them more efficient.


|
protected |
Helper method to calculate the position of all particles.
After each time step positions of all particles with velocities unequal to zero have to be updated.


|
protected |
Helper method to calculate the velocity of all particles.
After each time step the velocity of each particle may have changed due to forces that act between the particles.


|
friend |
|
friend |
|
friend |
|
protected |
|
private |
|
protected |
|
protected |
|
protected |
|
private |
|
protected |