12. Universal and updatable AIQM models

This tutorial will use the MLatom program.

12.1. Slides

Slides:

12.2. Geometry optimization

We will get started by showcasing the power of ML to supercharge the computational chemistry simulations. We will use the most recent and advanced concept of performing simulations with the universal and updatable AI-enhanced quantum mechanical (UAIQM) models:

Let’s say you want to optimize the molecular geometry. Now you do not need to worry which method (DFT or ab initio, etc.) to choose: MLatom will choose the best model automatically for you.

Example 1.

The input is simple:

UAIQM
geomopt
xyzfile='5

C         0.0000000000        0.0000000000        0.0000000000
H         1.0870000000        0.0000000000        0.0000000000
H        -0.3623333220       -1.0248334322       -0.0000000000
H        -0.3623333220        0.5124167161       -0.8875317869
H        -0.3623333220        0.5124167161        0.8875317869
'

In the output file, you will get the information which UAIQM model was selected:

Selected UAIQM method: uaiqm_gfn2xtbstar@cc
Selected version: 20240106

It is much nicer to use MLaton as a Python package, and Jupyter notebooks make it also easy to use if you do not know Python. The connoisseurs of Python can get much more flexibility when using MLatom. Here is the same example as above, but in Python (uaiqm_geomopt.ipynb), which you can use after you launch the Jupyter Lab on the Aitomistic Lab@XMU.

uaiqm_geomopt

You can check the model’s composition online.

If your molecule happened to be neutral and closed shell and only contain the CHNO elements, UAIQM will give you the CCSD(T)/CBS-level result but at a very fast speed (usually even faster than DFT).

The MLatom output .log file will contain information about the optimization iterations and print out the final optimized geometry, which you can also find in the optgeoms.xyz.

Note that same kind of input works for other, QM and ML, methods, e.g. for DFT:

Example 2.

# example for DFT:
B3LYP/6-31G*
# example for ab initio:
# CCSD(T)/cc-pVDZ
# example for very fast universal ML model (also approaching CCSD(T)/CBS):
# ANI-1ccx
geomopt
xyzfile='5

C         0.0000000000        0.0000000000        0.0000000000
H         1.0870000000        0.0000000000        0.0000000000
H        -0.3623333220       -1.0248334322       -0.0000000000
H        -0.3623333220        0.5124167161       -0.8875317869
H        -0.3623333220        0.5124167161        0.8875317869
'

or in Python:

import mlatom as ml

# Get the initial guess for the molecules to optimize
initmol = ml.data.molecule.from_xyz_string('''5

C         0.0000000000        0.0000000000        0.0000000000
H         1.0870000000        0.0000000000        0.0000000000
H        -0.3623333220       -1.0248334322       -0.0000000000
H        -0.3623333220        0.5124167161       -0.8875317869
H        -0.3623333220        0.5124167161        0.8875317869
''')

# define DFT method
b3lyp = ml.models.methods(method='B3LYP/6-31G*')

# Optimize the geometry with the choosen optimizer:
geomopt = ml.optimize_geometry(model=b3lyp, initial_molecule=initmol, program='geometric')

# Get the final geometry
final_mol = geomopt.optimized_molecule
# and its XYZ coordinates
print('\nOptimized coordinates\n')
print(final_mol.get_xyz_string())

# save the final geometry
final_mol.write_file_with_xyz_coordinates(filename='final.xyz')

# View the molecule
final_mol.view()

You can play with these different options.

Since MLatom is a data-drive package, the optimization trajectory is also saved in the json format, i.e., you will find files like opttraj.json (it is also available in XYZ format for convenience: opttraj.xyz).

For more options on how to use MLatom for geometry optimizations, you can check out the dedicated tutorial. For example, you can use MLatom for the optimization with constraints too.

The power of MLatom is that you can use different ML models to do many types of simulations, including geometry optimization as we will see in the basics of ML.