Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SOC DOS parsing for latest pymatgen #256

Merged
merged 5 commits into from
Feb 7, 2025
Merged

Conversation

kavanase
Copy link
Member

@kavanase kavanase commented Feb 6, 2025

Since materialsproject/pymatgen#4239, Spin.down entries are no longer stored in pymatgen DOS objects parsed from SOC calculations (as desired). There was a patch in sumo to delete this entry for SOC calculations if present, to make later downstream plotting easier, but this now causes a KeyError when used with the latest pymatgen due to this entry no longer being present:

sumo-dosplot
Traceback (most recent call last):
  File "/home/mmm0650/miniconda3/bin/sumo-dosplot", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/mmm0650/miniconda3/lib/python3.12/site-packages/sumo/cli/dosplot.py", line 646, in main
    dosplot(
  File "/home/mmm0650/miniconda3/lib/python3.12/site-packages/sumo/cli/dosplot.py", line 207, in dosplot
    dos, pdos = load_dos(
                ^^^^^^^^^
  File "/home/mmm0650/miniconda3/lib/python3.12/site-packages/sumo/electronic_structure/dos.py", line 132, in load_dos
    del dos.densities[Spin.down]
        ~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: <Spin.down: -1>

This small update fixes the issue.

@ajjackson
Copy link
Member

Would it be feasible to produce a small test case for this, or are these vaspruns always monstrous?

@kavanase
Copy link
Member Author

kavanase commented Feb 7, 2025

I looked at doing this when I added the fix, but didn't see a test file for DOS loading/handling. I've added one now. I checked and found the Cs2SnBr6 example in the repo is a SOC run so works for the test.

@ajjackson
Copy link
Member

That's wonderful, thanks Seán! Please add a line to the CHANGELOG and I'll be happy to merge.

PS I notice you are merging from a branch named "master". You may find that if we squash this PR or accept another one first then git pull stops working and you are stuck out of sync. It's salvageable, but generally easier to work on a branch with a new name instead...

@kavanase
Copy link
Member Author

kavanase commented Feb 7, 2025

Done.

Yeah should've made a new branch first, but went with the quick option. Will try remember that next time!

@ajjackson ajjackson merged commit 19be88a into SMTG-Bham:master Feb 7, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants