QijingZheng / VaspBandUnfolding

A collection of python scripts that deal with VASP outpts, e.g. WAVECAR, POTCAR etc.
198 stars 89 forks source link

dtype=int is not enough? (readWFHeader in vaspwfc) #10

Open mr-j-s opened 4 years ago

mr-j-s commented 4 years ago

Method readWFHeader in vaspwfc.py uses this code (currently lines 157-160):

        self._recl, self._nspin, self._rtag = np.array(
            np.fromfile(self._wfc, dtype=np.float, count=3),
            dtype=int
        )

It seems that for large WAVECARs dtype=int is not enough. I was getting overflow errors (don't remember all the details, I can try to reproduce the behaviour if needed). Changing from dtype=int to dtype=np.int64 fixed the issue.

QijingZheng commented 4 years ago

Hi

The default length of np.int on a 64-bit machine is 8 bytes, which is the same as that of np.int64. And I think it is large enough to hold the recl.

scrot_kaka

Did you use the code on a 32-bit machine?

mr-j-s commented 4 years ago

Hi

The default length of np.int on a 64-bit machine is 8 bytes, which is the same as that of np.int64. And I think it is large enough to hold the recl.

scrot_kaka

Did you use the code on a 32-bit machine?

64bit machine (checked with systeminfo). image

QijingZheng commented 4 years ago

Hmmm... It is strange that your numpy outputs and mine show a difference.

Anyway, I think it is wise to specifically assign np.int64 to recl in the code, which I have added to the code.

Thank you!