ls1-MarDyn
ls1-MarDyn molecular dynamics code
Classes | Public Member Functions | Static Public Member Functions | List of all members
Simulation Class Reference

Controls the simulation process. More...

#include <Simulation.h>

Public Member Functions

 Simulation ()
 
 ~Simulation ()
 
void readXML (XMLfileUnits &xmlconfig)
 Read in XML configuration for simulation and all its included objects. More...
 
void readConfigFile (std::string filename)
 process configuration file More...
 
void initConfigXML (const std::string &inputfilename)
 Opens given XML file and reads in parameters for the simulaion. More...
 
void prepare_start ()
 calculate all values for the starting timepoint More...
 
void simulate ()
 Controls the main loop of the simulation. More...
 
void pluginEndStepCall (unsigned long simstep)
 call plugins every nth-simstep More...
 
void finalize ()
 clean up simulation
 
void updateParticleContainerAndDecomposition (double lastTraversalTime, bool useTimers)
 
void performOverlappingDecompositionAndCellTraversalStep (double etime)
 
void setDomainDecomposition (DomainDecompBase *domainDecomposition)
 
DomainDecompBasedomainDecomposition ()
 
DomaingetDomain ()
 
IntegratorgetIntegrator ()
 
ParticleContainergetMoleculeContainer ()
 
void setNumTimesteps (unsigned long steps)
 
unsigned long getNumTimesteps ()
 
unsigned long getNumInitTimesteps ()
 
unsigned long getSimulationStep ()
 
void setLoopAbortTime (double time)
 
double getcutoffRadius () const
 
void setcutoffRadius (double cutoffRadius)
 
double getLJCutoff () const
 
void setLJCutoff (double LJCutoffRadius)
 
unsigned long getTotalNumberOfMolecules () const
 
double Tfactor (unsigned long simstep)
 Temperature increase factor function during automatic equilibration. More...
 
void initCanonical (unsigned long t)
 
void initGrandCanonical (unsigned long t)
 
void initStatistics (unsigned long t)
 
unsigned long getInitStatistics () const
 
void setSimulationTime (double curtime)
 
void advanceSimulationTime (double timestep)
 
double getSimulationTime ()
 
void setEnsemble (Ensemble *ensemble)
 
EnsemblegetEnsemble ()
 
std::shared_ptr< MemoryProfilergetMemoryProfiler ()
 
TimerProfilertimers ()
 
double getH ()
 get Planck constant
 
void setH (double h_extern)
 set Planck constant
 
unsigned long getNumberOfTimesteps () const
 
double getAndResetOneLoopCompTime ()
 computational time for one execution of traverseCell
 
void setOutputPrefix (std::string prefix)
 
void setOutputPrefix (char *prefix)
 
std::string getOutputPrefix ()
 
void enableFinalCheckpoint ()
 
void disableFinalCheckpoint ()
 
void useLegacyCellProcessor ()
 
void enableMemoryProfiler ()
 
void setForcedCheckpointTime (double time)
 
void initialize ()
 
PluginBasegetPlugin (const std::string &name)
 get plugin More...
 
std::list< PluginBase * > * getPluginList ()
 
void initGlobalEnergyLog ()
 
void writeGlobalEnergyLog (const double &globalUpot, const double &globalT, const double &globalPressure)
 
CellProcessorgetCellProcessor () const
 
void refreshParticleIDs ()
 Refresh particle IDs to continuous numbering.
 
bool keepRunning ()
 Checks if Simsteps or MaxWallTime are reached.
 

Static Public Member Functions

static void exit (int exitcode)
 Terminate simulation with given exit code. More...
 

Detailed Description

Controls the simulation process.

Author
Martin Bernreuther bernr.nosp@m.euth.nosp@m.er@hl.nosp@m.rs.d.nosp@m.e et al. (2010)

Simulation parameters are provided via a xml config file or can be set directly via the corresponding methods.

Constructor & Destructor Documentation

◆ Simulation()

Simulation::Simulation ( )

Instantiate simulation object

◆ ~Simulation()

Simulation::~Simulation ( )

destruct simulation object

Member Function Documentation

◆ domainDecomposition()

DomainDecompBase& Simulation::domainDecomposition ( )
inline

Return a reference to the domain decomposition used in the simulation

◆ exit()

void Simulation::exit ( int  exitcode)
static

Terminate simulation with given exit code.

The exit method takes care over the right way to terminate the application in a correct way for the different parallelization schemes. e.g. terminating other processes in MPI parallel execution mode.

◆ getDomain()

Domain* Simulation::getDomain ( )
inline

Get pointer to the domain

◆ getIntegrator()

Integrator* Simulation::getIntegrator ( )
inline

Get pointer to the integrator

◆ getMoleculeContainer()

ParticleContainer* Simulation::getMoleculeContainer ( )
inline

Get pointer to the molecule container

◆ getNumInitTimesteps()

unsigned long Simulation::getNumInitTimesteps ( )
inline

Get initial number of steps

◆ getNumTimesteps()

unsigned long Simulation::getNumTimesteps ( )
inline

Get the number of time steps to be performed in the simulation

◆ getPlugin()

PluginBase * Simulation::getPlugin ( const std::string &  name)

get plugin

Returns
pointer to the plugin if it is active, otherwise nullptr

◆ getSimulationStep()

unsigned long Simulation::getSimulationStep ( )
inline

Get the number of the actual time step currently processed in the simulation.

◆ initConfigXML()

void Simulation::initConfigXML ( const std::string &  inputfilename)

Opens given XML file and reads in parameters for the simulaion.

Parameters
[in]inputfilenamefilename of the XML input file

◆ initGlobalEnergyLog()

void Simulation::initGlobalEnergyLog ( )

Global energy log

◆ initialize()

void Simulation::initialize ( )

initialize all member variables with a suitable value

◆ performOverlappingDecompositionAndCellTraversalStep()

void Simulation::performOverlappingDecompositionAndCellTraversalStep ( double  etime)

Performs both the decomposition and the cell traversal in an overlapping way. The overlapping is needed to speed up the overall computation. The order of cells traversed will be different, than for the non-overlapping case, slightly different results are possible.

◆ pluginEndStepCall()

void Simulation::pluginEndStepCall ( unsigned long  simstep)

call plugins every nth-simstep

The present method serves as a redirection to the actual plugins. That includes a) particular plugin objects included in _plugins,

Parameters
[in]simsteptimestep of the plugins

◆ prepare_start()

void Simulation::prepare_start ( )

calculate all values for the starting timepoint

After the input file has been read in, only the information which is directly in the inputfile is known at time step zero. This includes e.g. Molecule position and velocities, but not forces which act on the molecules or macroscopic values at the potential. This method has to ensure, that all values are available at time step zero

Init TemperatureControl beta_trans, beta_rot log-files, register as observer if plugin DistControl is in use.

refresh particle IDs

◆ readConfigFile()

void Simulation::readConfigFile ( std::string  filename)

process configuration file

calls initConfigXML

Parameters
[in]filenamefilename of the input file

◆ readXML()

void Simulation::readXML ( XMLfileUnits xmlconfig)

Read in XML configuration for simulation and all its included objects.

The following xml object structure is handled by this method:

<simulation>
<integrator type="STRING"><!-- see Integrator class documentation --></integrator>
<run>
<production>
<steps>INTEGER</steps>
</production>
<equilibration>
<steps>INTEGER</steps>
</equilibration>
<currenttime>DOUBLE</currenttime>
</run>
<ensemble type=STRING> <!-- see Ensemble class documentation --></ensemble>
<algorithm>
<cutoffs>
<radiusLJ>DOUBLE</radiusLJ>
</cutoffs>
<electrostatic type='ReactionField'>
<epsilon>DOUBLE</epsilon>
</electrostatic>
<datastructure type=STRING><!-- see ParticleContainer class documentation --></datastructure>
<parallelisation type=STRING><!-- see DomainDecompBase class documentation -->
<timerForLoad>STRING</timerForLoad><!-- Timer to use as load. Requires valid timer name! -->
<timerForLoad_AveragingLength>UINT</timerForLoad_AveragingLength><!-- Defines how many time measurements should be averaged as input for the load balancing.-->
</parallelisation>
<thermostats>
<thermostat type='VelocityScaling' componentId=STRING><!-- componentId can be component id or 'global' -->
<temperature>DOUBLE</temperature>
</thermostat>
</thermostats>
</algorithm>
<output>
<outputplugin name=STRING enabled="yes|no"><!-- see OutputBase class and specific plugin documentation --></outputplugin>
</output>
<plugin name=STRING enabled="yes|no" (default yes)><!-- see PluginBase class and specific plugin documentation --></plugin>
</simulation>
Todo:
Here we store data in the _domain member as long as we do not use the ensemble everywhere
Todo:
introduce maxCutoffRadius here for datastructures, ... maybe use map/list to store cutoffs for different potentials?
Todo:
This may be better go into a physical section for constants?
Todo:
Dummy Decomposition now included in DecompBase - still keep this name?
Todo:
Review if we need to know the max cutoff radius usable with any datastructure.
Todo:
read header should be either part of readPhaseSpace or readXML.

Prepare start options, affecting behavior of method prepare_start()

◆ setDomainDecomposition()

void Simulation::setDomainDecomposition ( DomainDecompBase domainDecomposition)

Set the private _domainDecomposition variable to a new pointer.

Parameters
domainDecompositionthe new va

◆ setLoopAbortTime()

void Simulation::setLoopAbortTime ( double  time)
inline

Set Loop Time Limit in seconds

◆ setNumTimesteps()

void Simulation::setNumTimesteps ( unsigned long  steps)
inline

Set the number of time steps to be performed in the simulation

◆ simulate()

void Simulation::simulate ( )

Controls the main loop of the simulation.

precondition for this method is that initialize() has been called. The main loop calls all methods which have to be called in each iteration step, e.g. initializes the molecule Container, calculates the forces, ...
For the integration, a seperate integration object is used. This method is written in a way that should make it possible to use different integrators without having to change anything. Whenever something is done which might make it necessary for an integrator to do something, the integrator is informed about that using the integrators corresponding method (see integrator documentation) It follows a coarse outline of what has to be done:

  • Do all output that has to be done in each time step
  • Inform the iterator that all information is available (new timestep)
  • As the position of the molecules changed, the domain decomposition and the datastructure have to be updated
  • calculate forces (and afterwards delete halo)
  • Inform the iterator that forces for the new positions have been calculated
  • The iterator should now have finished everything to be done in this time step, so the macroscopic values can be calculated
  • velocity and angular momentum have to be scaled

< timer for the entire simulation loop (synced)

< timer for decomposition: sub-timer of loopTimer

< timer for computation: sub-timer of loopTimer

< timer for io in simulation loop: sub-timer of loopTimer

< timer for force calculation: sub-timer of computationTimer

< timer for measuring MPI-OMP communication time: sub-timer of decompositionTimer

Todo:
the number of particles per component stored in components has to be updated here in case we insert/remove particles

◆ Tfactor()

double Simulation::Tfactor ( unsigned long  simstep)

Temperature increase factor function during automatic equilibration.

Parameters
[in]currentsimulation time step

The present version of Mardyn provides the option of equilibrating the system at an increased temperature. This has, of course, the advantage that the equilibration is accelerated. In a special case that is of particular interest to a relevant subset of the developers, namely MD simulation of nucleation, it also reduces the amount of clusters formed during equilibration. Then, the actual nucleation process can be investigated for the equilibrated system.

Equilibration at an increased temperature is nothing new, in principle it could be considered a variant of simulated annealing. For the purpose of accelerating the relaxation, starting from an unrealistic initial state, it was e.g. proposed in the thesis of M. Kreitmeir.

The key parameter to regulating the equilibration is this->_initCanonical. The system is gradually heated and cooled again, and from this->_initCanonical on the temperature is constant (i.e. this method returns 1.0).

Thus, if temperature increase is to be avoided, the user should set the "initCanonical" parameter to "0".

◆ updateParticleContainerAndDecomposition()

void Simulation::updateParticleContainerAndDecomposition ( double  lastTraversalTime,
bool  useTimers 
)

The following things have to be done here:

  • bring all molecules to the corresponding processes (including copies for halo)
  • update the caches of the molecules
  • update the ParticleContainer

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