Electrolyte System Modeling and Classical MD Workflow¶
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.
Table of Contents¶
- Environment Setup and Software Installation
- Detailed Modeling Workflow
- Classical Molecular Dynamics (MD) Simulations
- Data Analysis and Processing
- FAQ and Useful Resources
Environment Setup and Software Installation¶
1. Set Up Conda Environment¶
- 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
2. Other Essential Software¶
- Download and install:
packmol
,gnuplot
,travis
- Tip: Always read each software's README before installing.
Detailed Modeling Workflow¶
1. Prepare Script Tools¶
-
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.
2. Molecular Modeling and Job Submission¶
2.1 Module load singularity for using LigParGen¶
- Module load singularity
module load singularity/3.9.2
- check out the output file path
singularity exec /data/share/images/apps/ligpargen.sif pwd
2.2 Generate Molecular Force Field¶
-
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.
2.2 Generate Required Files¶
-
Check script parameters:
convertLigParGen -h
-
Generate
.xyz
and.ff
files:convertLigParGen -g H2O.gmx.itp -l H2O.lammps.lmp -o H2O.ff
2.3 Build a Box Filled with Water Molecules¶
-
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
2.4 Submit Simulation Job¶
-
Copy job script template and ensure the
-in
argument matches your input script:- available scriptcp /data/share/base/scripts/lammps.slurm ./ sbatch lammps.slurm
- Useful commands:#!/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
squeue -u username # View jobs scancel JOBID # Cancel job tail -f log.lammps # Monitor log output
Classical Molecular Dynamics (MD) Simulations¶
- 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.
-
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.
Data Analysis and Processing¶
1. Install and Use Travis¶
-
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.
FAQ and Useful Resources¶
-
Encountering Errors:
Use Google, Computational Chemistry forums, and official documentation for troubleshooting.
For LAMMPS-specific errors, consult the LAMMPS Error Guide. -
More Resources:
Notes¶
- 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!