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 bug with nmr set writing units #2509

Merged
merged 2 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion pymatgen/io/vasp/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,9 @@ def incar(self):

isotopes = {ist.split("-")[0]: ist for ist in self.isotopes}

quad_efg = [Species(p).get_nmr_quadrupole_moment(isotopes.get(p, None)) for p in self.poscar.site_symbols]
quad_efg = [
float(Species(p).get_nmr_quadrupole_moment(isotopes.get(p, None))) for p in self.poscar.site_symbols
]

incar.update(
{
Expand Down
4 changes: 4 additions & 0 deletions pymatgen/io/vasp/tests/test_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from pymatgen.analysis.structure_matcher import StructureMatcher
from pymatgen.core import SETTINGS, Lattice, Species, Structure
from pymatgen.core.surface import SlabGenerator
from pymatgen.core.units import FloatWithUnit
from pymatgen.io.vasp.inputs import Kpoints, Poscar
from pymatgen.io.vasp.outputs import Vasprun
from pymatgen.io.vasp.sets import (
Expand Down Expand Up @@ -1054,6 +1055,9 @@ def test_incar(self):
vis = MPNMRSet(structure, mode="efg")
self.assertFalse(vis.incar.get("LCHIMAG", None))
self.assertEqual(vis.incar.get("QUAD_EFG", None), [-0.808])
for q in vis.incar["QUAD_EFG"]:
self.assertTrue(isinstance(q, float))
self.assertFalse(isinstance(q, FloatWithUnit))

vis = MPNMRSet(structure, mode="efg", isotopes=["Li-7"])
self.assertFalse(vis.incar.get("LCHIMAG", None))
Expand Down