Open In Colab

Geometry Optimization

Set up environment (optional)

These steps are required to run this tutorial with Google Colab. To do so, uncomment and run the cell below.

This will replace pre-installed versions of numpy and torch in Colab with versions that are known to be compatible with janus-core.

It may be possible to skip the steps that uninstall and reinstall torch, which will save a considerable amount of time.

These instructions but may work for other systems too, but it is typically preferable to prepare a virtual environment separately before running this notebook if possible.

[1]:
# import locale
# locale.getpreferredencoding = lambda: "UTF-8"

# ! pip uninstall numpy -y # Uninstall pre-installed numpy

# ! pip uninstall torch torchaudio torchvision transformers -y # Uninstall pre-installed torch
# ! uv pip install torch==2.5.1 # Install pinned version of torch

# ! uv pip install janus-core[mace,sevennet,chgnet,visualise] data-tutorials --system # Install janus-core with MACE, SevenNet, CHGNet, and WeasWidget, and data-tutorials

# get_ipython().kernel.do_shutdown(restart=True) # Restart kernel to update libraries. This may warn that your session has crashed.

To ensure you have the latest version of janus-core installed, compare the output of the following cell to the latest version available at https://pypi.org/project/janus-core/

[2]:
from janus_core import __version__

print(__version__)
0.8.3

Prepare data and modules

[3]:
from ase.io import read
from ase.optimize import FIRE
from weas_widget import WeasWidget

from data_tutorials.data import get_data

from janus_core.calculations.single_point import SinglePoint
from janus_core.calculations.geom_opt import GeomOpt

Use data_tutorials to get the data required for this tutorial:

[4]:
get_data(
    url="https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/",
    filename=["NaCl-deformed.xyz"],
    folder="data",
)
try to download NaCl-deformed.xyz from https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/ and save it in data/NaCl-deformed.xyz
saved in data/NaCl-deformed.xyz

Prepare for optimization of a deformed salt structure

[5]:
NaCl = read("data/NaCl-deformed.xyz")
NaCl.wrap()
v=WeasWidget()
v.from_ase(NaCl)
v.avr.model_style = 1
v.avr.show_hydrogen_bonds = True
v
[5]:
[6]:
sp_mace = SinglePoint(
    struct=NaCl.copy(),
    arch="mace_mp",
    device="cpu",
    model="small",
    calc_kwargs={"default_dtype": "float64"},
    properties="energy",
)

init_energy = sp_mace.run()["energy"]
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/e3nn/o3/_wigner.py:10: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  _Jd, _W3j_flat, _W3j_indices = torch.load(os.path.join(os.path.dirname(__file__), 'constants.pt'))
cuequivariance or cuequivariance_torch is not available. Cuequivariance acceleration will be disabled.
Using Materials Project MACE for MACECalculator with /home/runner/.cache/mace/20231210mace128L0_energy_epoch249model
Using float64 for MACECalculator, which is slower but more accurate. Recommended for geometry optimization.
Using head Default out of ['Default']
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/mace/calculators/mace.py:143: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  torch.load(f=model_path, map_location=device)

To optimize only the atomic positions and not the cell, set filter_class = None:

[7]:
optimized_NaCl = GeomOpt(
    struct=sp_mace.struct,
    fmax=0.001,
    filter_class=None,
)

optimized_NaCl.run()
v=WeasWidget()
v.from_ase(optimized_NaCl.struct)
v.avr.model_style = 1
v.avr.show_hydrogen_bonds = True
v
       Step     Time          Energy          fmax
LBFGS:    0 11:33:52      -24.377063        2.732337
LBFGS:    1 11:33:52      -24.576368        2.152513
LBFGS:    2 11:33:52      -25.093690        0.949845
LBFGS:    3 11:33:52      -25.290212        0.685740
LBFGS:    4 11:33:52      -25.403788        0.951695
LBFGS:    5 11:33:52      -25.465213        1.066671
LBFGS:    6 11:33:52      -25.566446        1.095941
LBFGS:    7 11:33:53      -25.695050        0.931041
LBFGS:    8 11:33:53      -25.856683        0.857034
LBFGS:    9 11:33:53      -26.109079        0.811033
LBFGS:   10 11:33:53      -26.298823        0.545193
LBFGS:   11 11:33:53      -26.353032        0.656387
LBFGS:   12 11:33:53      -26.383904        0.710488
LBFGS:   13 11:33:53      -26.485793        0.790107
LBFGS:   14 11:33:53      -26.643853        0.768081
LBFGS:   15 11:33:53      -26.751857        0.477356
LBFGS:   16 11:33:53      -26.792940        0.329784
LBFGS:   17 11:33:53      -26.815123        0.343673
LBFGS:   18 11:33:53      -26.829194        0.334430
LBFGS:   19 11:33:53      -26.845943        0.317718
LBFGS:   20 11:33:53      -26.912307        0.249075
LBFGS:   21 11:33:53      -26.975682        0.229256
LBFGS:   22 11:33:53      -27.018210        0.150833
LBFGS:   23 11:33:53      -27.023510        0.093603
LBFGS:   24 11:33:53      -27.024214        0.075937
LBFGS:   25 11:33:53      -27.025149        0.061405
LBFGS:   26 11:33:53      -27.026800        0.051912
LBFGS:   27 11:33:53      -27.028754        0.038049
LBFGS:   28 11:33:53      -27.029848        0.016211
LBFGS:   29 11:33:53      -27.030067        0.005215
LBFGS:   30 11:33:53      -27.030081        0.000579
[7]:

Check energy has been lowered, and cell is unchanged:

[8]:
print(f"Initial cell: {NaCl.cell.cellpar()}")
print(f"Initial energy: {init_energy}")

print(f"Final cell: {optimized_NaCl.struct.cell.cellpar()}")
print(f"Final energy: {optimized_NaCl.struct.get_potential_energy()}")
Initial cell: [ 5.63  5.63  5.63 90.   90.   90.  ]
Initial energy: -24.377062746436568
Final cell: [ 5.63  5.63  5.63 90.   90.   90.  ]
Final energy: -27.030081292879448

Optimizing cell vectors and atomic positions

Setting filter_kwargs = {"hydrostatic_strain": True} allows the cell lengths to be changed, in addition to atomic positions, but cell angles remain fixed:

[9]:
optimized_NaCl_lengths = GeomOpt(
    struct=NaCl.copy(),
    arch="mace_mp",
    device="cpu",
    model="small",
    calc_kwargs={"default_dtype": "float64"},
    fmax=0.001,
    filter_kwargs={"hydrostatic_strain": True},
)
optimized_NaCl_lengths.run()
Using Materials Project MACE for MACECalculator with /home/runner/.cache/mace/20231210mace128L0_energy_epoch249model
Using float64 for MACECalculator, which is slower but more accurate. Recommended for geometry optimization.
Using head Default out of ['Default']
       Step     Time          Energy          fmax
LBFGS:    0 11:33:54      -24.377063        2.732337
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/mace/calculators/mace.py:143: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  torch.load(f=model_path, map_location=device)
LBFGS:    1 11:33:54      -24.593123        2.143240
LBFGS:    2 11:33:54      -25.178180        0.955170
LBFGS:    3 11:33:54      -25.445502        0.670912
LBFGS:    4 11:33:54      -25.641907        0.919610
LBFGS:    5 11:33:54      -25.735611        1.036999
LBFGS:    6 11:33:54      -25.816918        1.015167
LBFGS:    7 11:33:54      -25.937123        0.774473
LBFGS:    8 11:33:54      -26.075553        0.561448
LBFGS:    9 11:33:54      -26.194652        0.423668
LBFGS:   10 11:33:54      -26.290628        0.391005
LBFGS:   11 11:33:54      -26.323319        0.439570
LBFGS:   12 11:33:54      -26.337274        0.452690
LBFGS:   13 11:33:54      -26.372755        0.457902
LBFGS:   14 11:33:55      -26.436676        0.640085
LBFGS:   15 11:33:55      -26.522182        0.786499
LBFGS:   16 11:33:55      -26.636096        0.839171
LBFGS:   17 11:33:55      -26.785166        0.746960
LBFGS:   18 11:33:55      -26.953112        0.390060
LBFGS:   19 11:33:55      -27.019414        0.155454
LBFGS:   20 11:33:55      -27.024708        0.104189
LBFGS:   21 11:33:55      -27.025735        0.100499
LBFGS:   22 11:33:55      -27.040218        0.057352
LBFGS:   23 11:33:55      -27.043130        0.040815
LBFGS:   24 11:33:55      -27.043931        0.043724
LBFGS:   25 11:33:55      -27.044043        0.046083
LBFGS:   26 11:33:55      -27.044456        0.047834
LBFGS:   27 11:33:55      -27.045052        0.042667
LBFGS:   28 11:33:55      -27.045824        0.025832
LBFGS:   29 11:33:55      -27.046215        0.014974
LBFGS:   30 11:33:56      -27.046303        0.010039
LBFGS:   31 11:33:56      -27.046314        0.008152
LBFGS:   32 11:33:56      -27.046320        0.006968
LBFGS:   33 11:33:56      -27.046335        0.004495
LBFGS:   34 11:33:56      -27.046350        0.003398
LBFGS:   35 11:33:56      -27.046360        0.001411
LBFGS:   36 11:33:56      -27.046362        0.000409

Check energy has been lowered, and cell lengths have been updated, but angles remain unchanged:

[10]:
print(f"Initial cell: {NaCl.cell.cellpar()}")
print(f"Initial energy: {init_energy}")

print(f"Final cell: {optimized_NaCl_lengths.struct.cell.cellpar()}")
print(f"Final energy: {optimized_NaCl_lengths.struct.get_potential_energy()}")
Initial cell: [ 5.63  5.63  5.63 90.   90.   90.  ]
Initial energy: -24.377062746436568
Final cell: [ 5.6899881  5.6899881  5.6899881 90.        90.        90.       ]
Final energy: -27.046361869183738

Optimizing at constant pressure and volume

Calculations can also be run at a fixed pressure and volume, by setting filter_kwargs = {"scalar_pressure": x, "constant_volume": True}

By default, both the cell lengths and angles will be optimized, in addition to the atomic positions.

We can also set the optimizer and filter class used, either by passing the function itself (e.g. FIRE) or passing the name of the ASE function (e.g. "ExpCellFilter"):

[11]:
optimized_NaCl_pressure = GeomOpt(
    struct=NaCl.copy(),
    arch="mace_mp",
    device="cpu",
    model="small",
    calc_kwargs={"default_dtype": "float64"},
    fmax=0.01,
    filter_kwargs={"scalar_pressure": 0.05, "constant_volume": True},
    optimizer=FIRE,
    filter_class="ExpCellFilter",
)
optimized_NaCl_pressure.run()
Using Materials Project MACE for MACECalculator with /home/runner/.cache/mace/20231210mace128L0_energy_epoch249model
Using float64 for MACECalculator, which is slower but more accurate. Recommended for geometry optimization.
Using head Default out of ['Default']
      Step     Time          Energy          fmax
FIRE:    0 11:33:56      -24.321372        2.732337
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/mace/calculators/mace.py:143: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  torch.load(f=model_path, map_location=device)
FIRE:    1 11:33:56      -24.475808        2.425259
FIRE:    2 11:33:56      -24.724546        1.986743
FIRE:    3 11:33:57      -24.989394        1.591361
FIRE:    4 11:33:57      -25.210859        1.296455
FIRE:    5 11:33:57      -25.366900        1.075710
FIRE:    6 11:33:57      -25.474543        0.903170
FIRE:    7 11:33:57      -25.563058        0.768084
FIRE:    8 11:33:57      -25.665958        0.788916
FIRE:    9 11:33:57      -25.804701        0.776696
FIRE:   10 11:33:57      -25.988476        0.629292
FIRE:   11 11:33:57      -26.185598        0.524310
FIRE:   12 11:33:58      -26.372697        0.544405
FIRE:   13 11:33:58      -26.529609        0.549348
FIRE:   14 11:33:58      -26.651271        0.500647
FIRE:   15 11:33:58      -26.733248        0.625696
FIRE:   16 11:33:58      -26.759626        0.705539
FIRE:   17 11:33:58      -26.768425        0.680857
FIRE:   18 11:33:58      -26.784768        0.633003
FIRE:   19 11:33:58      -26.806559        0.564653
FIRE:   20 11:33:58      -26.831285        0.478909
FIRE:   21 11:33:59      -26.856128        0.378669
FIRE:   22 11:33:59      -26.878203        0.266994
FIRE:   23 11:33:59      -26.895576        0.173920
FIRE:   24 11:33:59      -26.909428        0.195730
FIRE:   25 11:33:59      -26.920433        0.206251
FIRE:   26 11:33:59      -26.930828        0.201829
FIRE:   27 11:33:59      -26.943629        0.195696
FIRE:   28 11:33:59      -26.958594        0.174490
FIRE:   29 11:33:59      -26.970475        0.100623
FIRE:   30 11:33:59      -26.970442        0.055335
FIRE:   31 11:33:59      -26.970688        0.053585
FIRE:   32 11:34:00      -26.971042        0.050145
FIRE:   33 11:34:00      -26.971388        0.045125
FIRE:   34 11:34:00      -26.971749        0.038836
FIRE:   35 11:34:00      -26.972173        0.034034
FIRE:   36 11:34:00      -26.972587        0.024280
FIRE:   37 11:34:00      -26.972874        0.026451
FIRE:   38 11:34:00      -26.973086        0.031830
FIRE:   39 11:34:00      -26.973328        0.035290
FIRE:   40 11:34:00      -26.973544        0.035381
FIRE:   41 11:34:01      -26.973728        0.030713
FIRE:   42 11:34:01      -26.974006        0.021361
FIRE:   43 11:34:01      -26.974169        0.026135
FIRE:   44 11:34:01      -26.974266        0.009379

Check cell lengths and angles have both been updated:

[12]:
print(f"Initial cell: {NaCl.cell.cellpar()}")
print(f"Initial energy: {init_energy}")

print(f"Final cell: {optimized_NaCl_pressure.struct.cell.cellpar()}")
print(f"Final energy: {optimized_NaCl_pressure.struct.get_potential_energy()}")
Initial cell: [ 5.63  5.63  5.63 90.   90.   90.  ]
Initial energy: -24.377062746436568
Final cell: [ 5.63000038  5.63000038  5.63000038 90.0297029  90.0297029  90.0297029 ]
Final energy: -27.029956730994684

Comparing MACE to CHGNet and SevenNet

[13]:
optimized_NaCl_mace = GeomOpt(
    struct=NaCl.copy(),
    arch="mace_mp",
    device="cpu",
    model="small",
    calc_kwargs={"default_dtype": "float64"},
    fmax=0.01,
)
optimized_NaCl_mace.run()

optimized_NaCl_chgnet = GeomOpt(
    struct=NaCl.copy(),
    arch="chgnet",
    device="cpu",
    calc_kwargs={"default_dtype": "float64"},
    fmax=0.01,
)
optimized_NaCl_chgnet.run()

optimized_NaCl_sevennet = GeomOpt(
    struct=NaCl.copy(),
    arch="sevennet",
    device="cpu",
    calc_kwargs={"default_dtype": "float64"},
    fmax=0.01,
)
optimized_NaCl_sevennet.run()
Using Materials Project MACE for MACECalculator with /home/runner/.cache/mace/20231210mace128L0_energy_epoch249model
Using float64 for MACECalculator, which is slower but more accurate. Recommended for geometry optimization.
Using head Default out of ['Default']
       Step     Time          Energy          fmax
LBFGS:    0 11:34:01      -24.377063        2.732337
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/mace/calculators/mace.py:143: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  torch.load(f=model_path, map_location=device)
LBFGS:    1 11:34:01      -24.593440        2.145517
LBFGS:    2 11:34:01      -25.187807        0.956555
LBFGS:    3 11:34:01      -25.462335        0.675018
LBFGS:    4 11:34:01      -25.663853        0.932226
LBFGS:    5 11:34:02      -25.757785        1.056063
LBFGS:    6 11:34:02      -25.841303        1.038396
LBFGS:    7 11:34:02      -25.968290        0.806821
LBFGS:    8 11:34:02      -26.115858        0.539264
LBFGS:    9 11:34:02      -26.230485        0.404401
LBFGS:   10 11:34:02      -26.323082        0.351277
LBFGS:   11 11:34:02      -26.354901        0.404205
LBFGS:   12 11:34:02      -26.366593        0.418519
LBFGS:   13 11:34:02      -26.402172        0.433457
LBFGS:   14 11:34:02      -26.468589        0.596828
LBFGS:   15 11:34:02      -26.555830        0.733795
LBFGS:   16 11:34:02      -26.664503        0.782841
LBFGS:   17 11:34:02      -26.800773        0.695400
LBFGS:   18 11:34:02      -26.945555        0.318072
LBFGS:   19 11:34:02      -26.988824        0.103903
LBFGS:   20 11:34:02      -26.991370        0.096582
LBFGS:   21 11:34:02      -26.992831        0.094488
LBFGS:   22 11:34:03      -27.005617        0.089660
LBFGS:   23 11:34:03      -27.016434        0.131020
LBFGS:   24 11:34:03      -27.024799        0.125041
LBFGS:   25 11:34:03      -27.027461        0.088453
LBFGS:   26 11:34:03      -27.028315        0.072906
LBFGS:   27 11:34:03      -27.029306        0.076504
LBFGS:   28 11:34:03      -27.031938        0.077353
LBFGS:   29 11:34:03      -27.036130        0.065283
LBFGS:   30 11:34:03      -27.040555        0.072759
LBFGS:   31 11:34:03      -27.042541        0.055032
LBFGS:   32 11:34:03      -27.042957        0.032514
LBFGS:   33 11:34:03      -27.043064        0.029534
LBFGS:   34 11:34:03      -27.043288        0.029905
LBFGS:   35 11:34:03      -27.043771        0.028507
LBFGS:   36 11:34:03      -27.044653        0.023671
LBFGS:   37 11:34:03      -27.045667        0.028947
LBFGS:   38 11:34:04      -27.046214        0.014389
LBFGS:   39 11:34:04      -27.046318        0.007933
CHGNet v0.3.0 initialized with 412,525 parameters
CHGNet will run on cpu
       Step     Time          Energy          fmax
LBFGS:    0 11:34:05      -26.927519        2.412753
LBFGS:    1 11:34:05      -27.131771        1.918886
LBFGS:    2 11:34:05      -27.805649        0.565097
LBFGS:    3 11:34:05      -27.966398        0.791138
LBFGS:    4 11:34:05      -28.067211        1.082411
LBFGS:    5 11:34:05      -28.132513        1.174295
LBFGS:    6 11:34:05      -28.220078        1.044148
LBFGS:    7 11:34:05      -28.391468        0.548103
LBFGS:    8 11:34:05      -28.461401        0.419202
LBFGS:    9 11:34:05      -28.516052        0.275543
LBFGS:   10 11:34:05      -28.557796        0.262427
LBFGS:   11 11:34:05      -28.571011        0.290122
LBFGS:   12 11:34:05      -28.575558        0.297268
LBFGS:   13 11:34:05      -28.598139        0.317091
LBFGS:   14 11:34:05      -28.643253        0.323920
LBFGS:   15 11:34:05      -28.681047        0.465958
LBFGS:   16 11:34:05      -28.747162        0.497072
LBFGS:   17 11:34:05      -28.953316        0.500068
LBFGS:   18 11:34:05      -29.102654        0.429938
LBFGS:   19 11:34:05      -29.193975        0.207444
LBFGS:   20 11:34:05      -29.201221        0.186242
LBFGS:   21 11:34:06      -29.204500        0.160758
LBFGS:   22 11:34:06      -29.213327        0.181559
LBFGS:   23 11:34:06      -29.232643        0.228825
LBFGS:   24 11:34:06      -29.254860        0.194387
LBFGS:   25 11:34:06      -29.271729        0.120708
LBFGS:   26 11:34:06      -29.275753        0.104396
LBFGS:   27 11:34:06      -29.277836        0.117950
LBFGS:   28 11:34:06      -29.279495        0.115821
LBFGS:   29 11:34:06      -29.297962        0.096791
LBFGS:   30 11:34:06      -29.315012        0.082800
LBFGS:   31 11:34:06      -29.322977        0.075059
LBFGS:   32 11:34:06      -29.327665        0.054058
LBFGS:   33 11:34:06      -29.328333        0.050119
LBFGS:   34 11:34:06      -29.328659        0.049821
LBFGS:   35 11:34:06      -29.328373        0.050221
LBFGS:   36 11:34:06      -29.330223        0.044649
LBFGS:   37 11:34:06      -29.331551        0.044669
LBFGS:   38 11:34:06      -29.336990        0.035605
LBFGS:   39 11:34:06      -29.338936        0.051967
LBFGS:   40 11:34:06      -29.340191        0.031557
LBFGS:   41 11:34:06      -29.340641        0.031069
LBFGS:   42 11:34:07      -29.340767        0.031150
LBFGS:   43 11:34:07      -29.341061        0.030953
LBFGS:   44 11:34:07      -29.341702        0.027996
LBFGS:   45 11:34:07      -29.342655        0.022796
LBFGS:   46 11:34:07      -29.343447        0.014846
LBFGS:   47 11:34:07      -29.343800        0.005520
       Step     Time          Energy          fmax
LBFGS:    0 11:34:09      -24.363150        2.480490
LBFGS:    1 11:34:09      -24.564611        2.017852
LBFGS:    2 11:34:10      -25.182961        0.873339
LBFGS:    3 11:34:10      -25.402287        0.900135
LBFGS:    4 11:34:10      -25.539955        1.111846
LBFGS:    5 11:34:10      -25.654858        1.157828
LBFGS:    6 11:34:10      -25.767794        1.072121
LBFGS:    7 11:34:10      -25.878130        0.796773
LBFGS:    8 11:34:10      -26.012154        0.622276
LBFGS:    9 11:34:10      -26.166079        0.481378
LBFGS:   10 11:34:10      -26.271954        0.431494
LBFGS:   11 11:34:10      -26.301947        0.473225
LBFGS:   12 11:34:10      -26.320889        0.471760
LBFGS:   13 11:34:10      -26.364386        0.519019
LBFGS:   14 11:34:10      -26.440050        0.649182
LBFGS:   15 11:34:11      -26.534296        0.699947
LBFGS:   16 11:34:11      -26.655691        0.643782
LBFGS:   17 11:34:11      -26.800640        0.419270
LBFGS:   18 11:34:11      -26.893867        0.346006
LBFGS:   19 11:34:11      -26.911108        0.345064
LBFGS:   20 11:34:11      -26.920212        0.330304
LBFGS:   21 11:34:11      -27.020151        0.174307
LBFGS:   22 11:34:11      -27.035942        0.079712
LBFGS:   23 11:34:11      -27.038519        0.078538
LBFGS:   24 11:34:11      -27.039204        0.078125
LBFGS:   25 11:34:11      -27.045210        0.072798
LBFGS:   26 11:34:11      -27.051525        0.064373
LBFGS:   27 11:34:11      -27.057703        0.073462
LBFGS:   28 11:34:12      -27.059959        0.059883
LBFGS:   29 11:34:12      -27.060661        0.056062
LBFGS:   30 11:34:12      -27.061205        0.055570
LBFGS:   31 11:34:12      -27.062958        0.050588
LBFGS:   32 11:34:12      -27.065674        0.052724
LBFGS:   33 11:34:12      -27.068825        0.045018
LBFGS:   34 11:34:12      -27.070379        0.032039
LBFGS:   35 11:34:12      -27.070698        0.019584
LBFGS:   36 11:34:12      -27.070744        0.015365
LBFGS:   37 11:34:12      -27.070801        0.014363
LBFGS:   38 11:34:12      -27.070938        0.012267
LBFGS:   39 11:34:12      -27.071184        0.011225
LBFGS:   40 11:34:12      -27.071474        0.009584
[14]:
print(f"Initial energy: {init_energy}")

print(f"Final energy (MACE): {optimized_NaCl_mace.struct.get_potential_energy()}")
print(f"Final energy (CHGNet): {optimized_NaCl_chgnet.struct.get_potential_energy()}")
print(f"Final energy (SevenNet): {optimized_NaCl_sevennet.struct.get_potential_energy()}")
Initial energy: -24.377062746436568
Final energy (MACE): -27.046318223074792
Final energy (CHGNet): -29.343799591064453
Final energy (SevenNet): -27.071474075317383