Skip to content

Commit

Permalink
Add None support for user_incar_settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep committed Feb 27, 2019
1 parent abeee3d commit 111f44f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pymatgen/io/vasp/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ class DictSet(VaspInputSet):
of two ways, e.g. either {"LDAUU":{"O":{"Fe":5}}} to set LDAUU
for Fe to 5 in an oxide, or {"LDAUU":{"Fe":5}} to set LDAUU to
5 regardless of the input structure.
If a None value is given, that key is unset. For example,
{"ENCUT": None} will remove ENCUT from the incar settings.
user_kpoints_settings (dict or Kpoints): Allow user to override kpoints
setting by supplying a dict E.g., {"reciprocal_density": 1000}.
User can also supply Kpoints object. Default is None.
Expand Down Expand Up @@ -297,7 +300,14 @@ def __init__(self, structure, config_dict,
@property
def incar(self):
settings = dict(self._config_dict["INCAR"])
settings.update(self.user_incar_settings)
for k, v in self.user_incar_settings.items():
if v is None:
try:
del settings[k]
except KeyError:
settings[k] = v
else:
settings[k] = v
structure = self.structure
incar = Incar()
comp = structure.composition
Expand Down
3 changes: 3 additions & 0 deletions pymatgen/io/vasp/tests/test_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ def test_get_incar(self):
)
self.assertEqual(userset.incar['MAGMOM'], [100, 0.6])

noencutset = MPRelaxSet(struct, user_incar_settings={'ENCUT': None})
self.assertNotIn("ENCUT", noencutset.incar)

# sulfide vs sulfate test

coords = list()
Expand Down

0 comments on commit 111f44f

Please sign in to comment.