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.52k stars 867 forks source link

It seems that there is a bug to write the lobsterin file #3437

Closed RedStar-Iron closed 1 year ago

RedStar-Iron commented 1 year ago

https://github.com/materialsproject/pymatgen/blob/15dc77da508c6824a2e7cc41e983f797c64815c4/pymatgen/io/lobster/inputs.py#L271-L272

key in self.get(key) should be lower, then it can be found in Lobsterin.FLOAT_KEYWORDS.

And the cohpsteps might need to be a positive integer.

So I just revised it to:

if key.lower() == "cohpsteps":
    f.write(f"{key} {int(self.get(key.lower()))}\n")
else:
    f.write(f"{key} {self.get(key.lower())}\n")
JaGeo commented 1 year ago

Thanks for looking at the Lobster part of the code. @naik-aakash and I will check your suggestion carefully.

JaGeo commented 1 year ago

I think the bug is coming from the fact that the overwriting of the dict. We will look into it more carefully to not break other parts of the code!

naik-aakash commented 1 year ago

Hi @RedStar-Iron, Thanks for the suggestion. Can you also please post the steps to reproduce the issue? It would help me address it properly

RedStar-Iron commented 1 year ago

Hi @naik-aakash ,

When I run the code below, it gives me None for the FLOAT_KEYWORDS.

    structure = Poscar.from_file("POSCAR").structure
    potcar = Potcar.from_file("POTCAR")
    lobsterin = Lobsterin.from_file(file)
    basisfunctions = lobsterin.get_basis(structure, potcar.symbols)
    lobsterin['basisfunctions'] = basisfunctions
    lobsterin.write_lobsterin("lobsterin")
JaGeo commented 1 year ago

Yup, I have also already reproduced the issue and have started with a fix. Will start the WIP pull request in a minute.

JaGeo commented 1 year ago

@RedStar-Iron we have worked on a fix for both of your issues. However, we investigated that it does not matter if cohpsteps is a float or int (see here https://github.com/materialsproject/pymatgen/pull/3439#issuecomment-1791469518)