Open Metal Detection

In the previous examples, we manually specified the desired adsorption site via the site_idx argument to get_adsorbate(). In practice, it is often desirable to have an automated approach for determining which atom in a MOF is the desired adsorption site. By default, if the user does not specify site_idx, MAI will assume that you want an automated approach for determining this parameter. By default, MAI will attempt to read in the results from the OpenMetalDetector (OMD) code, which can be used to output information about the number, type, and properties of various open metal sites in a set of MOFs. Instructions for using OMD can be found elsewhere, but the main idea is to call OMD prior to calling MAI. An example is shown below for adding an O atom adsorbate to a bunch of MOFs stored in your current working directory.

import os
from omsdetector import MofCollection
from mai.adsorbate_constructor import adsorbate_constructor

mofs_path = 'example_MOFs' #path to folder of CIFs
oms_analysis_folder = os.getcwd() #path to store the OMS results
oms_data_path = os.path.join(oms_analysis_folder,'oms_results') #path to oms_results folder

#Run the Open Metal Detector
mof_coll = MofCollection.from_folder(collection_folder=mofs_path,

#add adsorbate for every CIF in mofs_path
for file in os.listdir(mofs_path):
	if '.cif' not in file:
	mof_path = os.path.join(mofs_path,file)
	ads = adsorbate_constructor(ads='O',d_MX1=1.75)
	new_mof_atoms = ads.get_adsorbate(atoms_path=mof_path,

You can see that this workflow is nearly identical to that in the monatomics tutorial, except we did not specify site_idx in get_adsorbate(), and we ran OMD’s MofCollection.from_folder() command prior to calling MAI’s adsorbate_constructor. Generally, the only arguments you’ll need to provide to MofCollection.from_folder() is the collection_folder and analysis_folder, which is where the CIF files are located and where you’d like to store the OMD results, respectively. Then, you’ll run OMD’s analyse_mofs() command to run the analysis. From there, you’re ready to run MAI as usual! The only new MAI-related keyword is that get_adsorbate() can take an omd_path keyword argument, which should be where the results from the OMD run are stored. This is generally located at analysis_folder/oms_results.