materialsproject / pymatgen

Python Materials Genomics (pymatgen) is a robust materials analysis code that defines classes for structures and molecules with support for many electronic structure codes. It powers the Materials Project.
https://pymatgen.org
Other
1.51k stars 864 forks source link

waveder AttributeError: can't set attribute #1442

Closed amyncarol closed 5 years ago

amyncarol commented 5 years ago

Unable to use the Waveder class in pymatgen.io.vasp.outputs

Error message below:

   4400             cder_data = cder.reshape((nbands, nelect, nk, ispin, 3))
   4401             self.cder_data = cder_data
-> 4402             self.nkpoints = nk
   4403             self.ispin = ispin
   4404             self.nelect = nelect

AttributeError: can't set attribute

I think this because nkpoints is a property and cannot be set. Change nkpoints to _nkpoints and change the nkpoints method accordingly will probably fix the problem.

utf commented 5 years ago

This is also the case for the nbands and nelect attributes.

amyncarol commented 5 years ago

I am also a little confused about cder_data. Should it be a complex vector with x,y,z components for each spin? Then it should have 6 float numbers for each (band1, band2, kpoint, spin)? But from the code, we only get 3 float numbers. It should be similar to the data in wavederf, right?

utf commented 5 years ago

I was also having this issue, I believe the datatype for the cder should be "complex64". E.g. the data is composed of two 32 bit numbers (real and imaginary component). However, looking at the VASP code, it seems like the exact format of the data will depend on whether the wave function is complex or not. I don't know when the wave function is not complex but the code seems like this could happen (perhaps when using the Gamma only version of VASP).

Unfortunately, even setting the dtype of cder to be complex, I couldn't get agreement between the WAVEDER and WAVEDERF file.

Another thing to note is that nelect is incorrectly named. It is not actually the number of electrons. In practice I think it will just be the same as nbands.

mkhorton commented 5 years ago

Yes, the wave function is not complex if it’s gamma point only.

amyncarol commented 5 years ago

Any idea what's the unit of numbers in cder_data?

amyncarol commented 5 years ago

Seems to be standard unit J/m, right?

shyuep commented 5 years ago

So can someone fix this and submit a PR?

mkhorton commented 5 years ago

@knc6, you contributed the WAVEDER class, could you comment on this or would you be willing to submit a fix as appropriate?