From 3ee17e2c346dea6e9248eb04c989e58880914650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=C3=A1n=20Kavanagh?= <51478689+kavanase@users.noreply.github.com> Date: Tue, 22 Oct 2024 21:28:48 -0400 Subject: [PATCH] Fix selective_dyn handling (#4097) Co-authored-by: Shyue Ping Ong --- src/pymatgen/io/vasp/outputs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pymatgen/io/vasp/outputs.py b/src/pymatgen/io/vasp/outputs.py index 456089258c5..841f28c1070 100644 --- a/src/pymatgen/io/vasp/outputs.py +++ b/src/pymatgen/io/vasp/outputs.py @@ -1510,8 +1510,9 @@ def _parse_structure(self, elem: XML_Element) -> Structure: lattice = _parse_vasp_array(elem.find("crystal").find("varray")) # type: ignore[union-attr] pos = _parse_vasp_array(elem.find("varray")) struct = Structure(lattice, self.atomic_symbols, pos) + selective_dyn = elem.find("varray/[@name='selective']") - if selective_dyn := elem.find("varray/[@name='selective']"): + if selective_dyn is not None: struct.add_site_property("selective_dynamics", _parse_vasp_array(selective_dyn)) return struct