romerogroup / pyprocar

A Python library for electronic structure pre/post-processing
GNU General Public License v3.0
171 stars 75 forks source link

Issue with plotting spin texture #143

Open malharkute opened 6 months ago

malharkute commented 6 months ago

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 commented 6 months ago

Just a simple check, did you check that the calculation runs correctly for the noncollinear case? meaning, check the PROCAR file and see the 4 blocks you expect to see for each Kpoint, each corresponding to Sx, Sy and Sz and total S… if this is the case, we can check further… but first the PROCAR should be correct.

__::::__ Prof. Aldo Humberto Romero Director Research Computing, West Virginia University Eberly Family Distinguished Professor Fellow American Physical Society Editor Physica B, Assistant Editor EPJB, Editor Frontiers in Physics Section Editor Papers in Physics Member of the Editorial Board of “Materials” and “Symmetry Physics”

Physics and Astronomy Department West Virginia University 135 Willey Street, PO Box 6315 111 White Hall Morgantown, WV 26506 Phone: 304-293-6317 Fax: 304-293-5732 email: @.***

From: malharkute @.> Date: Thursday, April 11, 2024 at 8:17 PM To: romerogroup/pyprocar @.> Cc: Subscribed @.***> Subject: [romerogroup/pyprocar] Issue with plotting spin texture (Issue #143)

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!

— Reply to this email directly, view it on GitHubhttps://github.com/romerogroup/pyprocar/issues/143, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AB24DTJDHBSULMXJ6E4C3VLY44RYBAVCNFSM6AAAAABGDGPVZCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGIZTQOBQG44TOOI. You are receiving this because you are subscribed to this thread.Message ID: @.***>

malharkute commented 6 months ago

Hi Aldo,

Thanks for your quick response. Yes, the PROCAR files are indeed formatted as your described. I checked with two different PROCAR calculations, both non-collinear, and had the same issue in both cases.

Thanks for your help! Malhar


From: Aldo Romero @.> Sent: Thursday, April 11, 2024 5:47 PM To: romerogroup/pyprocar @.> Cc: Malhar Balkrishna Kute @.>; Author @.> Subject: Re: [romerogroup/pyprocar] Issue with plotting spin texture (Issue #143)

Just a simple check, did you check that the calculation runs correctly for the noncollinear case? meaning, check the PROCAR file and see the 4 blocks you expect to see for each Kpoint, each corresponding to Sx, Sy and Sz and total S… if this is the case, we can check further… but first the PROCAR should be correct.

__::::__ Prof. Aldo Humberto Romero Director Research Computing, West Virginia University Eberly Family Distinguished Professor Fellow American Physical Society Editor Physica B, Assistant Editor EPJB, Editor Frontiers in Physics Section Editor Papers in Physics Member of the Editorial Board of “Materials” and “Symmetry Physics”

Physics and Astronomy Department West Virginia University 135 Willey Street, PO Box 6315 111 White Hall Morgantown, WV 26506 Phone: 304-293-6317 Fax: 304-293-5732 email: @.***

From: malharkute @.> Date: Thursday, April 11, 2024 at 8:17 PM To: romerogroup/pyprocar @.> Cc: Subscribed @.***> Subject: [romerogroup/pyprocar] Issue with plotting spin texture (Issue #143)

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!

— Reply to this email directly, view it on GitHubhttps://github.com/romerogroup/pyprocar/issues/143, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AB24DTJDHBSULMXJ6E4C3VLY44RYBAVCNFSM6AAAAABGDGPVZCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGIZTQOBQG44TOOI. You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHubhttps://github.com/romerogroup/pyprocar/issues/143#issuecomment-2050775688, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AWOKXRDEHJKNIHJC4X3CHA3Y44VLNAVCNFSM6AAAAABGDGPVZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJQG43TKNRYHA. You are receiving this because you authored the thread.Message ID: @.***>

lllangWV commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

Did you manage to download the repository from GitHub?