Skip to content

Commit

Permalink
Merge pull request #1338 from pyiron/lammps_from_dict_recursive
Browse files Browse the repository at this point in the history
Lammps: use recursive=True in read_dict_from_hdf()
  • Loading branch information
pmrv authored Feb 23, 2024
2 parents 2931bc1 + ae917c6 commit 39cd086
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions pyiron_atomistics/lammps/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,16 +740,8 @@ def from_hdf(self, hdf=None, group_name=None): # TODO: group_name should be rem
"""
super(LammpsBase, self).from_hdf(hdf=hdf, group_name=group_name)
self._structure_from_hdf()
self.input.from_dict(
data_dict=self._hdf5.read_dict_from_hdf(
[
"input",
"input/control_inp",
"input/potential_inp",
"input/potential_inp/potential",
]
)
)
with self.project_hdf5.open("input") as hdf_input:
self.input.from_dict(data_dict=hdf_input.read_dict_from_hdf(recursive=True))

def write_restart_file(self, filename="restart.out"):
"""
Expand Down Expand Up @@ -1056,10 +1048,10 @@ def _load_default_bond_params(self):
self.bond_dict["O"]["angle_type_list"] = [1]

def from_dict(self, data_dict):
self.control.from_dict(data_dict["input"]["control_inp"])
self.potential.from_dict(data_dict["input"]["potential_inp"])
if "bond_dict" in data_dict["input"].keys():
self.bond_dict = data_dict["input"]["bond_dict"]
self.control.from_dict(data_dict[self.control.table_name])
self.potential.from_dict(data_dict[self.potential.table_name])
if "bond_dict" in data_dict.keys():
self.bond_dict = data_dict["bond_dict"]

def to_dict(self):
return {
Expand All @@ -1085,16 +1077,8 @@ def from_hdf(self, hdf5):
hdf5:
Returns:
"""
self.from_dict(
data_dict=hdf5.read_dict_from_hdf(
[
"input",
"input/control_inp",
"input/potential_inp",
"input/potential_inp/potential",
]
)
)
with hdf5.open("input") as hdf_input:
self.from_dict(data_dict=hdf_input.read_dict_from_hdf(recursive=True))


def resolve_hierachical_dict(data_dict, group_name=""):
Expand Down

0 comments on commit 39cd086

Please sign in to comment.