A python-based package to generate VASP input files.
- parse template input files
INCAR,KPOINTS,POSCAR, andPOTCAR - loop over
INCARparameters - loop over lattice parameter in
POSCAR - generate
slurmscripts orbashscripts to run the calculations
This package requires hydra for building the configuration and pymatgen to manage the vasp input files.
To install hydra use pip install hydra-core.
Installing pymatgen requires two steps:
- Install the
pymatgenpackage withpip install pymatgen - Set up the pseudopotentials: after the installation run
pmg config -p <EXTRACTED_VASP_POTCAR> <MY_PSP>where<EXTRACTED_VASP_POTCAR>is the path to the extracted VASP pseudopotential files as obtained from VASP, and<MY_PSP>is the desired path where you would like to store the reformatted,pymatgen-compatible pseudopotential files. See the pymatgen website for more.
Set up a template folder with the vasp input files:
template/
├── INCAR
├── KPOINTS
├── POSCAR
└── POTCAR
then, from the command line, run:
python3 <path_to_source>/vasp-input.py \
source.dir=template \
dir.prefix=Si \
dir.subdir=PBE \
dir.suffix=cell-search \
loop='[{file:poscar,parameter:a,interpolation:interval,val:[5.5,5.75,0.1]}]' \ #python syntax for dictionary
dir.overwrite=True \
executor=daint-gh200You'll obtain the following tree:
Si
└── PBE
└── cell-search
├── a_5.50
│ ├── INCAR
│ ├── KPOINTS
│ ├── POSCAR
│ └── POTCAR
├── a_5.60
│ ├── INCAR
│ ├── KPOINTS
│ ├── POSCAR
│ └── POTCAR
├── a_5.70
│ ├── INCAR
│ ├── KPOINTS
│ ├── POSCAR
│ └── POTCAR
├── run.a_5.50
├── run.a_5.60
└── run.a_5.70
Alternatively, you can create a configuration file config.yaml:
source:
dir: template
poscar: null
kpoints: null
incar: null
potcar: null
dir:
prefix: Si
suffix: cell-search
subdir: PBE
overwrite: true
loop:
- file: poscar
parameter: a
interpolation: interval
val:
- 5.5
- 5.75
- 0.1
calc:
functional: PBE
pseudo:
variant: null
executor: daint-gh200
executors:
daint-gh200:
slurm:
cmd: srun --cpu-bind=socket ~/mps-wrapper.sh vasp_std
setup:
job-name: null
account: lp07
constraint: gpu
hint:
- nomultithread
- exclusive
nodes: 1
ntasks-per-node: 32
ntasks-per-core: 1
cpus-per-task: 1
partition: normal
time: '12:00:00'
output: log
error: err
uenv: vasp/v6.4.3:v1
env: |
export PATH=/user-environment/env/vasp/bin/:$PATH
export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
export MPICH_MALLOC_FALLBACK=1
export MPICH_GPU_SUPPORT_ENABLED=1
then run:
python3 <path_to_source>/vasp-input.py --config-path=$(pwd) --cofig-name=config.yamlThe program is configured using a yaml file. You can print a template of the basic config file with:
python3 vasp-input.py --cfg=jobThe output is going to look like:
executors:
daint-gh200:
# ... see later
cseasrv:
# ... see later
source: # path to the template files
dir: null
poscar: null
kpoints: null
incar: null
potcar: null
dir: # output directory settings
prefix: null
suffix: null
subdir: null
overwrite: false
loop: # loop settings
- file: null
parameter: null
interpolation: null
val: null
calc: # calculation settings
functional: PBE
pseudo:
variant: nullThe configuration file is in yaml format.
The settings are divided into sections:
executorscontains the settings for the different clusters where the calculations are going to be run.sourcecontains the path to the template files.dircontains the settings for the output directories.loopcontains the settings for the loops over the lattice parameter inPOSCARand/or the parameters inINCAR.calccontains the settings for the calculation.
The program runs on a set of template files. You can provide either the path of a directory containing the template files or the path of a single file. Single files have priority over the full directory.
for example, the following configuration:
source:
dir: /home/<user>/VASP/Si-origin
poscar: /home/<user>/VASP/structures/Si/POSCAR
kpoints: null
incar: null
potcar: nullwill cause the program to scan INCAR, KPOINTS, POSCAR, and POTCAR files in /home/<user>/VASP/Si-origin and use the POSCAR file in /home/<user>/VASP/structures/Si/POSCAR.
The program will create a directory for each calculation.
The directory name is composed of the prefix, the suffix, and the subdir settings.
The prefix and suffix are strings that are added to the directory name.
The subdir is a string that is added to the directory name and is used to create a subdirectory.
The overwrite setting is a boolean that specifies if the program should overwrite the directory if it already exists.
For example, the following configuration:
dir:
prefix: Si
subdir: PBE
suffix: cell-search
overwrite: falsewill produce the following tree:
Si
└── PBE
└── cell_search
├── ...
Only prefix is mandatory.
If no subdir or suffix are provided, the calculation directories will be created in the prefix directory.
The program re-generates a POTCAR file for each calculation, using pymatgen.
calc:
functional: PBE
pseudo:
variant: nullWith variant can choose between the different variants of the pseudopotentials provided by vasp, e.g. sv_GW.
Set to null to use the variant provided in the template POTCAR file parsed at the beginning of the program.
The program can loop over the lattice parameter in the POSCAR file and/or the parameters in the INCAR file.
At the moment, two kinds of loops are supported:
- loop over lattice parameter 'a' in
POSCARfile - loop over any parameter in
INCARfile
To set up a loop for the lattice constant:
loop:
- file: poscar
parameter: a
interpolation: interval
val: [5.5, 5.7, 0.05]To set up a loop for the parameters in INCAR:
loop:
- file: incar
parameter: ENCUT
interpolation: list
val: [50, 100, 200, 400]Two kinds of interpolation are supported:
intervalfor a linear interpolation between the values inval; the first value is the starting point, the second value is the end point, and the third value is the step (seenumpy.arange)listfor a list of values inval
Multiple loops can be set combined in the loop section. The program will loop over all the combinations of the parameters and name the folders accordingly.
loop:
- file: incar
parameter: ENCUT
interpolation: list
val: [50, 100, 200, 400]
- file: poscar
parameter: a
interpolation: interval
val: [5.5, 5.7, 0.05]The program can generate slurm scripts or bash scripts to run the calculations.
The executors section contains the settings for the different clusters where the calculations are going to be run.
There are two types of executors:
slurmfor theslurmscheduler. The program will generate aslurmscript for each calculation.localfor the local machine. The program will generate abashscript for each calculation.
For the slurm executor, the current template is:
executors:
daint-gh200:
slurm:
cmd: srun --cpu-bind=socket ~/mps-wrapper.sh vasp_std
setup:
job-name: null
account: lp07
constraint: gpu
hint: [nomultithread, exclusive]
nodes: 1
ntasks-per-node: 32
ntasks-per-core: 1
cpus-per-task: 1
partition: normal
time: '12:00:00'
output: log
error: err
uenv: 'vasp/v6.4.3:v1'
env: |
export PATH=/user-environment/env/vasp/bin/:$PATH
export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
export MPICH_MALLOC_FALLBACK=1
export MPICH_GPU_SUPPORT_ENABLED=1Further parameters can be added to the slurm.setup section.
The resulting slurm script is:
#!/bin/bash -l
#SBATCH --job-name=a_5.30
#SBATCH --account=lp07
#SBATCH --constraint=gpu
#SBATCH --hint=nomultithread
#SBATCH --hint=exclusive
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=32
#SBATCH --ntasks-per-core=1
#SBATCH --cpus-per-task=1
#SBATCH --partition=normal
#SBATCH --time=12:00:00
#SBATCH --output=a_5.30/log
#SBATCH --error=a_5.30/err
#SBATCH --uenv=vasp/v6.4.3:v1
export PATH=/user-environment/env/vasp/bin/:$PATH
export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
export MPICH_MALLOC_FALLBACK=1
export MPICH_GPU_SUPPORT_ENABLED=1
pushd /capstor/scratch/cscs/pgiorgio/VASP/Si/cell-search/a_5.30 || exit 1
srun --cpu-bind=socket ~/mps-wrapper.sh vasp_std
popd
echo $SLURM_JOB_ID > run.a_5.30.successFor running on the local machine, the current template is:
executors:
cseasrv:
local:
cmd: vasp_std
nproc: 128
mpiexec: mpirun
env: |
export SPACK_ROOT=/home/palermo/spack;
export SPACK_COLOR=always;
source \${SPACK_ROOT}/share/spack/setup-env.sh
spack load /cptwhgb #vasp@6.4.3~cuda+fftlib+hdf5+openmp+shmemwhich corresponds to this script:
#!/bin/bash -l
export SPACK_ROOT=/home/palermo/spack;
export SPACK_COLOR=always;
source ${SPACK_ROOT}/share/spack/setup-env.sh
spack load /cptwhgb #vasp@6.4.3~cuda+fftlib+hdf5+openmp+shmem
pushd /home/palermo/VASP/Si/cell_search/a_5.41 || exit 1
mpirun -np 128 vasp_std
popdYou can add a new executor to the executors dictionary. Use the templates provided for either the slurm or local execution.