Theory

VASP and ASE

To use the full functionality of the Atomistic Simulation Environment together with VASP one needs to do certain modifications compared to the standard guidelines. This article will help setup ASE to run VASP with parallel computing

The guide here is tested and working on Vera and Hebbe and using the following modules:

  1. Python/3.7.2
  2. iccifort/2019.1.144-GCC-8.2.0-2.31.1
  3. impi/2018.4.274
  4. ASE/3.18.0-Python-3.7.2
  5. VASP/5.4.4.16052018

The usual instructions are to create a folder like ~/vasp/ and make a python script that runs ASE: run_vasp.py. This contains the following lines:

	import os
	exitcode = os.system('vasp')

However to run parallel calculations one needs to call mpiexec/mpirun like this:

	import os 
	exitcode = os.system('mpirun -n 16 vasp')

Then VASP can easily be used in ASE. This means that you can write a submit script like this:

	#!/usr/bin/env bash 
	#SBATCH  LINES …....................

	export NCORES=$(($SLURM_JOB_NUM_NODES*16)) 

        cp inputfiles $TMPDIR
        cd $TMPDIR

        module purge # unloads all modules, so to have a fresh start 
                               # and no competing modules
        module load iccifort/2019.1.144-GCC-8.2.0-2.31.1  
        module load impi/2018.4.274
        module load Python/3.7.2
        module load ASE/3.18.0-Python-3.7.2
        module load VASP/5.4.4.16052018

	time python test_pd111.py $SLURM_SUBMIT_DIR > @SLURM_SUBMIT_DIR/result.txt

        exit_code=$?

        echo ""
        echo "Executable 'vasp' finished with exit code $exit_code"

       # Copy the files back after run:

       echo " "
       echo "Remove unneeded files"
       rm -vf $TMPDIR/{Unneeded file, comma-sperated}

       echo " "
       echo "copy needed files back"
       mv $TMPDIR/* $SLURM_SUBMIT_DIR

In edition to this set-up one also need to add the VASP Pseudopotential files and its path. Otherwise ASE will not be able to create the POTCAR file and fail to run the simulation. Thus beside the run_vasp.py, also the VASP_PP_PATH needs adding in the .bashrc:

        export VASP_SCRIPT="$HOME/VASP/run_vasp.py"
        export VASP_PP_PATH="$HOME/VASP/"

the folder name expected by ASE for the pseudo potentials is: potpaw_PBE and a zip-file of the ones in version 5.4 is attached: potpaw_PBE.54.zip

In order to use any vdW-functional, also the place where the vdw_kernel.bindat file (copy, unpack: vdw.zip ) is stored has to be mentioned to ASE:

        export ASE_VASP_VDW="$HOME/VASP/"

The BEEF-vdW functional is only available in the VASP/5.4.4.10112017-vtst module and not in the default one: VASP/5.4.4.16052018.

VASP Input files only can be created using the ASE class-definition without the need to start a calculation explicitly:

    from ase.calculators.vasp import Vasp
    import ase.calculators.vasp as vasp_calculator
    from ase.build import fcc111

    # creates a Pt(111) surface from the ase.build model with standard lattice constant 
    atoms=fcc111('Pt', size=(2,2,4)) 
    calc = vasp_calculator.Vasp()      # Define whatever parameters you need 
    calc.initialize(atoms)         #Initialize the VASP calculator class with the atom-object
    calc.write_input(atoms)    #Call the write_input definition of the VASP calculator class

Where the ASE python script “test_pd111.py” test_pd111.txt contains a relaxation of a Pd(111) surface with one free layer as follows:

	from ase.calculators.vasp import Vasp 
	from ase.optimize import QuasiNewton 
	from ase.constraints import FixAtoms 
	from ase.build import fcc111

	Setup Pd 
	a0 = 3.996 
	k0 = 6 
	size = [1,1,4] 

	syst = fcc111(symbol='Pd',size=size,a=a0,vacuum=8.0) 

	c = FixAtoms(indices=[atom.index for atom in syst if atom.tag<= 3]) 
	syst.set_constraint(c) 

	calc = Vasp(	prec='Normal',xc='PBE', 
			encut = 450.0, #PW cut-off 
			ispin=1, #No spin-polarization 
			ibrion=-1, #No VASP relaxation.
			nsw = 0, #Max. no of relaxation steps. 
			kpts = [k0,k0,1], 
			sigma=0.05, 
			potim=0.5, 
			isif=0,
			npar=4 #Band parallezation use kpar for k-points
			) 

	syst.set_calculator(calc) #Connect atoms and calculator

	#Now run the relaxation with QuasiNewton
	dyn = QuasiNewton(syst,trajectory='pd-relax.traj') 
	dyn.run(fmax=0.05) 

	print ("Found energy after relaxing", syst.get_potential_energy() )

To summarize, you set up ASE to run VASP in parallel by specifying that ASE should call mpirun vasp. Then you submit your ASE script as a normal python script.

General

Experiment

Theory

PmWiki

pmwiki.org

edit SideBar

Blix theme adapted by David Gilbert, powered by PmWiki