CellGPU  0.8.0
GPU-accelerated simulations of cells
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
NoseHooverChainNVT Class Reference

Implements NVT dynamics according to the Nose-Hoover equations of motion with a chain of thermostats. More...

#include <NoseHooverChainNVT.h>

Inheritance diagram for NoseHooverChainNVT:
Inheritance graph
[legend]

Public Member Functions

 NoseHooverChainNVT (int N, int M=2)
 The base constructor asks for the number of particles and the length of the chain. More...
 
virtual void set2DModel (shared_ptr< Simple2DModel > _model)
 set the internal State to the given model
 
virtual void integrateEquationsOfMotion ()
 the fundamental function that models will call, using vectors of different data structures More...
 
virtual void integrateEquationsOfMotionCPU ()
 call the CPU routine to integrate the e.o.m. More...
 
virtual void integrateEquationsOfMotionGPU ()
 call the GPU routine to integrate the e.o.m. More...
 
Dscalar getT ()
 Get temperature, T.
 
void setT (Dscalar _T)
 Set temperature, T, and also the bath masses! More...
 
void reportBathData ()
 Report the current status of the bath. More...
 
int getTimestep ()
 get the number of timesteps run
 
Dscalar getTime ()
 get the current simulation time
 
virtual void setDeltaT (Dscalar dt)
 Set the simulation time stepsize.
 
virtual void performUpdate ()
 performUpdate just maps to integrateEquationsOfMotion
 
virtual void setReproducible (bool rep)
 Set whether the source of noise should always use the same random numbers.
 
void reIndexRNG (GPUArray< curandState > &array)
 re-index the any RNGs associated with the e.o.m.
 
virtual void Update (int timestep)
 The fundamental function that a controlling Simulation can call.
 
void setPeriod (int _p)
 set the period
 
void setPhase (int _p)
 set the phase
 
virtual void spatialSorting ()
 allow for spatial sorting to be called if necessary...
 
virtual void setGPU ()
 Enforce GPU-only operation. This is the default mode, so this method need not be called most of the time.
 
virtual void setCPU ()
 Enforce CPU-only operation. Derived classes might have to do more work when the CPU mode is invoked.
 
int getNdof ()
 Get the number of degrees of freedom of the equation of motion.
 
void setNdof (int _n)
 Set the number of degrees of freedom of the equation of motion.
 

Public Attributes

shared_ptr< Simple2DModelState
 The system that can compute forces, move degrees of freedom, etc.
 
GPUArray< Dscalar > kineticEnergyScaleFactor
 Helper structure for GPU branch. A two-component GPU array that contains the total KE and the velocity scale factor.
 
GPUArray< Dscalar4 > BathVariables
 the (position,velocity,acceleration,mass) of the bath degrees of freedom
 
shared_ptr< Simple2DModelmodel
 A pointer to a Simple2DModel that the updater acts on.
 

Protected Member Functions

void propagateChain ()
 Propagate the chain. More...
 
void propagatePositionsVelocities ()
 Propagate the position and velocity of the particles. More...
 
void rescaleVelocitiesGPU ()
 Rescale velocities on the GPU. More...
 
void calculateKineticEnergyGPU ()
 combine kernel calls for vector combination and parallel reduction to compute the KE in the helper structure More...
 
void propagatePositionsVelocitiesGPU ()
 Propagate the position and velocity of the particles...on the gpu. More...
 
void reIndexArray (GPUArray< int > &array)
 Re-index cell arrays after a spatial sorting has occured.
 
void reIndexArray (GPUArray< Dscalar > &array)
 why use templates when you can type more?
 
void reIndexArray (GPUArray< Dscalar2 > &array)
 why use templates when you can type more?
 

Protected Attributes

Dscalar Temperature
 The targeted temperature.
 
int Nchain
 The length of the NH chain.
 
int Ndof
 The number of particles in the State.
 
GPUArray< Dscalar > keArray
 A helper vector for the GPU branch...can be asked to store 0.5*m[i]*v[i]^2 as an array.
 
GPUArray< Dscalar > keIntermediateReduction
 A helper structure for performing parallel reduction of the keArray.
 
int Timestep
 Count the number of integration timesteps.
 
Dscalar deltaT
 The time stepsize of the simulation.
 
GPUArray< Dscalar2 > displacements
 an internal GPUArray for holding displacements
 
noiseSource noise
 A source of noise for the equation of motion.
 
int Period
 The period of the updater... the updater will work every Period timesteps.
 
int Phase
 The phase of the updater... the updater will work every Period timesteps offset by a phase.
 
bool GPUcompute
 whether the updater does its work on the GPU or not
 
vector< int > reIndexing
 a vector of the re-indexing information
 

Detailed Description

Implements NVT dynamics according to the Nose-Hoover equations of motion with a chain of thermostats.

This allows one to do standard NVT simulations. A chain (whose length can be specified by the user) of thermostats is used to maintain the target temperature. We closely follow the Frenkel & Smit update scheme, which is itself based on: Martyna, Tuckerman, Tobias, and Klein Mol. Phys. 87, 1117 (1996)

Constructor & Destructor Documentation

◆ NoseHooverChainNVT()

NoseHooverChainNVT::NoseHooverChainNVT ( int  N,
int  M = 2 
)

The base constructor asks for the number of particles and the length of the chain.

Initialize everything, by default setting the target temperature to unity. Note that in the current set up the thermostate masses are automatically set by the target temperature, assuming = 1

References BathVariables, ArrayHandle< T >::data, simpleEquationOfMotion::deltaT, simpleEquationOfMotion::displacements, updater::GPUcompute, keArray, keIntermediateReduction, kineticEnergyScaleFactor, Nchain, Ndof, GPUArray< T >::resize(), setT(), and simpleEquationOfMotion::Timestep.

Member Function Documentation

◆ integrateEquationsOfMotion()

void NoseHooverChainNVT::integrateEquationsOfMotion ( )
virtual

the fundamental function that models will call, using vectors of different data structures

Advance by one time step. Of note, for computational efficiency the topology is only updated on the half-time steps (i.e., right before the instantaneous forces will to be computed). This means that after each call to the simulation to "performTimestep()" there is no guarantee that the topology will actually be up-to-date. Probably best to call enforceTopology just before saving or evaluating shape outside of the normal timestep loops.

Reimplemented from simpleEquationOfMotion.

References simpleEquationOfMotion::displacements, updater::GPUcompute, integrateEquationsOfMotionCPU(), integrateEquationsOfMotionGPU(), Ndof, GPUArray< T >::resize(), setT(), State, Temperature, and simpleEquationOfMotion::Timestep.

Referenced by set2DModel().

◆ integrateEquationsOfMotionCPU()

void NoseHooverChainNVT::integrateEquationsOfMotionCPU ( )
virtual

call the CPU routine to integrate the e.o.m.

The implementation here closely follows algorithms 30 - 32 in Frenkel & Smit, generalized to the case where the chain length is not necessarily always 2

References ArrayHandle< T >::data, access_location::host, kineticEnergyScaleFactor, Ndof, propagateChain(), propagatePositionsVelocities(), access_mode::read, and State.

Referenced by integrateEquationsOfMotion(), and set2DModel().

◆ integrateEquationsOfMotionGPU()

void NoseHooverChainNVT::integrateEquationsOfMotionGPU ( )
virtual

call the GPU routine to integrate the e.o.m.

The GPU implementation of the identical algorithm done on the CPU

References calculateKineticEnergyGPU(), propagateChain(), propagatePositionsVelocitiesGPU(), and rescaleVelocitiesGPU().

Referenced by integrateEquationsOfMotion(), and set2DModel().

◆ setT()

void NoseHooverChainNVT::setT ( Dscalar  T)

Set temperature, T, and also the bath masses!

Set the target temperature to the specified value. Additionally, use the observation in the Mol Phys paper to set the masses of the chain of thermostats

Referenced by integrateEquationsOfMotion(), and NoseHooverChainNVT().

◆ reportBathData()

void NoseHooverChainNVT::reportBathData ( )

Report the current status of the bath.

print out the current state of the bath: (pos, vel, accel, mass) for each element of the chain

References BathVariables, ArrayHandle< T >::data, and GPUArray< T >::getNumElements().

◆ propagateChain()

void NoseHooverChainNVT::propagateChain ( )
protected

Propagate the chain.

The simple part of the algorithm partially updates the chain positions and velocities. It should be called twice per time step

References kineticEnergyScaleFactor.

Referenced by integrateEquationsOfMotionCPU(), and integrateEquationsOfMotionGPU().

◆ propagatePositionsVelocities()

void NoseHooverChainNVT::propagatePositionsVelocities ( )
protected

Propagate the position and velocity of the particles.

The simple part of the algorithm actually updates the positions and velocities of the partices. This is the step in which a force calculation is required.

References ArrayHandle< T >::data, and kineticEnergyScaleFactor.

Referenced by integrateEquationsOfMotionCPU().

◆ rescaleVelocitiesGPU()

void NoseHooverChainNVT::rescaleVelocitiesGPU ( )
protected

Rescale velocities on the GPU.

Simply call the velocity rescaling function...

References ArrayHandle< T >::data, access_location::device, gpu_NoseHooverChainNVT_scale_velocities(), kineticEnergyScaleFactor, Ndof, access_mode::read, access_mode::readwrite, and State.

Referenced by integrateEquationsOfMotionGPU().

◆ calculateKineticEnergyGPU()

void NoseHooverChainNVT::calculateKineticEnergyGPU ( )
protected

combine kernel calls for vector combination and parallel reduction to compute the KE in the helper structure

This combines multiple kernel calls. First we make a vector of kinetic energies per particle, then we perform a parallel block reduction, and then a serial reduction

References ArrayHandle< T >::data, access_location::device, gpu_parallel_reduction(), gpu_prepare_KE_vector(), keArray, keIntermediateReduction, kineticEnergyScaleFactor, Ndof, access_mode::overwrite, access_mode::read, access_mode::readwrite, and State.

Referenced by integrateEquationsOfMotionGPU().

◆ propagatePositionsVelocitiesGPU()

void NoseHooverChainNVT::propagatePositionsVelocitiesGPU ( )
protected

Propagate the position and velocity of the particles...on the gpu.

Do a multi-step dance to get the positions and velocities updated on the gpu branch

Referenced by integrateEquationsOfMotionGPU().


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