Skip to content

Commit

Permalink
Merge pull request #2577 from jmmshn/charge_sign
Browse files Browse the repository at this point in the history
changed charge convention
  • Loading branch information
shyuep committed Jul 7, 2022
2 parents 91184c3 + 5f2ce21 commit d10c460
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pymatgen/io/vasp/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ def update_charge_from_potcar(self, path):
else:
nums = [len(list(g)) for _, g in itertools.groupby(self.atomic_symbols)]
potcar_nelect = sum(ps.ZVAL * num for ps, num in zip(potcar, nums))
charge = nelect - potcar_nelect
charge = potcar_nelect - nelect

if charge:
for s in self.structures:
Expand Down
4 changes: 2 additions & 2 deletions pymatgen/io/vasp/tests/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,14 +738,14 @@ def test_charged_structure(self):
vasprun = Vasprun(vpath, parse_potcar_file=False)
vasprun.update_charge_from_potcar(potcar_path)
self.assertEqual(vasprun.parameters.get("NELECT", 8), 9)
self.assertEqual(vasprun.structures[0].charge, 1)
self.assertEqual(vasprun.structures[0].charge, -1)

vpath = self.TEST_FILES_DIR / "vasprun.split.charged.xml"
potcar_path = self.TEST_FILES_DIR / "POTCAR.split.charged.gz"
vasprun = Vasprun(vpath, parse_potcar_file=False)
vasprun.update_charge_from_potcar(potcar_path)
self.assertEqual(vasprun.parameters.get("NELECT", 0), 7)
self.assertEqual(vasprun.structures[-1].charge, 1)
self.assertEqual(vasprun.structures[-1].charge, -1)

def test_kpointset_electronvelocities(self):
vpath = self.TEST_FILES_DIR / "vasprun.lvel.Si2H.xml"
Expand Down

0 comments on commit d10c460

Please sign in to comment.