Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with plotting spin texture #143

Open
malharkute opened this issue Apr 12, 2024 · 9 comments
Open

Issue with plotting spin texture #143

malharkute opened this issue Apr 12, 2024 · 9 comments

Comments

@malharkute
Copy link

Hello,

I'm trying to use pyprocar to plot the spin texture from a VASP calculation, but I'm finding conflicting documentation online. Here's how I'm calling the fermi2d function:
pyprocar.fermi2D('vasp', dirname=".", spin_texture=True, fermi=8.3106204826 - 0.1, spins=[1, 2], band_indices=[[46, 47], [46, 47]])

However, I get an error in the following line, as i_spin=2 is out of bounds.
indices = np.where( np.logical_and(ebs.bands[:,:,i_spin].min(axis=0) < energy, ebs.bands[:,:,i_spin].max(axis=0) > energy))

I did some digging and found that ebs.bands has shape (num_k, num_bands, 1), even though this is a non-collinear calculation. In my PROCAR files, I have Sx, Sy and Sz projections, yet it seems I can't plot these. Would you be able to help me figure out a workaround so I can plot the spin texture?

Thank you!

@ahromero
Copy link
Collaborator

ahromero commented Apr 12, 2024 via email

@malharkute
Copy link
Author

malharkute commented Apr 12, 2024 via email

@lllangWV
Copy link
Member

Hey Malhar,

so the issue is specifying spins = [1,2]. The argument is for when the calculation is a spin-polarized calculation For non-collinear calculations, the ebs.bands will have a shape [nkpoints,nbands,1], i.e. the band energies for a kpoint do not change based on the spin projections. Now, ebs.projected will have a shape [n_kpoints,n_bands,4, n_orbitals,n_atoms]. Where the third dimension represents the different spin projections. Index 0 is the total, Index 1 is Sx, Index 2 is Sy, and index 3 is Sz.

To fix your issue, just remove spins as an argument:

pyprocar.fermi2D('vasp', dirname=".", spin_texture=True, fermi=8.3106204826 - 0.1, band_indices=[[46, 47], [46, 47]])

You can also see additional keyword arguments for this function by passing print_plot_opts=True. This will print all the plot options. Now, since you are dealing with spin texture. I think you would be interested in keyword arguments listed below. In particular, you can choose which spin projection as the color scale. By default, it is z^2. But you can choose from (x,y,z,x^2,y^2,z^2)

no_arrow:
description: Boolean to use no arrows to represent the spin texture
value: False

arrow_color:
description: The linestyles for the spin plot lines.
value:

arrow_density:
description: The arrow density for the spin texture
value: 10
arrow_size:
description: The arrow size for the spin texture
value: 3

spin_projection:
description: The projection for the color scale for spin texture
value: z^2

Logan Lang

@malharkute
Copy link
Author

Hi Logan

Thanks for your help! Your suggestion to remove the spin argument does allow the code the run without any errors. However, the resulting plot doesn't seem to have any arrows, rather just dots on a line (see below). It also doesn't seem to change when I alter the "arrow_size" parameter. Do you know what might be the reason for this?

Thanks!

image

@lllangWV
Copy link
Member

Hey Malhar,

I just noticed it works the opposite the way you think, so the closer you are to 0 the larger the arrows. It has been a while since I worked on this code and I can't seem to remember why I left it like this. The arrow density also works like this too

I'll change this to what people would expect when you increase the size, the arrows should increase.

@lllangWV
Copy link
Member

Hey Malhar,

I just updated github, so the arrow_density and the arrow_size scale the way you would expect. Meaning increasing number means increasing density/size.

To see these updates clone the repository from github. Here are the commands for that.

bash
pip uninstall pyprocar
git clone git@github.com:romerogroup/pyprocar.git
cd pyprocar
pip install .

I will try to get this in the Pypi version as soon as possible. There are some further additions I would like to add before updating PyPi.

@malharkute
Copy link
Author

Great! Looks like I don't have permission to clone the repository:
`Cloning into 'pyprocar'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
`

@lllangWV
Copy link
Member

So this is from you not having your ssh keys for your computer register with your GitHub account. If you search this on google, you can figure out how to do this. It's very handy to have it registered.

Instead, you can download the zip of the repository, extract the zip on your computer, open a terminal inside the repo and do 'pip install .'

@lllangWV
Copy link
Member

Did you manage to download the repository from GitHub?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants