Skip to content
2 changes: 1 addition & 1 deletion pymatgen/apps/borg/tests/test_queen.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_get_data(self):
drone = VaspToComputedEntryDrone()
self.queen = BorgQueen(drone, PymatgenTest.TEST_FILES_DIR, 1)
data = self.queen.get_data()
assert len(data) == 15
assert len(data) == 16 # added new folder for testing of chemical shift vasprun.

def test_load_data(self):
drone = VaspToComputedEntryDrone()
Expand Down
6 changes: 3 additions & 3 deletions pymatgen/io/vasp/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2281,9 +2281,9 @@ def from_file(filename: str):
potcar = Potcar()

functionals = []
for p in fdata.split("End of Dataset"):
if p_strip := p.strip():
single = PotcarSingle(p_strip + "\nEnd of Dataset\n")
for p in fdata.split("End of Dataset\n"):
if p.strip():
single = PotcarSingle(p + "End of Dataset\n")
potcar.append(single)
functionals.append(single.functional)
if len(set(functionals)) != 1:
Expand Down
9 changes: 7 additions & 2 deletions pymatgen/io/vasp/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,8 +1149,13 @@ def update_charge_from_potcar(self, path):
potcar_nelect = sum(ps.ZVAL * num for ps, num in zip(potcar, nums))
charge = potcar_nelect - nelect

for s in self.structures:
s._charge = charge
# If we do a chemical shift calculation, there is only one ionic step really,
# but parsing the vasprun.xml file will result in len(self.ionic_steps) > 1
# only the first one contains a structure however, where we can update
# the charge.
if not self.incar.get("LCHIMAG"):
for s in self.structures:
s._charge = charge
if hasattr(self, "initial_structure"):
self.initial_structure._charge = charge
if hasattr(self, "final_structure"):
Expand Down
16 changes: 7 additions & 9 deletions pymatgen/io/vasp/tests/test_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,15 +1019,13 @@ def test_verify_correct_potcar_with_hash(self):
def test_multi_potcar_with_and_without_hash(self):
filename = f"{PymatgenTest.TEST_FILES_DIR}/POT_GGA_PAW_PBE_54/POTCAR.Fe_O.gz"
cwd = os.path.abspath(os.path.dirname(__file__))
loadfn(os.path.join(cwd, "../vasp_potcar_file_hashes.json"))
Potcar.from_file(filename)
# Still need to test the if POTCAR can be read.
# No longer testing for hashes
# for psingle in potcars:
# if hasattr(psingle, "hash_sha256_from_file"):
# assert psingle.hash_sha256_computed == psingle.hash_sha256_from_file
# else:
# assert psingle.file_hash in file_hash_db
file_hash_db = loadfn(os.path.join(cwd, "../vasp_potcar_file_hashes.json"))
potcars = Potcar.from_file(filename)
for psingle in potcars:
if hasattr(psingle, "hash_sha256_from_file"):
assert psingle.hash_sha256_computed == psingle.hash_sha256_from_file
else:
assert psingle.file_hash in file_hash_db

# def test_default_functional(self):
# p = PotcarSingle.from_symbol_and_functional("Fe")
Expand Down
10 changes: 10 additions & 0 deletions pymatgen/io/vasp/tests/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,16 @@ def test_parsing_chemical_shift_calculations(self):
assert n_estep == 10
assert vasp_run.converged

# test another chemical shift calculation done with 6.4.1
# and also parsing the associated POTCAR file
filepath_wPOT = f"{self.TEST_FILES_DIR}/nmr/cs/with_POTCAR/vasprun.xml.gz"
vasp_run_wPOT = Vasprun(filepath_wPOT, parse_potcar_file=True)

n_estep_wPOT = len(vasp_run_wPOT.ionic_steps[-1]["electronic_steps"])
assert vasp_run_wPOT.converged
assert n_estep_wPOT == 4
assert vasp_run_wPOT.final_structure._charge == 0.0

def test_parsing_efg_calcs(self):
filepath = f"{self.TEST_FILES_DIR}/nmr/efg/AlPO4/vasprun.xml"
vasp_run = Vasprun(filepath)
Expand Down
Binary file added test_files/nmr/cs/with_POTCAR/POTCAR.gz
Binary file not shown.
Binary file added test_files/nmr/cs/with_POTCAR/vasprun.xml.gz
Binary file not shown.