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

changed charge convention #2577

Merged
merged 2 commits into from
Jul 7, 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
2 changes: 1 addition & 1 deletion pymatgen/io/vasp/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,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