Installing and running Gromacs on a HPC.
Today we are going to install and run Gromacs on a high performance computer (HPC). The installation can be done by writing first the following in the command shell (this should be run using the slurm scheduler):
spack install gromacs ^openmpi schedulers=slurm pmi=true
After installation is finished. We can then run a mixture of two molecules MOL1 and MOL2, with 100 molecules of each, using the following bash code and the appropriate files in order to calculate density of this mixture:
#!/bin/bash
#SBATCH -J test # Job name
#SBATCH -n 1 # Number of total cores
#SBATCH -N 1 # Number of nodes
#SBATCH -A name
#SBATCH -p cpu
#SBATCH -t 2-00:00:00
#SBATCH --mem-per-cpu=6000 # Memory pool for all cores in MB
#SBATCH -e test_%j.err
#SBATCH -o test_%j.out # File to which STDOUT will be written %j is the job #
echo "Job started on `hostname` at `date`"
module load openmpi
spack load gromacs
BOXSIZE=10
NMOLECULE1=100
NMOLECULE2=100
NAME1=MOL1
NAME2=MOL2
srun --mpi=pmix gmx_mpi insert-molecules -ci ${NAME1}.gro -o ${NAME1}_box.gro -box $BOXSIZE $BOXSIZE $BOXSIZE -nmol $NMOLECULE1 -rot xyz
srun --mpi=pmix gmx_mpi insert-molecules -f ${NAME1}_box.gro -ci ${NAME2}.gro -o mix_box.gro -nmol $NMOLECULE2 -rot xyz
srun --mpi=pmix gmx_mpi grompp -f minim.mdp -c mix_box.gro -p topol.top -o em.tpr
srun --mpi=pmix gmx_mpi mdrun -s em.tpr -mp topol.top -c em.gro
echo " "
echo "Minimization Ended at `date`"
srun --mpi=pmix gmx_mpi grompp -f nvt.mdp -c em.gro -p topol.top -o nvt.tpr
srun --mpi=pmix gmx_mpi mdrun -s nvt.tpr -mp topol.top -cpo nvt.cpt -c nvt.gro
echo " "
echo "NVT Ended at `date`"
srun --mpi=pmix gmx_mpi grompp -f npt.mdp -c nvt.gro -t nvt.cpt -p topol.top -o npt.tpr
srun --mpi=pmix gmx_mpi mdrun -s npt.tpr -mp topol.top -cpo npt.cpt -c npt.gro -e npt.edr
echo " "
echo "NPT Ended at `date`"
srun --mpi=pmix gmx_mpi grompp -f npt.mdp -c npt.gro -t npt.cpt -p topol.top -o nptrun.tpr
srun --mpi=pmix gmx_mpi mdrun -s nptrun.tpr -mp topol.top -cpo nptrun.cpt -c nptrun.gro -e nptrun.edr -o nptrun.trr
echo " "
echo "NPT Run Ended at `date`"
echo "22 0" | srun --mpi=pmix --partition=cpu -N 1 gmx_mpi energy -f nptrun.edr -s nptrun.tpr -o density.xvg
echo "0" | srun --mpi=pmix --partition=cpu -N 1 gmx_mpi dipoles -f traj.trr -s nptrun.tpr -eps epsilon.xvg
echo " "
echo "Job Ended at `date`"
This will output the values of the density and of the permittivity of the mixture in the .out file.