AuToGraFS Examples#
The following examples are compatible with all calculators within the
Amsterdam Modeling Suite. Any Python script utilizing these libraries
should be executed using the $AMSBIN/amspython binary, for example
$AMSBIN/amspython code.py or amspython code.py where code.py
is a Python file containing your code.
These examples illustrate the construction of various metal-organic frameworks (MOFs) using their secondary building units and Reticular Chemistry Structure Resource (RCSR) topological codes. They are specifically designed to work with the version of AuToGraFS included in SCM.
Simplest approach#
We will construct the structures of MOF-5 and UIO66 using two different approaches. In AuToGraFS, you have the option to build a MOF using secondary building units from the default database or by supplying your own building units. We will employ both approaches to give users greater autonomy in constructing their MOFs.
1.1 Using default database#
In SCM, there are two default databases available for AuToGraFS. The
first database comprises approximately 82 secondary building units and
serves as the default path for AuToGraFS. You can directly access this
path from amshome/atomicdata/autografs/database. The following
scripts offer the simplest method for constructing any MOF.
#MOF-5/IRMOF-1
import os
from scm.autografs import autografs, framework
from scm.autografs.utils import sbu
# Initialize the model generator
mofgen = autografs.Autografs(sbu_path=None)
# The secondary building units should be provided as a list.
sbu_names = ["Benzene_linear", "Zn_mof5_octahedral"]
topology_name = "pcu"
mof = mofgen.make(topology_name=topology_name, sbu_names=sbu_names)
# The MOF generated can be viewed directly using the ASE visualizer as follows
mof.view()
# You can also choose to write the mof to a gin (GULP) input file or any ASE input format.
# Writing to .gin
mof.write('MOF-5', 'gin')
# Writing to cif
mof.write('MOF-5', 'cif')
Checking list of secondary building units in the default database and topologies#
You can quickly access the secondary building units in the default
database with the following command: mofgen.sbu. Additionally, the
topologies can be accessed as follows: mofgen.topologies.
1.2 Using same default database as the GUI#
The GUI utilizes an updated database containing 1237 organic secondary building
units and 639 metal secondary building
units that are shipped with SCM. This data can be found in
~/.scm_gui/autografs/default after the first time the GUI is used to
build a MOF. The database can also be manually extracted from
$AMSHOME/atomicdata/autografs/database/database.tar.gz into there.
Custom-built secondary building units from the GUI are stored in
~/.scm_gui/autografs/custom. In the updated version, organic SBUs can
also be searched using their IUPAC names. The X in an SBU name
corresponds to dummy atoms, and the trailing number indicates how many
dummy atoms are present in the building unit. This is the quickest way
to determine the number of connection points, or the coordination
number, of the building unit. We can leverage the GUI default database
as follows:
import os
sbu_path = os.path.join(os.path.expanduser("~"), ".scm_gui", "autografs", 'default')
mofgen = autografs.Autografs(sbu_path=sbu_path)
print(len(mofgen.sbu_data))
#IRMOF-3
sbu_names = ["Bis_phenylethynylbenzene_linear", "Zn_mof5_octahedral"]
topology_name = 'acs'
mof = mofgen.make(topology_name=topology_name, sbu_names=sbu_names)
mof.view()
#UIO-66
sbu_names = ["UIO66_Zr_icosahedral", "Benzene_linear"]
topology_name = 'fcu'
mof = mofgen.make(topology_name=topology_name, sbu_names=sbu_names)
mof.view()
mof.write('UIO66', 'cif')
1.3 User defined data#
Users can create their own secondary building units (SBUs) in an
.xyz format by defining points of extension using a dummy atom
(X). To generate an SBU in XYZ format, follow these steps:
Identify Points of Extension
These are the atoms where the SBU should connect to other building blocks.
For benzene dicarboxylate, the extension points are the carboxyl groups.
Modify the Molecular Structure
Remove the two oxygen atoms from the carboxyl groups.
Replace the carbon atoms (previously bonded to these oxygens) with a dummy atom (``X``).
Save the Modified Structure
Ensure the XYZ file format is preserved.
The file should be saved in a dedicated folder for easy retrieval.
Example: Benzene Dicarboxylate#
# Assuming that the files are stored in a folder called ``./test_data``
path_to_file = "./test_data"
mofgen = autografs.Autografs(update=True, sbu_path=path_to_file, use_defaults=True)
topology_name = "pcu"
# Assuming that ``2_7-dipyridin-4-ylfluoren-9-one_X2`` and
# ``Zn_irmof_sbu_X6`` are found in the test_data folder
sbu_names = ["2_7-dipyridin-4-ylfluoren-9-one_X2", "Zn_irmof_sbu_X6"]
mof = mofgen.make(topology_name=topology_name, sbu_names=sbu_names)
# mof.write('new_mof', 'cif')
1.4 Finding suitable topologies for a given set of SBUs#
One common problem often revolves around determining which topologies would be suitable for a given set of building units. This situation becomes particularly intriguing when you’ve synthesized a new MOF and possess knowledge of the building units used, but are not sure of the precise structure. Identifying the range of available topologies can facilitate the construction of all potential MOFs stemming from these building units. The PXRD from these hypothetical structures can then be compared with the experimental diffraction patterns to infer the structure of the synthesized MOF. The following example provides a straightforward illustration, which can be adapted to more complex systems.
mofgen = autografs.Autografs()
print(mofgen.sbu_data)
sbu_names = ["Pyrene_linear", "Zn_mof5_octahedral"]
list_of_available_topologies = mofgen.list_available_topologies(from_list=sbu_names)
print(list_of_available_topologies)
for idx, topology_name in enumerate(list_of_available_topologies[:10]):
try:
mofgen.set_topology(topology_name=topology_name)
print(topology_name)
mof = mofgen.make(sbu_names=sbu_names)
mof.view()
mof.write(topology_name, 'cif')
except Exception:
pass
1.5 Finding available building units for a given topology#
Similarly, one may be interested in finding possible building units that can be used to construct a MOF with a specific topology. This becomes valuable when investigating stability or conducting studies on isoreticular MOFs, where one aims to analyze the properties of a given topology. In such cases, it is essential to construct hypothetical MOFs based on a specified topology.
mofgen = autografs.Autografs()
topology_name = 'acs'
available_sbus = mofgen.list_available_sbu(topology_name=topology_name, coercion=True)
print (available_sbus)
selected_sbu = ['Al_trimeric_prism', 'Acetylene_linear']
make(topology_name=topology_name, sbu_names=selected_sbu)
mof.view()
N.B#
There are a few important things to note regarding the following line of
code:
available_sbus = molgen.list_available_sbu(topology_name=topology_name, coercion=True)
i. Coercion#
When setting coercion to True, AutoGraFS is compelled
to match only SBUs that can combine based on their number of points of
extension/ number of dummies/coordination number of SBUs. This feature
is beneficial as it ensures a strong likelihood of building a MOF by
combining outputs from available_sbus.
ii. available_sbus#
The available_sbus is a dictionary with keys represented as tuples.
It is crucial to use items from different keys as centers and linkers.
For instance:
available_sbus = {(0, 1): ['Al_trimeric_prism', 'Benzene_hexagonal', 'H6BHEHPI_Yaghi_hexagonal', 'Persulfurated_benzene_hexagonal', 'ReS_cluster_octahedral', 'Zn_mof5_octahedral', 'Zn_octahedral_paddlewheel'], (14, 15, 16, 17, 18, 19): ['Acetylene_linear', 'Benzene_linear', 'Benzil_linear', 'Benzo_bis_dioxaborole_linear', 'Benzodithiophene_linear', 'Benzothiadiazole_linear', 'Betabinaphtol_linear', 'Bicyclooctane_linear', 'Biphenyl_linear', 'Bipyridine_linear', 'Bis_phenylethynylbenzene_linear', 'Butane_linear', 'Chrysene_linear', 'Cubane_linear', 'DCDPBN_Yaghi_linear', 'DPMDBDA_linear', 'Decapentene', 'Diethinylbenzene_linear', 'Diphenylbutadiyne_linear', 'Diphenylperylimide_linear', 'Fluorenone_linear', 'H4DH11PhDC_Yaghi_linear', 'H4DH9PhDC_Yaghi_linear', 'Naphtalene_linear', 'Pentaphenyl_linear', 'Peropyrene_linear', 'Phenazine_linear', 'Phenylethynylbenzene_linear', 'Pyrene_linear', 'Stilbene_linear', 'Tetracene_linear', 'Tetraphenyl_linear', 'Thienothiophene_linear', 'Triphenyl_linear', 'Zn_porphyrin_linear']}
key = (0, 1) Items listed here represent the center nodes or
centers.
key = (14, 15, 16, 17, 18, 19) Items listed here should be used as
linkers.
For example, incorrect usage like:
sbu_names != ['Al_trimeric_prism', 'Benzene_hexagonal'] will cause
the code to fail.
Instead, one should select items from different keys, such as:
sbu_names = ['Al_trimeric_prism', 'Benzo_bis_dioxaborole_linear']
or
sbu_names = ['Benzene_hexagonal', 'DPMDBDA_linear'] note that this
will build a COF instead of a MOF.
1.6 Finding available frameworks#
Another useful function is to find all available frameworks for a given
topology. This is especially valuable when building a series of
hypothetical MOFs for a specific topology or multiple topologies. In
this case, the list_available_frameworks function is useful for
providing a dictionary-style dataset, which can be used to automate the
construction of the hypothetical database.
list_available_frameworks = mofgen.list_available_frameworks(topology_name='ats', coercion=True)
print (list_available_frameworks)
for i, frameworks in enumerate(list_available_frameworks[:5]):
mof = mofgen.make(topology_name='ats', sbu_dict=frameworks)
mof.write(f'atc_{1}' 'gin')
Making SURMOFs#
Surface Mounted Metal-Organic Frameworks are a class of materials that combine organic linkers and metal ions or clusters to form highly porous structures. SURMOFs are unique because they can be grown as thin films directly on substrates, allowing for their integration into various devices and applications.
Simply put, these are pillared MOFs that are horizontally linked with a
given linker and vertically linked with another linker. The following
examples can be used to generate all possible SURMOFs for a list of
available SBUs present in the default database. N.B. Note that
SURMOFs generally adopt the pcu topology.
mofgen = autografs.Autografs()
# get all available linkers, center, pillars for the pcu topology
topology_name = "pcu"
all_sbus = mofgen.list_available_sbu(topology_name=topology_name)
center_key, linker_key = list(all_sbus.keys())
centers = all_sbus[center_key]
print(centers)
linkers = all_sbus[linker_key]
print(linkers)
for node in centers:
for i in range(len(linkers)-1):
for j in range(1, len(linkers)):
linker = linkers[i]
pillar = linkers[j]
if linker != pillar:
sbu_names = [node, (linker, 1), (pillar, 1)]
framework = mofgen.make(topology_name=topology_name, sbu_names=sbu_names)
surmof_name = 'node-linker-pillar'
framework.write(surmof_name, 'gin')
Functionalization#
It is common to want to functionalize a specific site in a MOF. This can
be easily achieved using the list_functionalizable_sites and
functionalize functions. 1. The list_functionalizable_sites function
identifies functionalizable sites in a MOF. By default, it searches for
hydrogen atoms, but you can specify other atomic symbols if needed. 2.
You can also choose to functionalize a specific SBU by providing its
name as an argument. By default, the function searches for
functionalizable sites throughout the entire MOF.
path_to_file = "./test_data"
mofgen = autografs.Autografs(update=True, sbu_path=path_to_file, use_defaults=True )
topology_name = "pcu"
# We purposely build a pillar MOF with two linkers so as to illustrates all functionalities
sbu_names = ["Zn_irmof_sbu_X6", ("2_7-dipyridin-4-ylfluoren-9-one_X2", 1), ("bis1_2_4-triazol-4-yldiazene_X2", 1)]
mof = mofgen.make(topology_name='pcu' ,sbu_names=sbu_names, coercion=False)
mof.view()
# Now find the list of all functionalizable sites. If no argument are givens, it will by default search for all hydrogen on all the SBUs.
list_functionalizable_sites = mof.list_functionalizable_sites()
print(list_functionalizable_sites)
The output is a list of tuples where the first element in each tuple represents the SBU, and the second element represents the atom index of the atom to be substituted in the building unit.
# It is also possible to parse symbols of atoms to functionalise as well as the SBU to functionalized.
list_functionalizable_sites_1 = mof.list_functionalizable_sites(symbol=['O'])
list_functionalizable_sites_2 = mof.list_functionalizable_sites(sbu_names=['2_7-dipyridin-4-ylfluoren-9-one_X2'])
print ('functionaliseable oxygen atoms:', list_functionalizable_sites_1 )
print ("2_7-dipyridin-4-ylfluoren-9-one_X2 functionalisable sites",list_functionalizable_sites_2)
Now let us try to functionalize a random hydrogen with a pyridine. Note
that we created a pyridine file using the discription above and we have
it in the folder ./test_data.
NB#
Note that in the new database, we have a series of data with X1.
These are molecules that can easily be used for functionalization.
Moreover, it is important to note that the number after X refers to
the number of points of extension (coordination number) of the
building unit..
# check the sbu in
print (mofgen.sbu_data)
fg = mofgen.sbu_data['pyridine_X1'].atoms
mof.functionalize(where=(9, 6),fg=fg)
mof.view()
FAQs#
I have updated the data in my database, but AuToGraFs is not recognizing it. I get a KeyError or still see only the previous data when I run
mofgen.sbu_data.This issue arises because when you load a new dataset, a cache is created to prevent redundancy, which ensures that the data is not reloaded every time you generate a new MOF. The simplest solution is to delete the
sbu.pklfile located in your database folder.For example, if your XYZ files are stored in a folder called data_folder, you can remove the cache by running:
rm data_folder/sbu.pklThen, reinitialize AuToGraFs with:
mofgen = autografs.Autografs(sbu_path=data_folder)After creating a new MOF and saving it as a cif? The building units apears disconnected.
The
mofgen.makefunction creates new MOFs by identifying a topology and then generating slots where building units are aligned and fitted. However, AuToGraFs does not directly optimse the structure but it keeps track of the points of connections and stores this information in a bond matrix.To properly optimize the structure, you should write your new MOF in a
.ginfile format, which is a GULP-compatible format. Then run the following command to optimize the structure and generate a new .cif file containing the optimized MOF:gulp < mof.gin > mof.gotEnsure that you have GULP installed. You can download it from
https://gulp.curtin.edu.au/download.html. When building the MOF using the GUI, this problem is automatically resolved, as the GUI performs the optimization during the process.Have building units and topologies that are known to form a MOF, but I get a KeyError when I run
mofgen.makeThere are several reasons why this may happen. The most common issue arises from symmetry operations. We recommend symmetrizing the organic SBU if possible but do not symmetrize the metal SBU. During testing, we found that when the metal SBU is symmetrized, the algorithm struggles to find compatible slots especially if the symmetry operation distorts the SBU, which prevents it from aligning properly with the topology’s slot.
How do I convert from a standard XYZ file format to .inp which is used in AuToGraFs?
Firstly with the update version of AuToGraFs, you nolonger need to convert from XYZ file format to .inp format. AuToGraFs can directly read the XYZ file and generates the inp and uploads it in a cache sbu.pkl file. The only thing users have to do is to include dummy atoms in their XYZ file as illustrated above. However, if you really wish to do the conversion, the code below can be useful.
import os import sys from scm.autografs.utils.io import xyz_to_inp if len(sys.argv) == 2: qcin = sys.argv[1] qc_base = os.path.basename(qcin).split('.')[0] else: print ('Incorrect filetype') sys.exit() xyz_to_inp(qcin, name=qc_base)
NB#
For any further issues with using AuToGraFs, please contact SCM support
or send an email directly to dak52@uclive.ac.nz.

