This tutorial provides a step-by-step guide for modeling electrolyte solutions and running classical molecular dynamics (MD) simulations. It is aimed at beginners and covers environment setup, required software installation, molecular modeling, simulation script preparation, job submission, and data analysis. Please follow each step closely and refer to documentation or community resources when needed.
- Environment Setup and Software Installation
- Detailed Modeling Workflow
- Classical Molecular Dynamics (MD) Simulations
- Machine Learning Molecular Dynamics (MLMD) Workflow
- Data Analysis and Processing
- FAQ and Useful Resources
-
Module Anaconda/Miniconda:
module load miniconda/3
- see detail from the official site and follow our group wiki.
-
Create and activate a Python environment:
conda create --name py311 python=3.11 conda activate py311
-
Install required packages:
conda install -c rdkit rdkit conda install -c conda-forge openbabel pip install ai2-kit # If network issues occur, change sources in ~/.condarc to Tsinghua mirrors, e.g.: # channels: # - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ # - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ # - conda-forge # - defaults # ssl_verify: true
- Download and install:
packmol
,gnuplot
,travis
- Tip: Always read each software's README before installing.
-
Copy auxiliary scripts to your working directory:
- convertLigParGen.py You can read this blog from Xu longkun which gives a detailed example on how to obtain the OPLS-AA force field parameters and the LAMMPS settings for MD simulations.
- fftool.py For the details about using fftool to generate LAMMPS input file and data file, you can check this fftool page of Prof. Agilio Padua, which contains very detailed information.
cp /path/convertLigParGen.py ./ cp /path/fftool.py ./
-
For better organization, create directories for scripts and define aliases in your shell:
alias convertLigParGen='python /path/to/convertLigParGen/convertLigParGen.py' alias fftool='python /path/to/fftool/fftool.py'
Remember to add these to
~/.bashrc
and runsource ~/.bashrc
to apply.
- Module load singularity
module load singularity/3.9.2
- check out the output file path
singularity exec /data/share/images/apps/ligpargen.sif pwd
-
Example for water molecule:
singularity exec /data/share/images/apps/ligpargen.sif ligpargen -s 'O' -n H2O -p H2O -c 0 -o 3 -cgen CM1A
-s
: SMILES input-n
: Output file prefix-p
: Output folder-c
: charge-o
: optimization-cgen
: charge type
-
SMILES resources:
- OPLS-AA for LAMMPS & SMILES explanation see detail from the official doc.
- Draw structure and convert to SMILES (Marvin JS)
try to use this tool from the official site.
Note: Marvin JS requires JavaScript enabled in your browser.
-
Check script parameters:
convertLigParGen -h
-
Generate
.xyz
and.ff
files:convertLigParGen -g H2O.gmx.itp -l H2O.lammps.lmp -o H2O.ff
-
Check fftool help:
fftool -h
-
Fill box:
fftool 128 H2O.xyz -b 15
-
This generates
pack.inp
forpackmol
:packmol < pack.inp
-
-
Generate LAMMPS input files:
fftool 128 H2O.xyz -b 15 -l
- Produces
input.lammps
anddata.lmp
- Produces
-
Copy job script template and ensure the
-in
argument matches your input script:cp /data/share/base/scripts/lammps.slurm ./ sbatch lammps.slurm
-
available script
#!/bin/bash #SBATCH -J lammps #SBATCH -p c51-medium #SBATCH -N 1 #SBATCH --ntasks-per-node=24 #SBATCH --exclusive # add modulefiles module load lammps/23Jun2022_update1_cpu module load intel/17.5.239 mpi/intel/2017.5.239 gcc/7.4.0 module load netcdf/4.9.0_intel17 module load plumed/2.8.0 mpiexec.hydra -env I_MPI_EXTRA_FILESYSTEM on -env I_MPI_EXTRA_FILESYSTEM_LIST gpfs \ lmp_mpi -in input.lammps
-
Useful commands:
squeue -u username # View jobs scancel JOBID # Cancel job tail -f log.lammps # Monitor log output
- Refer to the LAMMPS Manual for parameter settings and input file formats.
- LAMMPS (Large-scale Atomic/Molecular Massively Parallel Simulator) is an open-source, highly extensible classical MD engine.
- Learn about NVT/NPT ensembles and other relevant commands.
- If you encounter errors, check common LAMMPS errors and troubleshooting.
- Upload and extract the
mlmd
package to your root directory. - Key scripts:
run.sh
: Automates several data extraction and conversion stepsdump2xyz.py
: Converts.lammpstrj
to.xyz
dump2avedata.py
: Selects the best energy-converged frame and generates a LAMMPS inputsub.deepmd
: Job submission script
-
Edit
run.sh
to match your file names -
Copy
mlmd
to your classical MD folder -
Execute:
./run.sh ./dump2xyz.py
-
Obtain
input_npt.lammps
,conf.lmp
,simbox.xyz
, etc. -
Submit the NPT job:
sbatch sub.deepmd
-
After NPT, process the data:
./dump2avedata.py
-
Create a new
nvt
folder inmlmd
, copy the average density output file (preferably rename asnvt.lmp
), and ensure all necessary files (sub.deepmd
,nvt.lmp
,input_nvt.lammps
, force field files) are present and consistently named. -
Submit the NVT job:
sbatch sub.deepmd
-
You can terminate the simulation early if energies are converged (check with
plot
tool). Use VMD to visualize trajectory files.- About VMD:
VMD (Visual Molecular Dynamics) is a free, cross-platform program for displaying, animating, and analyzing large biomolecular systems using 3D graphics and scripting. It supports MacOS, Unix, and Windows and is commonly used for trajectory visualization and analysis.
- About VMD:
-
After installing TravisCI, load the gcc module:
module load gcc ln -s name.lammpstrj name.lmp travis -p -name.lmp
-
Choose central atom and calculation type per your research needs (e.g., RDF). Use
plot
to visualize and check the quality of your data.
-
Encountering Errors:
Use Google, Computational Chemistry forums, and official documentation for troubleshooting.
For LAMMPS-specific errors, consult the LAMMPS Error Guide. -
More Resources:
- Make good use of bash aliases and scripts to accelerate batch operations.
- Always maintain organized file/script naming and archiving habits for reproducibility and collaboration.
- If in doubt at any step, consult the relevant README or Wiki, or ask more experienced colleagues.
This tutorial is subject to updates. Contributions and suggestions are welcome!