One of the reasons we use is to make it easy to run a lot of calculations conveniently. automatically submits jobs to the queue for us, and provides some job control features to make it wait until they are finished.

Sometimes things go wrong though, e.g. you realize you used the wrong parameter and suddenly you have a lot of jobs in the queue to stop. Not to worry, can help you out. Each calculator stores a jobid on it, and provides some support to interact with the queue system (assuming you use Torque or something compatible with it)!

Here is an example where we setup and run 10 calculations. The first time we run this, 10 jobs get submitted.

from vasp import Vasp
from ase import Atom, Atoms
import matplotlib.pyplot as plt
import numpy as np

bond_lengths = np.linspace(1.05, 1.3, 10)

calcs = [Vasp('molecules/co-n{0:02d}'.format(i),  # output dir
                atoms=Atoms([Atom('C', [0, 0, 0]),
                             Atom('O', [d, 0, 0])],
                            cell=(6, 6, 6)))
         for i, d in enumerate(bond_lengths)]

energies = [calc.potential_energy for calc in calcs]

# Here are the jobids
print([(c.jobid(), c.in_queue()) for c in calcs])

# Stop here until all calculations are done.
Vasp.stop_if(None in energies)

/home-research/jkitchin/dft-book/blog/source/org/molecules/co-n00 submitted:
/home-research/jkitchin/dft-book/blog/source/org/molecules/co-n01 submitted:
/home-research/jkitchin/dft-book/blog/source/org/molecules/co-n02 submitted:
/home-research/jkitchin/dft-book/blog/source/org/molecules/co-n03 submitted:
/home-research/jkitchin/dft-book/blog/source/org/molecules/co-n04 submitted:
/home-research/jkitchin/dft-book/blog/source/org/molecules/co-n05 submitted:
/home-research/jkitchin/dft-book/blog/source/org/molecules/co-n06 submitted:
/home-research/jkitchin/dft-book/blog/source/org/molecules/co-n07 submitted:
/home-research/jkitchin/dft-book/blog/source/org/molecules/co-n08 submitted:
/home-research/jkitchin/dft-book/blog/source/org/molecules/co-n09 submitted:
[(u'', True), (u'', True), (u'', True), (u'', True), (u'', True), (u'', True), (u'', True), (u'', True), (u'', True), (u'', True)]

Say we just realize we wanted to delete these jobs, and change a parameter. We just get the calculators, and call qdel on each one like this:

from vasp import Vasp
import numpy as np

bond_lengths = np.linspace(1.05, 1.3, 10)
calcs = [Vasp('molecules/co-n{0:02d}'.format(i))
         for i, d in enumerate(bond_lengths)]

print([calc.qdel() for calc in calcs])
[(0, ''), (0, ''), (0, ''), (0, ''), (0, ''), (0, ''), (0, ''), (0, ''), (0, ''), (0, '')]

All those 0's just means the job deletion succeeded. Now, we just have to adjust the original parameter set, and rerun the original script! That will resubmit the new jobs for us.

Here is the output from one of those calculations. Note the path is an org-link, so you can just click on it to open the directory if you run this in Emacs.

from vasp import Vasp
*************** VASP CALCULATION SUMMARY ***************
Vasp calculation directory:

Unit cell:
       x       y       z             |v|
  v0   6.000   0.000   0.000       6.000 Ang
  v1   0.000   6.000   0.000       6.000 Ang
  v2   0.000   0.000   6.000       6.000 Ang
  a,b,c,alpha,beta,gamma (deg): 6.000 6.000 6.000 90.0 90.0 90.0
  Total volume:                  216.000 Ang^3
  Stress:    xx     yy     zz     yz     xz     xy
         -0.071  0.001  0.001 -0.000 -0.000 -0.000 GPa

  ID  tag     sym    x        y        z    rmsF (eV/A)constraints (F=Frozen)
  0   0       C      0.000    0.000    0.000   14.97      T T T
  1   0       O      1.050    0.000    0.000   14.97      T T T
  Potential energy: -14.1779 eV

INPUT Parameters:
  lcharg    : False
  pp        : PBE
  nbands    : 6
  xc        : pbe
  ismear    : 1
  lwave     : False
  sigma     : 0.2
  kpts      : [1, 1, 1]
  encut     : 520

Pseudopotentials used:
  C: potpaw_PBE/C/POTCAR (git-hash: ee4d8576584f8e9f32e90853a0cbf9d4a9297330)
  O: potpaw_PBE/O/POTCAR (git-hash: 592f34096943a6f30db8749d13efca516d75ec55)

Here is a summary of the job control functions and queue commands built in to

1 job control functions


Runs all stored calculators on the Vasp class.

from vasp import Vasp
Help on method run in module vasp.vasp_core:

run(cls, wait=False) method of __builtin__.type instance
    Convenience function to run calculators.

    The default behavior is to exit after doing this. If wait is
    True, iy will cause it to wait with the default args to

    If wait is a dictionary, it will be passed as kwargs to


Runs the instance calculator.

1.3 Vasp.all()

Returns whether all calculators are ready, e.g. with results.

from vasp import Vasp
Help on method all in module vasp.vasp_core:

all(cls) method of __builtin__.type instance
    Returns if all calculators in the class are ready.

1.4 Vasp.stop_if(condition)

Aborts the script if condition is not truthy

from vasp import Vasp
Help on method stop_if in module vasp.vasp_core:

stop_if(cls, condition) method of __builtin__.type instance
    Stops the program if condition is truthy.

1.5 Vasp.abort() and calc.abort()

Aborts the script.

from vasp import Vasp
Help on method abort in module vasp.vasp_core:

abort(cls) method of __builtin__.type instance
    Abort and exit the program the calculator is running in.

1.6 Vasp.wait() and calc.wait()

Allows a real time-elapsed wait for jobs to finish. This blocks the script.

from vasp import Vasp
Help on method wait in module vasp.vasp_core:

wait(cls, poll_interval=5, timeout=None, abort=False) method of __builtin__.type instance
    Control function to wait until all calculators are ready.

    if abort is truthy, stop the program.

    Otherwise check the calculators every poll_interval seconds,
    up to timeout seconds later. If timeout is None, poll forever.

2 queue commands

2.1 calc.qstat(*options)

Gets information about the job.

from vasp import Vasp
import numpy as np

calc = Vasp('molecules/co-n09')

Job id                    Name             User            Time Use S Queue
------------------------- ---------------- --------------- -------- - -----
1397268.gilgamesh         .../co-n09       jkitchin               0 R short

2.2 calc.qalter(*options)

Allows you to alter the queue parameters for a job.

from vasp import Vasp
import numpy as np

calc = Vasp('molecules/co-n09')

calc.qalter('-l', 'walltime=20:00:00')

2.3 calc.qdel(*options)

Allows you to delete the job

2.4 calc.xterm()

This will pop up an xterm window in the directory of the calculation. There you can run commands and see what is going on.

from vasp import Vasp
import numpy as np

calc = Vasp('molecules/co-n00')


2.5 calc.qoutout()

Returns contents of the queue output file if it exists. May be useful to debug.

from vasp import Vasp
import numpy as np

calc = Vasp('molecules/co-n00')

xmodmap:  unable to open display ''
 vasp.5.3.5 31Mar14 (build Aug 04 2015 12:48:45) complex

 POSCAR found :  2 types and       2 ions
 LDA part: xc-table for Pade appr. of Perdew
 POSCAR found :  2 types and       2 ions
 POSCAR, INCAR and KPOINTS ok, starting setup
 WARNING: small aliasing (wrap around) errors must be expected
 FFT: planning ...
 WAVECAR not read
 WARNING: random wavefunctions but no delay for mixing, default for NELMDL
 entering main loop
       N       E                     dE             d eps       ncg     rms          rms(c)
DAV:   1     0.693510492725E+02    0.69351E+02   -0.29305E+03    12   0.855E+02
DAV:   2    -0.556930203939E+01   -0.74920E+02   -0.74931E+02    18   0.248E+02
DAV:   3    -0.151153850754E+02   -0.95461E+01   -0.95461E+01    12   0.964E+01
DAV:   4    -0.153607093341E+02   -0.24532E+00   -0.24532E+00    12   0.138E+01
DAV:   5    -0.153763439194E+02   -0.15635E-01   -0.15635E-01    24   0.343E+00    0.816E+00
DAV:   6    -0.144168400550E+02    0.95950E+00   -0.26887E+00    12   0.196E+01    0.429E+00
DAV:   7    -0.142207761391E+02    0.19606E+00   -0.48211E-01    18   0.795E+00    0.186E+00
DAV:   8    -0.142021024270E+02    0.18674E-01   -0.81621E-02    18   0.376E+00    0.582E-01
DAV:   9    -0.142016090043E+02    0.49342E-03   -0.11924E-02    12   0.136E+00    0.870E-02
DAV:  10    -0.142024449557E+02   -0.83595E-03   -0.55763E-04    12   0.268E-01    0.420E-02
DAV:  11    -0.142040155105E+02   -0.15706E-02   -0.43005E-04    18   0.201E-01    0.267E-02
DAV:  12    -0.142041222436E+02   -0.10673E-03   -0.11191E-04     6   0.106E-01    0.989E-03
DAV:  13    -0.142042422801E+02   -0.12004E-03   -0.26082E-05     6   0.587E-02    0.352E-03
DAV:  14    -0.142042518369E+02   -0.95569E-05   -0.35661E-06     6   0.202E-02
   1 F= -.14204252E+02 E0= -.14208117E+02  d E =0.115958E-01

2.6 Vasp.torque()