Skip to content

Commit

Permalink
Fixed bugs in lobster and qe spin polarized calculations related to n…
Browse files Browse the repository at this point in the history
…umber of bands
  • Loading branch information
uthpalaherath committed Jul 28, 2020
1 parent 3bff5ed commit 0a8e7d8
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 38 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ will bring a help menu.
Changelog
--------------

v5.5.0 July 27th, 2020 -- Updated spin colinear calculations for Quantum Espresso and Lobster codes. <br />
v5.5.2 July 27th, 2020 -- Updated spin colinear calculations for Quantum Espresso and Lobster codes. <br />
v5.4.3 July 25th, 2020 -- Bug fixes in stand-alone version and updates to bandgap calculation. <br />
v5.4.0 Jun 17th, 2020 -- Improved 3D Fermi Surface plotter, added support for Quantum Espresso, conda support. <br />
v5.3.3 May 22nd, 2020 -- Added DOS plotting feature. <br />
Expand Down
2 changes: 1 addition & 1 deletion pyprocar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__author__ = "Francisco Munoz,Aldo Romero,Sobhit Singh,Uthpala Herath,Pedram Tavadze,Eric Bousquet,Xu He"
__copyright__ = "Copyright 2020"
__version__ = "5.5.1"
__version__ = "5.5.2"
__email__ = (
"[email protected]/[email protected]/[email protected]/[email protected]"
)
Expand Down
73 changes: 39 additions & 34 deletions pyprocar/lobsterparser/lobsterparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from re import findall, search, match, DOTALL, MULTILINE, finditer, compile, sub

from numpy import array, dot, linspace, sum, where, zeros, pi
from numpy import array, dot, linspace, sum, where, zeros, pi, concatenate
import logging


Expand Down Expand Up @@ -52,7 +52,7 @@ def __init__(
self.ionsList = None
self.ionsCount = None
self.spinCount = None

# Used to store atomic states at the top of the kpdos.out file
self.states = None

Expand Down Expand Up @@ -231,8 +231,8 @@ def _readProjFiles(self):
for ikband in kpoint_bands:
band_info.append(ikband)

# if len(band_info) == self.bandsCount * self.kpointsCount:
# print("Number of bands headers match")
# if len(band_info) == self.bandsCount * self.kpointsCount:
# print("Number of bands headers match")
self.bands = zeros(shape=(self.kpointsCount, self.bandsCount))

ik = 0
Expand All @@ -248,15 +248,12 @@ def _readProjFiles(self):
# Forming SPD array
#########################################################################################

#Checks for spin polarization
# Checks for spin polarization
if len(findall("spillings for spin channel", self.lobsterout)) == 2:
self.spinCount = 2
else:
self.spinCount = 1




self.orbitalCount = 10
self.spd = zeros(
shape=(
Expand Down Expand Up @@ -296,55 +293,63 @@ def _readProjFiles(self):
band = findall(expression + bands_wSpin * "(.*)\n", projFile)[0]
for iband in range(self.bandsCount):
if self.spinCount == 2:
self.spd[ik,iband,0,ionIndex,orbitalIndex] += float(band[iband].split()[2])
self.spd[ik,iband,0,ionIndex,0] = ionIndex + 1
self.spd[ik,iband,1,ionIndex,orbitalIndex] += float(band[iband+self.bandsCount].split()[2])
self.spd[ik,iband,1,ionIndex,0] = ionIndex + 1
self.spd[ik, iband, 0, ionIndex, orbitalIndex] += float(
band[iband].split()[2]
)
self.spd[ik, iband, 0, ionIndex, 0] = ionIndex + 1
self.spd[ik, iband, 1, ionIndex, orbitalIndex] += float(
band[iband + self.bandsCount].split()[2]
)
self.spd[ik, iband, 1, ionIndex, 0] = ionIndex + 1
else:
self.spd[ik,iband,0,ionIndex,orbitalIndex] += float(band[iband].split()[2])
self.spd[ik,iband,0,ionIndex,0] = ionIndex + 1

self.spd[ik, iband, 0, ionIndex, orbitalIndex] += float(
band[iband].split()[2]
)
self.spd[ik, iband, 0, ionIndex, 0] = ionIndex + 1

self.spd[:, :, :, :, -1] = sum(self.spd[:, :, :, :, 1:-1], axis=4)
self.spd[:, :, :, -1, :] = sum(self.spd[:, :, :, 0:-1, :], axis=3)
self.spd[:, :, :, -1, 0] = 0

# colinear spin polarized case

# manipulating spd array for spin polarized calculations.
# The shape is (nkpoints,2*nbands,2,natoms,norbitals)
# The third dimension is for spin.
# When this is zero, the bands*2 (all spin up and down bands) have positive projections.
# When this is one, the the first half of bands (spin up) will have positive projections
# and the second half (spin down) will have negative projections. This is to adhere to
# the convention used in PyProcar to obtain spin density and spin magnetization.

if self.spinCount == 2:
print("\nLobster colinear spin calculation detected.\n")
self.spd2 = zeros(
shape=(
self.kpointsCount,
self.bandsCount*2,
self.spinCount,
self.ionsCount + 1,
len(self.orbitals) + 2,
shape=(
self.kpointsCount,
self.bandsCount * 2,
self.spinCount,
self.ionsCount + 1,
len(self.orbitals) + 2,
)
)

# spin up block for spin=0
self.spd2[:, :self.bandsCount, 0, :, :] = self.spd[:,:,0,:,:]
self.spd2[:, : self.bandsCount, 0, :, :] = self.spd[:, :, 0, :, :]

# spin down block for spin=0
self.spd2[:, self.bandsCount:, 0, :, :] = self.spd[:,:,1,:,:]
self.spd2[:, self.bandsCount :, 0, :, :] = self.spd[:, :, 1, :, :]

# spin up block for spin=1
self.spd2[:, :self.bandsCount, 1, :, :] = self.spd[:,:,0,:,:]
self.spd2[:, : self.bandsCount, 1, :, :] = self.spd[:, :, 0, :, :]

# spin down block for spin=1
self.spd2[:, self.bandsCount:, 1, :, :] = -1*self.spd[:,:,1,:,:]
self.spd2[:, self.bandsCount :, 1, :, :] = -1 * self.spd[:, :, 1, :, :]

self.spd = self.spd2

# Reshaping bands array to inlcude all bands (spin up and down)
self.bands = bands = concatenate((self.bands, self.bands), axis=1)

@property
def fermi(self):
"""
Expand Down Expand Up @@ -383,4 +388,4 @@ def reclat(self):
# Transposing to get the correct format
reclat = reclat.T

return reclat
return reclat
5 changes: 5 additions & 0 deletions pyprocar/qeparser/qeparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,11 @@ def _readQEin(self):

self.spd = self.spd2

# Reshaping bands array to inlcude all bands (spin up and down)
self.bands = self.bands.reshape(
self.kpointsCount, self.bandsCount * 2, order="F"
)

@property
def fermi(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

setup(
name="pyprocar",
version="5.5.1",
version="5.5.2",
author="Francisco Munoz,Aldo Romero,Sobhit Singh,Uthpala Herath,Pedram Tavadze,Eric Bousquet, Xu He",
author_email="[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]",
url="https://github.com/romerogroup/pyprocar",
download_url="https://github.com/romerogroup/pyprocar/archive/5.5.1.tar.gz",
download_url="https://github.com/romerogroup/pyprocar/archive/5.5.2.tar.gz",
packages=[
"pyprocar",
"pyprocar.utilsprocar",
Expand Down

0 comments on commit 0a8e7d8

Please sign in to comment.