-
Notifications
You must be signed in to change notification settings - Fork 0
Tutorial
Follow this guide to learn how this package can be used. The original purpose was to create a simple package to calculate the spin splitting in altermagnetic materials simulated using VASP, but it has since been extended with more features!
The first step is to import the main class called VASP
:
from vasp_analyzer import VASP
It is the main object that is supposed to handle all the other classes in a single, unified interface to the user. But it is possible to access the other classes individually to modify their content or use associated functions (covered later).
To get started, defined the path to the vasprun.xml
file you wish to analyze:
import os
PATH = os.getcwd() + "/"
relative_path = "path/to/calculation/vasprun.xml"
And then create a VASP
object with an associated path:
vasp = VASP(filepath = PATH + relative_path)
Alternatively, you can create an empty VASP
object and then add the path to the file afterwards:
vasp = VASP()
vasp.add_filepath(PATH + relative_path)
Now you are ready to use it!
Note: The object does not load the
vasprun.xml
at this point yet, but it will load necessary parts of the file once they are needed.
The VASP
function includes many useful functions to get data in a format that can be used directly with the included plotter.
The density of states can now be accessed from the vasp
object as follow:
total_dos = vasp.get_dos_total()
There are further methods to get calculated partial densities of states (make sure your calculation includes partial density of states, otherwise this won't work):
# Density by element present
element_dos = vasp.get_dos_element()
# Density by orbitals
spd_dos = vasp.get_dos_orbital()
# Density by orbitals per element
element_spd_dos = vasp.get_dos_orbital_element()
Any of these can be used with the included plotter (explained later) or you can set get_dos_...(plot=True)
in the function argument to quickly generate a default plot without much hassle.
On the other hand, the default band structure can be accessed with:
band = vasp.get_band_structure()
There is also a function which tries to identify bands based on their orbital character (PROCAR information) to identify which band is which when bands cross:
matched_band = vasp.get_band_structure_matched()
⚠️ This function is not guaranteed to give useful results! Use with caution.
Again, these can be used with the customizable included plotter.
The most important feature here is to extract and plot the spin splitting. For the total spin splitting, it can be calculated using:
splitting = vasp.get_splitting_normal_total()
While it can be calculated for only the occupied bands like this:
splitting_occupied = vasp.get_splitting_normal_total()
The plotter object can be obtained using this method:
vplotter = vasp.get_plotter(size=None, width=None, height=None)
Where size
or width
and height
can be used to set the size of the plot. If nothing is set, the plot will be variable size and adjust to your screen size.
Next add relevant data to the plotter object:
vplotter.add_bs(band_structure)
#or
vplotter.add_dos(density_of_states)
#or
vplotter.add_3d_scatter_weight(spin_splitting)
#or
vplotter.add_contour_weight(spin_splitting)
Where either 3d_scatter_weight
OR countour_weight
can be used for the spin splitting (but not both!). Once all data has been added, it can simply be plotted using:
vplotter.plot(filename=None)
This will automatically plot all the relevant plots. With the filename
option, the plot can be saved (in .html or .png) format!