VASP 2.0¶
Introduction¶
This module introduces an updated version of the ASE VASP calculator,
which adds the functionality of the
Calculator.='vasp.out', **kwargs)[source]¶
ASE interface for the Vienna Ab initio Simulation Package (VASP), with the Calculator, output stream will be supressed
If txt is ‘-‘ the output will be sent through stdout
If txt is a string a file will be opened, and the output will be sent to that file.
Finally, txt can also be a an output stream, which has a ‘write’ attribute.
Default is ‘vasp.out’
Examples:
>>> Vasp2(label='mylabel', txt='vasp.out') # Redirect stdout >>> Vasp2(txt='myfile.txt') # Redirect stdout >>> Vasp2(txt='-') # Print vasp output to stdout >>> Vasp2(txt=None) # Suppress txt output
- command: str
Custom instructions on how to execute VASP. Has priority over environment variables.
Basic calculator implementation.
- restart: str
Prefix for restart file. May contain a directory. Default is None: don’t restart.
- ignore_bad_restart_file: bool
Ignore broken or missing restart file. By default, it is an error if the restart file is missing or broken.
- directory: str or PurePath
Working directory in which to read and write files and perform calculations.
- label: str
Name used for all files. Not supported by all calculators. May contain a directory, but please use the directory parameter for that instead.
- atoms: Atoms object
Optional Atoms object to which the calculator will be attached. When restarting, atoms will get its positions and unit-cell updated from file.
Note
Parameters can be changed after the calculator has been constructed
by using the
set() method:
>>> calc.set(prec='Accurate', ediff=1E-5)
This would set the precision to Accurate and the break condition
for the electronic SC-loop to
1E-5 eV.
Storing the calculator state¶
The results from the Vasp2 calculator can exported as a dictionary, which can then be saved in a JSON format,
which enables easy and compressed sharing and storing of the input & outputs of
a VASP calculation. The following methods of
Vasp2 can be used for this purpose:
Vasp2.
asdict()[source]¶
Return a dictionary representation of the calculator state. Does NOT contain information on the
command,
txtor
directorykeywords. Contains the following keys:
ase_version
vasp_version
inputs
results
atoms(Only if the calculator has an
Atomsobject)
Vasp2.
fromdict(dct)[source]¶
Restore calculator from a
asdict()dictionary.
Parameters:
- dct: Dictionary
The dictionary which is used to restore the calculator state.
Vasp2.
write_json(filename)[source]¶
Dump calculator state to JSON file.
Parameters:
- filename: string
The filename which the JSON file will be stored to. Prepends the
directorypath to the filename.
First we can dump the state of the calculation using the
write_json() method:
# After a calculation calc.write_json('mystate.json') # This is equivalent to from ase.io import jsonio dct = calc.asdict() # Get the calculator in a dictionary format jsonio.write_json('mystate.json', dct)
At a later stage, that file can be used to restore a the input and (simple) output parameters of a calculation,
without the need to copy around all the VASP specific files, using either the
ase.io.jsonio.read_json() function
or the Vasp2
fromdict() method.
calc = Vasp2() calc.read_json('mystate.json') atoms = calc.get_atoms() # Get the atoms object # This is equivalent to from ase.calculators.vasp import Vasp2 from ase.io import jsonio dct = jsonio.read_json('mystate.json') # Load exported dict object from the JSON file calc = Vasp2() calc.fromdict(dct) atoms = calc.get_atoms() # Get the atoms object
The dictionary object, which is created from the
todict() method, also contains information about the ASE
and VASP version which was used at the time of the calculation, through the
ase_version and
vasp_version keys.
import json with open('mystate.json', 'r') as f: dct = json.load(f) print('ASE version: {}, VASP version: {}'.format(dct['ase_version'], dct['vasp_version']))
Note
The ASE calculator contains no information about the wavefunctions or charge densities, so these are NOT stored in the dictionary or JSON file, and therefore results may vary on a restarted calculation.
Examples¶
The Vasp 2.calc =, show=True) #.