CederGroupHub / chgnet

Pretrained universal neural network potential for charge-informed atomistic modeling https://chgnet.lbl.gov
https://doi.org/10.1038/s42256-023-00716-3
Other
220 stars 60 forks source link

Way to extract final total energy and final structure from the result #47

Closed M9JS closed 1 year ago

M9JS commented 1 year ago

Recently I have been using CHGNet for structure optimization for some high throughput screening. I wonder if there is a way to extract the final total energy, which lies at the last line of the output of FIRE optimization. And also, the structure in the form of pymatgen.Structure or Ase.atoms is needed I have wrote some functions for parsing that energy and structure in the output log. But I think it's a low efficient way to do so. Is there any way to get those energy and structure object by calling the attribute?

BowenD-UCB commented 1 year ago

This is shown in the documentation:

from chgnet.model import StructOptimizer

relaxer = StructOptimizer()
result = relaxer.relax(structure)
print("CHGNet relaxed structure", result["final_structure"])
print("relaxed total energy =", result["trajectory"][-1].get_potential_energy())
M9JS commented 1 year ago

Thank you, I have tried to call the total energy by result["trajectory"][-1].get_potential_energy() but failed. I think the right form should be result["trajectory"].energies[-1]) :)

BowenD-UCB commented 1 year ago

Thanks for the correction!