Skip to content

Relax a Material with MACE

1. Introduction

Relax the atomic positions of a material with the Atomic Simulation Environment (ASE) and a MACE machine-learned force field (MLFF) foundation model. The relaxation runs in the notebook itself and submits no job; the notebook logs in to load the material from the account and to save the relaxed structure to it.

2. Open the notebook

In JupyterLite, the notebook is made/workflows/local/relaxation_mlff_mace.ipynb, entry 3.2.1 "Pre-relaxation with MLFF (MACE)" of made/workflows/Introduction.ipynb.

3. Set the parameters

Cell 1.2 holds the account and material parameters:

1
2
3
4
5
6
7
# 2. Auth and organization parameters
ORGANIZATION_NAME = None

# 3. Material parameters
FOLDER = "../../uploads"
MATERIAL_NAME = "Silicon"  # used for local/Standata lookup and as platform search term
RELAXED_MATERIAL_NAME = MATERIAL_NAME + " pre-relaxed (MACE)"

FOLDER is ../../uploads, since the notebook is in the local subfolder. MATERIAL_NAME is looked up in FOLDER, then among the account's materials by its exact name. RELAXED_MATERIAL_NAME is the name of the relaxed material. ORGANIZATION_NAME selects the account.

Cell 1.3 holds the relaxation and model parameters:

1
2
3
4
5
6
7
8
9
# Final maximum force on any atom (eV/Å)
FMAX = 0.05

# MACE foundation model family: "MACE-MP-0" for crystals and surfaces, "MACE-OFF23" for molecules
MACE_MODEL_FAMILY = "MACE-MP-0"
MACE_MODEL = "large"  # choose between "small", "medium", and "large"
MACE_DISPERSION = True  # enable D3 dispersion correction for van der Waals interactions
MACE_DEFAULT_DTYPE = "float32"  # floating-point precision for model inference; "float64" is more accurate but slower
MACE_DEVICE = "cpu"  # hardware target: "cpu" or "cuda" (GPU)

FMAX is the maximum force on any atom, in eV/Å, at which the relaxation stops. MACE_MODEL_FAMILY is "MACE-MP-0" for crystals and surfaces or "MACE-OFF23" for molecules, and MACE_MODEL its size. MACE_DISPERSION adds the D3 dispersion correction, and MACE_DEFAULT_DTYPE sets the floating-point precision. The overview explains the model parameters.

4. Run and read the result

Run the notebook with Run > Run All and log in when it asks, as in Authentication in JupyterLite.

Section 4 relaxes the structure with the BFGS optimizer of ASE, plots the energy at each step and prints the final energy. Section 5 shows the structure before and after the relaxation, and section 6 writes the relaxed material to FOLDER with set_materials and saves it to the account.

5. Interactive JupyterLite notebook

The interactive JupyterLite notebook for relaxing a structure with MACE can be accessed below.

Perform Structural Relaxation runs a Density Functional Theory relaxation from the web interface.