Compare structure energies#
This notebook gives an example of how to load a .cif
file and calculate the relaxed geometry energy. This can be used to compare the distributions of the energies of the materials from Chemeloen
and CrystaLLM
execute next cell only if you are on google colab
import locale
locale.getpreferredencoding = lambda: "UTF-8"
! pip uninstall torch torchaudio torchvision numpy -y
! uv pip install janus-core[all] data-tutorials torch==2.5.1 --system
get_ipython().kernel.do_shutdown(restart=True)
from janus_core.calculations.geom_opt import GeomOpt
import ase
Use data_tutorials to get the data required for this tutorial:
from data_tutorials.data import get_data
get_data(
url="https://gitlab.com/cam-ml/tutorials/-/raw/main/notebooks/05-generative/chemeleon/",
filename=["generated_structure_0.cif"],
folder="chemeleon",
)
Optimise#
Read in a generated strucrtue and run a BFGS optimisation
device = 'cuda'
#or
#device = "cpu"
mol = ase.io.read('chemeleon/generated_structure_0.cif')
# periodic
opt = GeomOpt(
struct=mol,
arch="mace_mp",
device=device,
model_path="medium-omat-0",
calc_kwargs={"default_dtype": "float64"},
fmax=0.001,
filter_kwargs={"hydrostatic_strain": True},
)
opt.run()
print(opt.struct.get_potential_energy())