Skip to content

Commit

Permalink
Write json file in abiml.py gs
Browse files Browse the repository at this point in the history
  • Loading branch information
gmatteo committed Feb 26, 2024
1 parent 6dd94a3 commit 6b37665
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions abipy/ml/aseml.py
Original file line number Diff line number Diff line change
Expand Up @@ -3049,6 +3049,20 @@ def run(self):
res = AseResults.from_atoms(self.atoms)
print(res.to_string(verbose=self.verbose))

# Write json file with GS results.
from abipy.tools.serialization import mjson_write
data = dict(
structure=Structure.as_structure(self.atoms),
ene=res.ene,
stress=res.stress,
forces=res.forces,
)
mjson_write(data, self.workdir / "gs.json", indent=4)

# To read the dictionary from json use:
#from abipy.tools.serialization import mjson_load
#data = mjson_load(self.workdir / "gs.json")

# Write ASE trajectory file with results.
with open(self.workdir / "gs.traj", "wb") as fd:
write_traj(fd, [self.atoms])
Expand Down

0 comments on commit 6b37665

Please sign in to comment.