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.48k stars 851 forks source link

VASP noncollinear Wavecar read error #3640

Open wladerer opened 6 months ago

wladerer commented 6 months ago

Python version

Python 3.11.7

Pymatgen version

Version: 2023.11.12

Operating system version

Red Hat Enterprise Linux 8.8

Current behavior

similar to #1995

vsh wavecar WAVECAR -k 130 -b 84 85 -S CONTCAR -o both_bands_gamma.vasp -p --vasp-type ncl --prec accurate
Traceback (most recent call last):
  File "/p/home/wladerer/.pyenv/versions/3.11.7/bin/vsh", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/p/home/wladerer/.execs/vsh/vsh/cli.py", line 23, in main
    command.run(args)
  File "/p/home/wladerer/.execs/vsh/vsh/scripts/wavecar.py", line 207, in run
    func(args)
  File "/p/home/wladerer/.execs/vsh/vsh/scripts/wavecar.py", line 54, in generate_parchg
    wave = Wavecar(args.input, vasp_type=args.vasp_type, precision=args.prec)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/p/home/wladerer/.pyenv/versions/3.11.7/lib/python3.11/site-packages/pymatgen/io/vasp/outputs.py", line 4354, in __init__
    raise ValueError(
ValueError: Incorrect vasp_type='ncl'. Please open an issue if you are certain this WAVECAR was generated with the given vasp_type.

Expected Behavior

My goal was to create a cube file from a specific kpoint and band, so I anticipated that the script would run and produce an output file.

Minimal example

from pymatgen.io.vasp.outputs import Wavecar

wave = Wavecar("WAVECAR", vasp_type="ncl", precision="accurate")

Relevant files to reproduce this bug

I have included some basic wavecar info, the verbose output of the Wavecar init method, the kpoints file and the incar file

wladerer commented 6 months ago

No errors were found after commenting out the following lines (starting at 4345)

                    if len(self.Gpoints[ink]) != nplane and 2 * len(self.Gpoints[ink]) != nplane:
                        raise ValueError(
                            f"Incorrect {vasp_type=}. Please open an issue if you are certain this WAVECAR"
                            " was generated with the given vasp_type."
                        )

And produced the expected cube file.

I will investigate more over the weekend