pymatgen
pymatgen copied to clipboard
Reading WAVECAR for SOC is not working
Hello,
I hope you will find this message in good health.
I trying to load the spin-orbit coupling WAVCAR but failed. I got the following error message:
Traceback (most recent call last):
File "/lustre/project/k1388/shafiq/CSLD-AMSET/install4/bin/amset", line 33, in
Can you provide your pymatgen version, VASP version, and a copy of the WAVECAR?
I have used pymatgen==2020.11.11 and vasp 5.4.4 version. I am unable to attach the WAVECAR file because the size of the file is very large (approx. 155 GB).
Do you have enough memory? The entire WAVECAR will be read in to memory. I've tested against a WAVECAR generated from 5.4.4, so it should work. Without the WAVECAR, I'm not really sure how to debug it for you.
Hi Mark,
I have also run into the 'incorrect vasp_type'
issue trying to convert WAVECAR to wavefunction.h5 file. The WAVECAR is generated by VASP 5.4.4 and is about 5 MB. So, I do not think mine is a memory issue. Could you test if you could convert my WAVECAR file? I have tested this with pymatgen installed on different OS (both linux and windows). Any insights will be much appreciated.
Thank you, Manoj
Hi @ManojSettipalli, I took a look at the file you sent. It seems that the number of plane waves that are read in from the WAVECAR at the first kpoint is 339, which is not evenly divisible by 2, so something is wrong. A noncollinear WAVECAR has spinors, so there should be twice as many plane waves as usual, one set for spin up and one set for down. By any chance, was this WAVECAR from a relaxation where the volume was also relaxed? That's my only guess as to what may be going wrong. Perhaps try doing a fixed geometry calculation from this WAVECAR to generate a new one and see if that fixes it.
If that's not the case, then I'm not really sure what might be wrong. I can look into it, but I'm quite busy at the moment, so I may not get back to you for some time.
Hi Mark,
Thank you for your response. I should have mentioned that I got the error for an 'std' type calculation so it is not a noncollinear calculation. I still had this issue. As a last attempt, I fully uninstalled Python on my computer and reinstalled a new python on Conda, and then installed pymatgen. Now, the WAVECAR is being read. So, while I am not entirely sure what the issue was, I am just going with this for now.
Thank you, Manoj
That's strange. I'm glad it worked out in the end.
I guess this problem may come from the precision of calculating Gpoints from _generate_G_points function.
As you can find in the code, the error is raised when the deduced Gpoints is mismatched with nplane.
The plane waves near the boundary of the cutoff radius (in energy) are critical to include as bases.
if len(self.Gpoints[ink]) != nplane and 2 * len(self.Gpoints[ink]) != nplane:
raise ValueError(
f"Incorrect value of vasp_type given ({vasp_type})."
" Please open an issue if you are certain this WAVECAR"
" was generated with the given vasp_type."
)
So, changing the k-point that encounters the error might solve the problem.
@mturiansky
I found that three lines in the outputs.py script below could cause the problem.
for i in range(2 * self._nbmax[2] + 1):
i3 = i - 2 * self._nbmax[2] - 1 if i > self._nbmax[2] else i
for j in range(2 * self._nbmax[1] + 1):
j2 = j - 2 * self._nbmax[1] - 1 if j > self._nbmax[1] else j
for k in range(kmax):
k1 = k - 2 * self._nbmax[0] - 1 if k > self._nbmax[0] else k
if gamma and ((k1 == 0 and j2 < 0) or (k1 == 0 and j2 == 0 and i3 < 0)):
continue
G = np.array([k1, j2, i3])
v = kpoint + G
g = np.linalg.norm(np.dot(v, self.b))
E = g**2 / self._C
if E < self.encut:
gpoints.append(G)
if gamma and (k1, j2, i3) != (0, 0, 0):
extra_gpoints.append(-G)
extra_coeff_inds.append(G_ind)
G_ind += 1
i3 = i - 2 * self._nbmax[2] - 1 if i > self._nbmax[2] else i
j2 = j - 2 * self._nbmax[1] - 1 if j > self._nbmax[1] else j
k1 = k - 2 * self._nbmax[0] - 1 if k > self._nbmax[0] else k
Three lines could be critical with the if conditions. During the calculation of Gpoints, the vector G must be in the 1st Brillouin zone. The folding way, if condition in three lines, causes the lack of Gpoints.
Some K-points outside the 1st Brillouin zone were set in my WAVECAR.
~~It seems that an even element in self._nbmax causes the error.~~
Replacing _generate_G_points with the code below works for my specific WAVECAR by accident, but I could understand how it works.
I confirmed the way that the code reads Gpoints matches the way VASP reads Gpoints (only for my case).
def _generate_G_points(self, kpoint: np.ndarray, gamma: bool = False) -> tuple[list, list, list]:
"""
Helper function to generate G-points based on nbmax.
This function iterates over possible G-point values and determines
if the energy is less than G_{cut}. Valid values are appended to
the output array. This function should not be called outside of
initialization.
Args:
kpoint (np.array): the array containing the current k-point value
gamma (bool): determines if G points for gamma-point only executable
should be generated
Returns:
a list containing valid G-points
"""
if gamma:
kmax = self._nbmax[0] + 1
else:
kmax = 2 * self._nbmax[0] + 1
gpoints = []
extra_gpoints = []
extra_coeff_inds = []
G_ind = 0
for i in range(2 * self._nbmax[2] + 1):
i3 = i - 2 * self._nbmax[2] - 1 if i > self._nbmax[2] else i
for j in range(2 * self._nbmax[1] + 1):
j2 = j - 2 * self._nbmax[1] - 1 if j > self._nbmax[1] else j
for k in range(kmax):
k1 = k - 2 * self._nbmax[0] - 1 if k > self._nbmax[0] else k
if gamma and ((k1 == 0 and j2 < 0) or (k1 == 0 and j2 == 0 and i3 < 0)):
continue
G = np.array([k1, j2, i3])
v = kpoint + G
g = np.linalg.norm(np.dot(v, self.b))
E = g**2 / self._C
if E < self.encut:
gpoints.append(G)
if gamma and (k1, j2, i3) != (0, 0, 0):
extra_gpoints.append(-G)
extra_coeff_inds.append(G_ind)
G_ind += 1
elif i == self._nbmax[2]:
i3 = i - 2 * self._nbmax[2] - 1
if gamma and ((k1 == 0 and j2 < 0) or (k1 == 0 and j2 == 0 and i3 < 0)):
continue
G = np.array([k1, j2, i3])
v = kpoint + G
g = np.linalg.norm(np.dot(v, self.b))
E = g**2 / self._C
if E < self.encut:
gpoints.append(G)
if gamma and (k1, j2, i3) != (0, 0, 0):
extra_gpoints.append(-G)
extra_coeff_inds.append(G_ind)
G_ind += 1
elif j == self._nbmax[1]:
j2 = j - 2 * self._nbmax[1] - 1
if gamma and ((k1 == 0 and j2 < 0) or (k1 == 0 and j2 == 0 and i3 < 0)):
continue
G = np.array([k1, j2, i3])
v = kpoint + G
g = np.linalg.norm(np.dot(v, self.b))
E = g**2 / self._C
if E < self.encut:
gpoints.append(G)
if gamma and (k1, j2, i3) != (0, 0, 0):
extra_gpoints.append(-G)
extra_coeff_inds.append(G_ind)
G_ind += 1
elif k == self._nbmax[0]:
k1 = k - 2 * self._nbmax[0] - 1
if gamma and ((k1 == 0 and j2 < 0) or (k1 == 0 and j2 == 0 and i3 < 0)):
continue
G = np.array([k1, j2, i3])
v = kpoint + G
g = np.linalg.norm(np.dot(v, self.b))
E = g**2 / self._C
if E < self.encut:
gpoints.append(G)
if gamma and (k1, j2, i3) != (0, 0, 0):
extra_gpoints.append(-G)
extra_coeff_inds.append(G_ind)
G_ind += 1
return (gpoints, extra_gpoints, extra_coeff_inds)
I hope to share whether it works for other WAVECARs with the error.
@Nokimann Feel free to open a new issue if this is still an issue. I'll close this issue as completed for now.
I have encountered a similar problem on line 4345 of the vasp outputs.py module. I have explicitly included the correct precision and vasp binary type (accurate, ncl). The incar that produced it is the following:
ALGO = Fast
AMIN = 0.01
EDIFF = 1e-06
ENCUT = 600 eV
GGA = PE
ISMEAR = 0
LASPH = True
LDAU = False
LMAXMIX = 4
LORBIT = 11
LREAL = Auto
LSORBIT = True
LWAVE = True
MAGMOM = 100*0
NELM = 100
PREC = Accurate
SIGMA = 0.05
Do keep in mind that I produced this WAVECAR using line mode, so perhaps that might be an issue?
For now, I have commented out the conditional statement to see if there are any further issues, as all I need is the charge density at a specific single kpoint.
@wladerer feel free to open an issue with a repro if you can confirm there's a bug