Skip to content

Commit

Permalink
Merge pull request #920 from pyiron/vasprun_memory_efficiency_fix1
Browse files Browse the repository at this point in the history
Remove redundant property consuming huge amounts of memory in vasprun object
  • Loading branch information
ligerzero-ai authored Jan 7, 2023
2 parents b0190c4 + b7d46a0 commit a4e4aef
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pyiron_atomistics/vasp/vasprun.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class Vasprun(object):

def __init__(self):
self.vasprun_dict = dict()
self.root = None

def from_file(self, filename="vasprun.xml"):
"""
Expand All @@ -59,19 +58,18 @@ def from_file(self, filename="vasprun.xml"):
if not (os.path.isfile(filename)):
raise AssertionError()
try:
self.root = ETree.parse(filename).getroot()
root = ETree.parse(filename).getroot()
except ParseError:
raise VasprunError(
"The vasprun.xml file is either corrupted or the simulation has failed"
)

self.parse_root_to_dict()
self.parse_root_to_dict(root)

def parse_root_to_dict(self):
def parse_root_to_dict(self, root):
"""
Parses from the main xml root.
"""
node = self.root
d = self.vasprun_dict
d["scf_energies"] = list()
d["scf_fr_energies"] = list()
Expand All @@ -84,7 +82,7 @@ def parse_root_to_dict(self):
d["total_fr_energies"] = list()
d["total_0_energies"] = list()
d["stress_tensors"] = list()
for leaf in node:
for leaf in root:
if leaf.tag in ["generator", "incar"]:
d[leaf.tag] = dict()
for items in leaf:
Expand Down

0 comments on commit a4e4aef

Please sign in to comment.