Molecular Dynamics
Overview
SPARC run MD simulation leveraging the ASE MD engine framework. It supports both ab initio MD (AIMD) and machine-learning MD (ML-MD) using DeepPotential models. This module integrates thermostats, logging, checkpointing, and trajectory handling into a unified workflow.
It currently supports the NVT ensemble with Langevin thermostat or the Nosé-Hoover chain thermostat. Parameters such as damping time (for Nose) or friction coefficient (Langevin) needs to defined.
Each ML/MD iteration is saved in the corresponding iter_0000xx/02.dpmd directory, which includes the simulation log (log_file), the trajectory of atomic positions (extxyz or traj). It also write a checkpoint file to restart long simulations.
Simulation Outputs
>>> cat Iter1_dpmd.log
Time[ps] Etot[eV] Epot[eV] Ekin[eV] T[K]
0.0000 -112.0807 -112.8950 0.8143 300.0
0.0700 -111.6322 -112.7149 1.0828 398.9
0.1400 -112.4215 -113.3518 0.9303 342.7
0.2100 -112.9996 -113.6775 0.6779 249.8
0.2800 -112.6910 -113.7220 1.0310 379.8
0.3500 -112.8007 -113.2903 0.4896 180.4
Usage Examples
Nose-Hoover NVT Simulation:
- sparc.src.ase_md.NoseNVT(atoms, timestep=1, temperature=300, tdamp=10, restart=False)[source]
Set up a Nose-Hoover chain NVT thermostat for MD simulation.
- Parameters:
atoms (ase.Atoms) – The ASE Atoms object representing the system.
timestep (float, optional) – The simulation time step in femtoseconds (default is 1 fs).
temperature (float, optional) – The target temperature in Kelvin (default is 300 K).
tdamp (float, optional) – The damping time for the thermostat in femtoseconds (default is 10 fs).
restart (bool, optional) – If True, the simulation will be restarted from a checkpoint.
- Returns:
dynamics – The initialized dynamics object using the Nose-Hoover chain thermostat.
- Return type:
NoseHooverChainNVT
from ase import Atoms
from sparc.src.ase_md import NoseNVT
atoms = Atoms("H2O")
dyn = NoseNVT(atoms, temperature=300)
dyn.run(1000)
Langevin NVT Simulation:
- sparc.src.ase_md.LangevinNVT(atoms, timestep=1, temperature=300, friction=0.01, restart=False)[source]
Set up a Langevin thermostat for NVT MD simulation.
- Parameters:
atoms (ase.Atoms) – The ASE Atoms object representing the system.
timestep (float, optional) – The simulation time step in femtoseconds (default is 1 fs).
temperature (float, optional) – The target temperature in Kelvin (default is 300 K).
friction (float, optional) – The friction coefficient for the Langevin thermostat (default is 0.01 fs^-1).
restart (bool, optional) – If True, the simulation will be restarted from a checkpoint.
- Returns:
dynamics – The initialized dynamics object using the Langevin thermostat.
- Return type:
Langevin
from sparc.src.ase_md import LangevinNVT
dyn = LangevinNVT(atoms, temperature=300, friction=0.01)
dyn.run(1000)
Ab-initio Molecular Dynamics:
- sparc.src.ase_md.ExecuteAbInitioDynamics(system, dyn, steps, pace, log_filename, trajfile, dir_name, name)[source]
Run an ab initio MD simulation.
- Parameters:
system (ase.Atoms) – The ASE Atoms object representing the system.
dyn (dynamics object) – The initialized MD dynamics object.
steps (int) – The number of MD steps to run.
pace (int) – The interval (in steps) at which to log data and save checkpoints.
log_filename (str) – The filename for the MD log file.
trajfile (str) – The filename for the trajectory file.
dir_name (str) – The directory where log and trajectory files will be saved.
name (str) – A label for the simulation (e.g., the thermostat type).
- Return type:
None
from sparc.src.ase_md import ExecuteAbInitioDynamics
ExecuteAbInitioDynamics(system=atoms, dyn=dyn, steps=500, pace=10,
log_filename="aimd.log", trajfile="aimd.traj",
dir_name="aimd_results", name="DFT_AIMD")
References
For more information on ASE, visit: https://wiki.fysik.dtu.dk/ase/