DFT-FE 1.1.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
dftfe::molecularDynamicsClass Class Reference

#include <molecularDynamicsClass.h>

Public Member Functions

 molecularDynamicsClass (const std::string parameter_file, const std::string restartFilesPath, const MPI_Comm &mpi_comm_parent, const bool restart, const int verbosity, const bool useDevice)
 molecularDynamicsClass constructor: copy data from dftparameters to the memebrs of molecularDynamicsClass
 
int runMD ()
 runMD: Assign atom mass to charge. Create vectors for displacement, velocity, force. Create KE vector, TE vector, PE vector. Initialise velocities from Boltsmann distribution. Set Center of Mass velocities to be 0. Call the resepective ensemble based on input file
 

Public Attributes

const double haPerBohrToeVPerAng = 27.211386245988 / 0.529177210903
 
const double haToeV = 27.211386245988
 
const double bohrToAng = 0.529177210903
 
const double AngTobohr = 1.0 / bohrToAng
 
const double kB = 8.617333262e-05
 
int d_startingTimeStep
 

Private Member Functions

int mdNVE (std::vector< double > &KineticEnergyVector, std::vector< double > &InternalEnergyVector, std::vector< double > &EntropicEnergyVector, std::vector< double > &TotalEnergyVector, std::vector< dealii::Tensor< 1, 3, double > > &displacements, std::vector< double > &velocity, std::vector< double > &force, const std::vector< double > &atomMass)
 mdNVE Performs a Ccanonical Ensemble MD calculation. The inital temperature is set by runMD(). Temperature is NOT_CONTROLLED. Controls the timeloop.
 
int mdNVTnosehoverchainsThermostat (std::vector< double > &KineticEnergyVector, std::vector< double > &InternalEnergyVector, std::vector< double > &EntropicEnergyVector, std::vector< double > &TotalEnergyVector, std::vector< dealii::Tensor< 1, 3, double > > &displacements, std::vector< double > &velocity, std::vector< double > &force, const std::vector< double > &atomMass)
 mdNVTnosehoverchainsThermostat Performs a Canonical Ensemble MD calculation. The inital temperature is set by runMD(). Thermostat type is NOSE_HOVER_CHAINS. Controls the timeloop.
 
int mdNVTrescaleThermostat (std::vector< double > &KineticEnergyVector, std::vector< double > &InternalEnergyVector, std::vector< double > &EntropicEnergyVector, std::vector< double > &TotalEnergyVector, std::vector< dealii::Tensor< 1, 3, double > > &displacements, std::vector< double > &velocity, std::vector< double > &force, const std::vector< double > &atomMass)
 mdNVTrescaleThermostat Performs a Constant Kinetic Energy Ensemble MD calculation. The inital temperature is set by runMD(). Thermostat type is RESCALE. Controls the timeloop. At timestep which is multiple of Thermostat time constatn, the veloctites are rescaled *such that the temperature is set to inital temperature .
 
int mdNVTsvrThermostat (std::vector< double > &KineticEnergyVector, std::vector< double > &InternalEnergyVector, std::vector< double > &EntropicEnergyVector, std::vector< double > &TotalEnergyVector, std::vector< dealii::Tensor< 1, 3, double > > &displacements, std::vector< double > &velocity, std::vector< double > &force, const std::vector< double > &atomMass)
 mdNVTsvrThermostat Performs a Canonical Ensemble MD calculation. The inital temperature is set by runMD(). Thermostat type is SVR. Controls the timeloop.
 
double RescaleVelocities (std::vector< double > &v, const std::vector< double > &M, double Temperature)
 RescaleVelocities controls the velocity at timestep t. The scaling of velocities depends on ratio of T at that timestep and inital Temperature.
 
void NoseHoverChains (std::vector< double > &v, std::vector< double > &v_e, std::vector< double > &e, std::vector< double > Q, double KE, double Temperature)
 NoseHoverChains controls the velocity at timestep t. The temperature is contolled by 2 thermostats. Thermostat 1 contols the velocity of all Charges. Thermostat 2 controls thermostat 1. Employs Extended Lagrangian approach.
 
double svr (std::vector< double > &v, double KE, double KEref)
 
double velocityVerlet (std::vector< double > &v, std::vector< dealii::Tensor< 1, 3, double > > &r, const std::vector< double > &atomMass, std::vector< double > &forceOnAtoms)
 velocityVerlet
 
void writeRestartFile (const std::vector< dealii::Tensor< 1, 3, double > > &disp, const std::vector< double > &velocity, const std::vector< double > &force, const std::vector< double > &KineticEnergyVector, const std::vector< double > &InternalEnergyVector, const std::vector< double > &TotalEnergyVector, int time)
 writeRestartFile: Writing files at each timestep to mdRestart
 
void InitialiseFromRestartFile (std::vector< dealii::Tensor< 1, 3, double > > &disp, std::vector< double > &velocity, std::vector< double > &force, std::vector< double > &KE, std::vector< double > &IE, std::vector< double > &TE)
 InitialiseFromRestartFile : Initialise atomcordinates, velocity and force at restart.
 
void writeRestartNHCfile (const std::vector< double > &v_e, const std::vector< double > &e, const std::vector< double > &Q, const int time)
 NoseHoverExtendedLagrangian Writes the NHC parameters at each timeStep.
 
void InitialiseFromRestartNHCFile (std::vector< double > &v_e, std::vector< double > &e, std::vector< double > &Q)
 InitialiseFromRestartNHCFile: Reads the NHC parameters during restart.
 
void writeTotalDisplacementFile (const std::vector< dealii::Tensor< 1, 3, double > > &r, int time)
 writeTotalDisplacementFile: Updates Displacement.chk and appends TotalDisplacement.chk
 
double NoseHoverExtendedLagrangian (const std::vector< double > &thermovelocity, const std::vector< double > &thermoposition, const std::vector< double > &thermomass, double PE, double KE, double T)
 NoseHoverExtendedLagrangian: Computes the Nose-Hover Hamiltonian when using NHC thermostat.
 
int checkRestart (std::string &coordinatesFile, std::string &domainVectorsFile, bool &scfRestart)
 checkRestart: Identifies the folder containing the restart file, sets the path of coordinates file and restursn the starting timestep *
 
void DensityExtrapolation (int TimeStep)
 DensityExtrapolation Identifies the folder containing the restart file, sets the path of coordinates file and restursn the starting timestep *.
 
void DensitySplitExtrapolation (int TimeStep)
 DensityExtrapolation calculates the t+dt density as a second order extrapolation of density from t, t-dt and t-2dt.
 
void set ()
 set() initalises all the private datamembers of mdclass object from the parameters declared by user.
 

Private Attributes

std::unique_ptr< dftfeWrapperd_dftfeWrapper
 
dftBased_dftPtr
 
const MPI_Comm d_mpiCommParent
 
const unsigned int d_this_mpi_process
 
dealii::ConditionalOStream pcout
 
std::string d_restartFilesPath
 
const int d_verbosity
 
unsigned int d_restartFlag
 
unsigned int d_numberGlobalCharges
 
double d_TimeStep
 
unsigned int d_TimeIndex
 
unsigned int d_numberofSteps
 
double d_startingTemperature
 
int d_ThermostatTimeConstant
 
std::string d_ThermostatType
 
double d_MDstartWallTime
 
double d_MaxWallTime
 
std::vector< std::vector< double > > d_atomFractionalunwrapped
 
std::vector< double > d_domainLength
 
distributedCPUVec< double > d_extrapDensity_tmin2
 
distributedCPUVec< double > d_extrapDensity_tmin1
 
distributedCPUVec< double > d_extrapDensity_t0
 
distributedCPUVec< double > d_extrapDensity_tp1
 

Constructor & Destructor Documentation

◆ molecularDynamicsClass()

dftfe::molecularDynamicsClass::molecularDynamicsClass ( const std::string parameter_file,
const std::string restartFilesPath,
const MPI_Comm & mpi_comm_parent,
const bool restart,
const int verbosity,
const bool useDevice )

molecularDynamicsClass constructor: copy data from dftparameters to the memebrs of molecularDynamicsClass

Parameters
[in]dftBase*_dftBasePtr pointer to base class of dftClass
[in]mpi_comm_parentparent mpi communicator

Member Function Documentation

◆ checkRestart()

int dftfe::molecularDynamicsClass::checkRestart ( std::string & coordinatesFile,
std::string & domainVectorsFile,
bool & scfRestart )
private

checkRestart: Identifies the folder containing the restart file, sets the path of coordinates file and restursn the starting timestep *

Returns
StartingTimeStep the timestep to restart the MD from.

◆ DensityExtrapolation()

void dftfe::molecularDynamicsClass::DensityExtrapolation ( int TimeStep)
private

DensityExtrapolation Identifies the folder containing the restart file, sets the path of coordinates file and restursn the starting timestep *.

◆ DensitySplitExtrapolation()

void dftfe::molecularDynamicsClass::DensitySplitExtrapolation ( int TimeStep)
private

DensityExtrapolation calculates the t+dt density as a second order extrapolation of density from t, t-dt and t-2dt.

◆ InitialiseFromRestartFile()

void dftfe::molecularDynamicsClass::InitialiseFromRestartFile ( std::vector< dealii::Tensor< 1, 3, double > > & disp,
std::vector< double > & velocity,
std::vector< double > & force,
std::vector< double > & KE,
std::vector< double > & IE,
std::vector< double > & TE )
private

InitialiseFromRestartFile : Initialise atomcordinates, velocity and force at restart.

Parameters
[out]dispDisplacements of previous timestep from restart
[out]velocityVelocity updated from restart
[out]forceForce updated from dft->Solve
[out]PEFree energy of system at current Timestep
[out]KEKinetic ENergy of nuclei at current Timestep
[out]TEtemperature at current Timestep

◆ InitialiseFromRestartNHCFile()

void dftfe::molecularDynamicsClass::InitialiseFromRestartNHCFile ( std::vector< double > & v_e,
std::vector< double > & e,
std::vector< double > & Q )
private

InitialiseFromRestartNHCFile: Reads the NHC parameters during restart.

Parameters
[out]thermovelocityVelocity of each, updated at each TimeStep
[out]thermopositionPosition of each thermostat , updated at each TimeStep
[out]thermomassStores the mass of each thermostat.

◆ mdNVE()

int dftfe::molecularDynamicsClass::mdNVE ( std::vector< double > & KineticEnergyVector,
std::vector< double > & InternalEnergyVector,
std::vector< double > & EntropicEnergyVector,
std::vector< double > & TotalEnergyVector,
std::vector< dealii::Tensor< 1, 3, double > > & displacements,
std::vector< double > & velocity,
std::vector< double > & force,
const std::vector< double > & atomMass )
private

mdNVE Performs a Ccanonical Ensemble MD calculation. The inital temperature is set by runMD(). Temperature is NOT_CONTROLLED. Controls the timeloop.

Parameters
[in]atomMassStores the mass of each Charge.
[out]KineticEnergyVectorStores KineticEnergy at each TimeStep
[out]InternalEnergyVectorStores InternalEnergy at each TimeStep
[out]EntropicEnergyVectorStores PotentialEnergy at each TimeStep
[out]TotalEnergyVectorStores TotalEnergy at each TimeStep
[out]displacementsStores the displacment of each Charge, updated at each TimeStep
[out]velocityStores the velocity of each Charge, updated at each TimeStep
[out]forceStores the -ve of force on each charge, updated at each TimeStep

◆ mdNVTnosehoverchainsThermostat()

int dftfe::molecularDynamicsClass::mdNVTnosehoverchainsThermostat ( std::vector< double > & KineticEnergyVector,
std::vector< double > & InternalEnergyVector,
std::vector< double > & EntropicEnergyVector,
std::vector< double > & TotalEnergyVector,
std::vector< dealii::Tensor< 1, 3, double > > & displacements,
std::vector< double > & velocity,
std::vector< double > & force,
const std::vector< double > & atomMass )
private

mdNVTnosehoverchainsThermostat Performs a Canonical Ensemble MD calculation. The inital temperature is set by runMD(). Thermostat type is NOSE_HOVER_CHAINS. Controls the timeloop.

Parameters
[in]atomMassStores the mass of each Charge.
[out]KineticEnergyVectorStores KineticEnergy at each TimeStep
[out]InternalEnergyVectorStores InternalEnergy at each TimeStep
[out]EntropicEnergyVectorStores PotentialEnergy at each TimeStep
[out]TotalEnergyVectorStores TotalEnergy at each TimeStep
[out]displacementsStores the displacment of each Charge, updated at each TimeStep
[out]velocityStores the velocity of each Charge, updated at each TimeStep
[out]forceStores the -ve of force on each charge, updated at each TimeStep

◆ mdNVTrescaleThermostat()

int dftfe::molecularDynamicsClass::mdNVTrescaleThermostat ( std::vector< double > & KineticEnergyVector,
std::vector< double > & InternalEnergyVector,
std::vector< double > & EntropicEnergyVector,
std::vector< double > & TotalEnergyVector,
std::vector< dealii::Tensor< 1, 3, double > > & displacements,
std::vector< double > & velocity,
std::vector< double > & force,
const std::vector< double > & atomMass )
private

mdNVTrescaleThermostat Performs a Constant Kinetic Energy Ensemble MD calculation. The inital temperature is set by runMD(). Thermostat type is RESCALE. Controls the timeloop. At timestep which is multiple of Thermostat time constatn, the veloctites are rescaled *such that the temperature is set to inital temperature .

Parameters
[in]atomMassStores the mass of each Charge.
[out]KineticEnergyVectorStores KineticEnergy at each TimeStep
[out]InternalEnergyVectorStores InternalEnergy at each TimeStep
[out]EntropicEnergyVectorStores PotentialEnergy at each TimeStep
[out]TotalEnergyVectorStores TotalEnergy at each TimeStep
[out]displacementsStores the displacment of each Charge, updated at each TimeStep
[out]velocityStores the velocity of each Charge, updated at each TimeStep
[out]forceStores the -ve of force on each charge, updated at each TimeStep

◆ mdNVTsvrThermostat()

int dftfe::molecularDynamicsClass::mdNVTsvrThermostat ( std::vector< double > & KineticEnergyVector,
std::vector< double > & InternalEnergyVector,
std::vector< double > & EntropicEnergyVector,
std::vector< double > & TotalEnergyVector,
std::vector< dealii::Tensor< 1, 3, double > > & displacements,
std::vector< double > & velocity,
std::vector< double > & force,
const std::vector< double > & atomMass )
private

mdNVTsvrThermostat Performs a Canonical Ensemble MD calculation. The inital temperature is set by runMD(). Thermostat type is SVR. Controls the timeloop.

Parameters
[in]massAtomsStores the mass of each Charge. *
[out]KineticEnergyVectorStores KineticEnergy at each TimeStep
[out]InternalEnergyVectorStores InternalEnergy at each TimeStep
[out]EntropicEnergyVectorStores PotentialEnergy at each TimeStep
[out]TotalEnergyVectorStores TotalEnergy at each TimeStep
[out]displacementsStores the displacment of each Charge, updated at each TimeStep
[out]velocityStores the velocity of each Charge, updated at each TimeStep
[out]forceStores the -ve of force on each charge, updated at each TimeStep

◆ NoseHoverChains()

void dftfe::molecularDynamicsClass::NoseHoverChains ( std::vector< double > & v,
std::vector< double > & v_e,
std::vector< double > & e,
std::vector< double > Q,
double KE,
double Temperature )
private

NoseHoverChains controls the velocity at timestep t. The temperature is contolled by 2 thermostats. Thermostat 1 contols the velocity of all Charges. Thermostat 2 controls thermostat 1. Employs Extended Lagrangian approach.

Parameters
[in]Qstores mass of each Thermostat
[in]Temperaturetemperature of previous timestep
[out]vStores the velocity of each Charge, updated at each TimeStep
[out]v_eStores the thermostat velocity
[out]eStores the position of each thermosat

◆ NoseHoverExtendedLagrangian()

double dftfe::molecularDynamicsClass::NoseHoverExtendedLagrangian ( const std::vector< double > & thermovelocity,
const std::vector< double > & thermoposition,
const std::vector< double > & thermomass,
double PE,
double KE,
double T )
private

NoseHoverExtendedLagrangian: Computes the Nose-Hover Hamiltonian when using NHC thermostat.

Parameters
[in]thermovelocityVelocity of each, updated at each TimeStep
[in]thermopositionPosition of each thermostat , updated at each TimeStep
[in]thermomassStores the mass of each thermostat.
[in]PEFree energy of system at current Timestep
[in]KEKinetic ENergy of nuclei at current Timestep
[in]Temperaturetemperature at current Timestep
Returns
Hnose Nose Hamiltonian at each timestep

◆ RescaleVelocities()

double dftfe::molecularDynamicsClass::RescaleVelocities ( std::vector< double > & v,
const std::vector< double > & M,
double Temperature )
private

RescaleVelocities controls the velocity at timestep t. The scaling of velocities depends on ratio of T at that timestep and inital Temperature.

@param[in] M Stores the mass of each Charge.
@param[in] Temperature  temperature at current Timestep
@param[out] v Stores the velocity of each Charge, updated at each

Timestep

@param[return] KE Kinetic Energy at current timestp in eV

◆ runMD()

int dftfe::molecularDynamicsClass::runMD ( )

runMD: Assign atom mass to charge. Create vectors for displacement, velocity, force. Create KE vector, TE vector, PE vector. Initialise velocities from Boltsmann distribution. Set Center of Mass velocities to be 0. Call the resepective ensemble based on input file

◆ set()

void dftfe::molecularDynamicsClass::set ( )
private

set() initalises all the private datamembers of mdclass object from the parameters declared by user.

◆ svr()

double dftfe::molecularDynamicsClass::svr ( std::vector< double > & v,
double KE,
double KEref )
private
Parameters
[in]KErefTarget value of Kinetic Enegy from Temperature
[out]vStores the velocity of each Charge, updated at each TimeStep
[out]KErescaled Kinetic Energy from svr thermostat

◆ velocityVerlet()

double dftfe::molecularDynamicsClass::velocityVerlet ( std::vector< double > & v,
std::vector< dealii::Tensor< 1, 3, double > > & r,
const std::vector< double > & atomMass,
std::vector< double > & forceOnAtoms )
private

velocityVerlet

Parameters
[in]atomMassStores the mass of each Charge.
[return]KE Kinetic Energy at current timestp in eV
[out]forceonAtomsUpdated -ve forces on each charge.
[out]rUpdated displacement
[out]vUpdated velocity of each atom

◆ writeRestartFile()

void dftfe::molecularDynamicsClass::writeRestartFile ( const std::vector< dealii::Tensor< 1, 3, double > > & disp,
const std::vector< double > & velocity,
const std::vector< double > & force,
const std::vector< double > & KineticEnergyVector,
const std::vector< double > & InternalEnergyVector,
const std::vector< double > & TotalEnergyVector,
int time )
private

writeRestartFile: Writing files at each timestep to mdRestart

Parameters
[in]velocityVelocity updated from restart
[in]forceForce data at each timeStep
[in]PEFree energy of system at current Timestep
[in]KEKinetic ENergy of nuclei at current Timestep
[in]TEtemperature at current Timestep
[in]timeCurrent TimeStep

◆ writeRestartNHCfile()

void dftfe::molecularDynamicsClass::writeRestartNHCfile ( const std::vector< double > & v_e,
const std::vector< double > & e,
const std::vector< double > & Q,
const int time )
private

NoseHoverExtendedLagrangian Writes the NHC parameters at each timeStep.

Parameters
[in]thermovelocityVelocity of each, updated at each TimeStep
[in]thermopositionPosition of each thermostat , updated at each TimeStep
[in]thermomassStores the mass of each thermostat.
[in]timeCurrent TimeStep

◆ writeTotalDisplacementFile()

void dftfe::molecularDynamicsClass::writeTotalDisplacementFile ( const std::vector< dealii::Tensor< 1, 3, double > > & r,
int time )
private

writeTotalDisplacementFile: Updates Displacement.chk and appends TotalDisplacement.chk

Parameters
[in]rDisplacemnt of each atom, updated at each TimeStep
[in]timeeach TimeStep

Member Data Documentation

◆ AngTobohr

const double dftfe::molecularDynamicsClass::AngTobohr = 1.0 / bohrToAng

◆ bohrToAng

const double dftfe::molecularDynamicsClass::bohrToAng = 0.529177210903

◆ d_atomFractionalunwrapped

std::vector<std::vector<double> > dftfe::molecularDynamicsClass::d_atomFractionalunwrapped
private

◆ d_dftfeWrapper

std::unique_ptr<dftfeWrapper> dftfe::molecularDynamicsClass::d_dftfeWrapper
private

◆ d_dftPtr

dftBase* dftfe::molecularDynamicsClass::d_dftPtr
private

◆ d_domainLength

std::vector<double> dftfe::molecularDynamicsClass::d_domainLength
private

◆ d_extrapDensity_t0

distributedCPUVec<double> dftfe::molecularDynamicsClass::d_extrapDensity_t0
private

◆ d_extrapDensity_tmin1

distributedCPUVec<double> dftfe::molecularDynamicsClass::d_extrapDensity_tmin1
private

◆ d_extrapDensity_tmin2

distributedCPUVec<double> dftfe::molecularDynamicsClass::d_extrapDensity_tmin2
private

◆ d_extrapDensity_tp1

distributedCPUVec<double> dftfe::molecularDynamicsClass::d_extrapDensity_tp1
private

◆ d_MaxWallTime

double dftfe::molecularDynamicsClass::d_MaxWallTime
private

◆ d_MDstartWallTime

double dftfe::molecularDynamicsClass::d_MDstartWallTime
private

◆ d_mpiCommParent

const MPI_Comm dftfe::molecularDynamicsClass::d_mpiCommParent
private

◆ d_numberGlobalCharges

unsigned int dftfe::molecularDynamicsClass::d_numberGlobalCharges
private

◆ d_numberofSteps

unsigned int dftfe::molecularDynamicsClass::d_numberofSteps
private

◆ d_restartFilesPath

std::string dftfe::molecularDynamicsClass::d_restartFilesPath
private

◆ d_restartFlag

unsigned int dftfe::molecularDynamicsClass::d_restartFlag
private

◆ d_startingTemperature

double dftfe::molecularDynamicsClass::d_startingTemperature
private

◆ d_startingTimeStep

int dftfe::molecularDynamicsClass::d_startingTimeStep

◆ d_ThermostatTimeConstant

int dftfe::molecularDynamicsClass::d_ThermostatTimeConstant
private

◆ d_ThermostatType

std::string dftfe::molecularDynamicsClass::d_ThermostatType
private

◆ d_this_mpi_process

const unsigned int dftfe::molecularDynamicsClass::d_this_mpi_process
private

◆ d_TimeIndex

unsigned int dftfe::molecularDynamicsClass::d_TimeIndex
private

◆ d_TimeStep

double dftfe::molecularDynamicsClass::d_TimeStep
private

◆ d_verbosity

const int dftfe::molecularDynamicsClass::d_verbosity
private

◆ haPerBohrToeVPerAng

const double dftfe::molecularDynamicsClass::haPerBohrToeVPerAng = 27.211386245988 / 0.529177210903

◆ haToeV

const double dftfe::molecularDynamicsClass::haToeV = 27.211386245988

◆ kB

const double dftfe::molecularDynamicsClass::kB = 8.617333262e-05

◆ pcout

dealii::ConditionalOStream dftfe::molecularDynamicsClass::pcout
private

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