materialsvirtuallab / matgl

Graph deep learning library for materials
BSD 3-Clause "New" or "Revised" License
256 stars 59 forks source link

[Bug]: Data type for ASE potential energy result is not a float #202

Closed Andrew-S-Rosen closed 9 months ago

Andrew-S-Rosen commented 9 months ago

Email (Optional)

No response

Version

0.0.3

Which OS(es) are you using?

What happened?

The calc.results["energy"] property from the M3GNetCalculator should be a float but is a numpy array of length 1. This behavior is not observed in CHGNet, for what it's worth.

Code snippet

import matgl
from matgl.ext.ase import M3GNetCalculator
from ase.build import bulk

atoms = bulk("Cu")
potential = matgl.load_model("M3GNet-MP-2021.2.8-DIRECT-PES")
atoms.calc = M3GNetCalculator(potential)
e = atoms.get_potential_energy() # or atoms.calc.results["energy"]
print(e)

You can compare this with:

from ase.build import bulk
from ase.calculators.emt import EMT

atoms = bulk("Cu")
atoms.calc = EMT()
e = atoms.get_potential_energy()
print(e)

Log output

The output is: 

array(-32.750034, dtype=float32)

Code of Conduct