General AuToGraFS Scripting concepts#

AuToGraFS relies on the concept of underlying nets common to many structures. These nets, or topologies, can be found in the RCSR and EPINET databases. Once implemented, AuToGraFS will follow these blueprints to generate a framework from building units of compatible geometries. Since these geometries are ideal objects and most chemical structures are distorted, an optimization step using UFF is necessary for the building units to “snap into place”. Correct handling of bonding information and UFF atom types are crucial to the generation of correct structures.

Components of AuToGraFS#

The SBU class#

This is a slightly modified version of the native ASE Atoms object, designed to hold essential data for UFF postprocessing. This includes the UFF atom types and the bonding information.

from scm.autografs.utils.sbu import SBU
from ase import Atoms

line = SBU(
   ase.Atoms("X2", positions=...),
   mmtypes=["H_", "H_"],
   bonds = [[0,0,1],[0,0,1],[1,1,0]],
   shape=shape,
   pg=point_group
)

Where:

  • mmtypes is a list of UFF atom type symbols, ordered as the corresponding atoms in the structure

  • bonds is a symmetric numpy array of size equal to the number of atoms. The i,j elements in the bonds array are the bond order between atom i and atom j of the structure. These bond orders should follow the UFF conventions (1.5 for aromatic, 0.5 for coordination bonds, 0.001 for hydrogen bonds…).

  • shape is an array that holds information for AuToGraFS about the connectivity of the fragment. It checks the compatibility of the fragment with the topology. Each dummy atom, with symbol “X” in ASE, represents a point of connection between two fragments. Hence shape is a list of integers, each integer representing the number of connections for the corresponding atom in the structure. For example, a benzene ring with 6 atoms and 6 dummy atoms will have a shape of [2,2,2,2,2,2]. A linear molecule with 4 atoms and 2 dummy atoms will have a shape of [1,1,0,0]. The shape can be computed using the get_unique_shapes function from scm.autografs.utils.topology.get_unique_shapes.

  • pg is the point group of the fragment.

The name of a secondary building unit is used only for logging purposes. Individual building blocks of a framework are manipulated through the SBU class. .. It is possible to export a fragment from the GUI using edit -> framework -> export fragment. If the UFF atom types are not specified, an automatic typing script will take care of it.

The Framework class#

This is a container class that holds in one place the topology of a framework and the correctly positioned fragments. Most of the postprocessing methods found in AuToGraFS are Framework methods.

from scm.autografs import framework

model = framework.Framework(...)

# view the framework in adfinput. set clean to False to keep dummy atoms.
model.view(clean=True, verbose=True)

# write the name.ams and name.run files
model.write(name="framework", clean=True, verbose=True)

# returns a Fragment, with correct bonding information and mmtypes
# if indices is True, it also returns the index of the corresponding fragment in the model for each atom
atoms = model.get_atoms(self, clean=False, indices=False)

# returns a supercell of the framework as a Fragment
supercell = model * (2,2,2)

# deletes a fragment in the framework. if no index is given, the fragment will be chosen at random.
# the defects will cap with hydrogen the empty spaces. returns a Fragment
# here, a linker at random will be deleted
model.insert_defect(indices=None, centers=0, linkers=1)

# flip a linear object
model.flip_fragment(index=the_fragment_index)

# rotates a linear object around its axis by angle in degrees
model.rotate_fragment(index=the_fragment_index, angle=85.0)

# Will add a functional group to the selected fragment on a random hydrogen
# if and only if the hydogen is connected to a carbon.
# for more precise handling, use the GUI for now.
model.functionalize_fragment(functional_group="NH2", index=the_fragment_index)

The Autografs class#

This class is the builder in itself. Given a path to a database of building units in .inp or .xyz format, it will generate a valid framework from a topology name and secondary building units.

from scm.autografs import autografs
from random import choice

# create the generator and update the database of building units
mofgen = autografs.Autografs(sbu_path="path/to/my/fragments/", update=True)

# choose a topology from the available one given no center or linkers
topologies = mofgen.get_available_topologies(sbu_names)
topology = choice(topologies)

# Find fragments in the list of available sbu for the topology
all_sbus = mofgen.list_available_sbu(topology_name)

# generate the framework using multiprocessing tools and automatic scaling of unit cell
framework = mofgen.make(topology_name=topology, sbu_names=sbu_names)

# visualize in adfinput
framework.view()

Do not forget to run a quick UFF optimization after generation to optimize the lattice and fragment into an optimal configuration.

About the databases of building units#

AuToGraFS uses both a binary database format and structures in the DemonNano file format from which the binary is compiled. To ask AuToGraFS to use a custom directory containing .inp files, simply pass the directory to the path argument when initializing the constructor. The “.inp” file format should be formatted like the following example:

Data: shape = [1 1 0 1 1 2]
Data: name  = benzene_X2
GEOMETRY CARTESIAN
C      -0.517332   -0.168745   1.281475     MMTYPE=C_R  QMMM=MM BOND=2/1.5:9/1.5:11/1.0
C      0.179055    0.994516    0.949745     MMTYPE=C_R  QMMM=MM BOND=1/1.5:3/1.0:4/1.5
H      0.312742    1.765132    1.701305     MMTYPE=H_  QMMM=MM BOND=2/1.0
C      0.694793    1.164986    -0.323853    MMTYPE=C_R  QMMM=MM BOND=2/1.5:5/1.0:6/1.5
H      1.237857    2.066338    -0.590389    MMTYPE=H_  QMMM=MM BOND=4/1.0
C      0.517412    0.168704    -1.281448    MMTYPE=C_R  QMMM=MM BOND=4/1.5:7/1.5:12/1.0
C      -0.17926    -0.994413   -0.949815    MMTYPE=C_R  QMMM=MM BOND=6/1.5:8/1.0:9/1.5
H      -0.312783   -1.765111   -1.701319    MMTYPE=H_  QMMM=MM BOND=7/1.0
C      -0.694789   -1.164988   0.323855     MMTYPE=C_R  QMMM=MM BOND=1/1.5:7/1.5:10/1.0
H      -1.237689   -2.066423   0.590446     MMTYPE=H_  QMMM=MM BOND=9/1.0
X      -1.074343   -0.339375   2.680005     MMTYPE=C_R  QMMM=MM BOND=1/1.0
X      1.075647    0.33872     -2.679565    MMTYPE=C_R  QMMM=MM BOND=6/1.0
END

With the new version of AuToGraFS, one does not need to create an inp file manually. It can easily be created using the code below or simply using an xyz file connecting dummy atoms.

from scm.autografs.utils.io import xyz_to_inp
xyz_to_inp("path/to/xyzfile.xyz")