ZIF-8 in water and ethanol
A crystal of the metal–organic framework ZIF-8 in an aqueous solution of ethanol. ZIF-8, zinc 2-methylimidazolate, has cages of 11.6 Å connected by windows of 3.4 Å, lined by the methyl groups of the linkers: its pores are hydrophobic, and they take up alcohols but almost no water, which is why ZIF-8 is studied for the recovery of ethanol and butanol from water.
The crystal is a slab, periodic in x and y, and the liquid fills the space between its two faces, which meet across the periodic boundary in z. Ethanol is packed in the pores and in the liquid; water only in the liquid.
The packed system (drag to rotate, scroll to zoom), built in the Julia script section below: the framework (dark blue), ethanol (spheres, carbon pale green) and water (sticks), with hydrogen white and oxygen red.
Files: zif8.pdb, ethanol.pdb, water.pdb, and the input file zif8.inp.
The crystal
The structure of ZIF-8 is entry 7111973 of the Crystallography Open Database (O. Shekhah et al., Chem. Commun. 50, 2089 (2014), doi:10.1039/c3cc47495j): a cubic cell of 17.033 Å, Zn₁₂(C₄H₅N₂)₂₄, with 276 atoms. The full unit cell is obtained from the CIF file with Open Babel, as for the zeolite:
obabel 7111973.cif -O zif8_uc.pdb --fillUC strictThe slab, zif8.pdb, has 3 × 3 unit cells in x and y (51.1 Å) and is 2 unit cells thick in z, from z = 0.5 to 37.7 Å (5364 atoms). It is cut at whole linkers: the zinc atoms of two unit cells, and every linker bound to them. At each face, 36 linkers are bound to a single zinc atom, as at the surfaces of real crystals. It was built by the script build_slab.jl, which also keeps one of the two orientations of the methyl groups (the hydrogen atoms of the methyl groups are disordered in the crystal):
The script build_slab.jl (click to expand)
#
# A slab of ZIF-8 (zif8.pdb): 3 x 3 unit cells in x and y (periodic), 2 unit cells thick
# in z, with whole linkers at its faces, from the unit cell of COD entry 7111973
# (Shekhah et al., Chem. Commun. 50, 2089 (2014)) filled by Open Babel:
#
# obabel 7111973.cif -O zif8_uc.pdb --fillUC strict
# julia build_slab.jl zif8_uc.pdb zif8.pdb
#
using PDBTools, LinearAlgebra
# Minimum-image distance, with the periods L (Inf: not periodic)
wrap(d, L) = isinf(L) ? d : d - L * round(d / L)
dist(p, q, L) = norm([wrap(p[i] - q[i], L[i]) for i in 1:3])
function zif8_slab(ucfile, outfile; a = 17.033, n = 3)
uc = read_pdb(ucfile)
x = [collect(Float64, position(at)) for at in uc]
el = [element(at) for at in uc]
# The hydrogens of the methyl groups are disordered in the crystal: two sets of 3,
# half occupied. One set per carbon is kept: three hydrogens 1.57 Å apart (C–H bonds
# of 0.96 Å in the CIF); those of the other set are 0.9 and 1.8 Å from them.
L = (a, a, a)
remove = Int[]
for i in eachindex(x)
el[i] == "C" || continue
hs = [j for j in eachindex(x) if el[j] == "H" && dist(x[i], x[j], L) < 1.2]
length(hs) == 6 || continue
keep = [hs[1]; [h for h in hs[2:end] if 1.4 < dist(x[h], x[hs[1]], L) < 1.7]]
length(keep) == 3 || error("methyl $i: no set of 3 hydrogens")
append!(remove, setdiff(hs, keep))
end
keepat = setdiff(eachindex(x), remove)
x = x[keepat]
el = el[keepat]
println("unit cell: ", length(x), " atoms") # Zn12 (C4H5N2)24: 276 atoms
# n x n cells in x and y (periodic), 3 cells stacked in z (not periodic)
X = Vector{Float64}[]
E = String[]
for i in 0:n-1, j in 0:n-1, k in 0:2, (p, e) in zip(x, el)
push!(X, p + [i * a, j * a, k * a])
push!(E, e)
end
Lxy = (n * a, n * a, Inf)
# The linkers: the groups of bonded atoms (bonds shorter than 1.75 Å) other than zinc
nat = length(X)
linker = zeros(Int, nat)
nlinkers = 0
for i in 1:nat
(E[i] == "Zn" || linker[i] != 0) && continue
nlinkers += 1
linker[i] = nlinkers
stack = [i]
while !isempty(stack)
k = pop!(stack)
for j in 1:nat
if E[j] != "Zn" && linker[j] == 0 && dist(X[k], X[j], Lxy) < 1.75
linker[j] = nlinkers
push!(stack, j)
end
end
end
end
# The zinc atoms of the two cells in the middle of the stack, and the linkers bound to
# them (those at the faces are bound to a single zinc)
zn = [i for i in 1:nat if E[i] == "Zn" && a <= X[i][3] < 3a]
bound = Set(linker[j] for i in zn for j in 1:nat if E[j] == "N" && dist(X[i], X[j], Lxy) < 2.3)
slab = sort([zn; [j for j in 1:nat if linker[j] in bound]])
# The slab from z = 0.5, with x and y wrapped into the periodic cell
z0 = minimum(X[i][3] for i in slab)
atoms = Atom{Nothing}[]
for i in slab
p = X[i] - [0.0, 0.0, z0 - 0.5]
push!(atoms, Atom(; name = E[i], resname = "ZIF", resnum = 1, chain = "A",
x = mod(p[1], n * a), y = mod(p[2], n * a), z = p[3], pdb_element = E[i]))
end
println("slab: ", length(atoms), " atoms, ", length(zn), " Zn, ", length(bound),
" linkers, z from 0.5 to ", round(maximum(at.z for at in atoms); digits = 2))
write_pdb(outfile, atoms)
end
zif8_slab(ARGS[1], ARGS[2])
The ethanol molecule was built by Open Babel from its SMILES (obabel -:"CCO" -O ethanol.pdb --gen3d -h), and the water molecule is that of the other tutorials.
The numbers of molecules
The periodic cell is the slab, with 40 Å of liquid above it: pbc 51.099 51.099 80.0 (from the origin to these sides).
The liquid is the region 2 Šbeyond the faces of the crystal (39.66 < z < 80), about 105000 ų. An aqueous solution of 20% ethanol in volume has 217 molecules of ethanol (0.789 g/mL) and 2808 of water (0.997 g/mL) in it.
The pores: the volume of the crystal available to ethanol is given by free_volume, which samples the region of each structure type and discounts the space taken by the fixed molecules (see Volume estimates):
packmol --free-volume zif8.inp Structure Number Volume (ų) ± error Density (g/mL)
ethanol.pdb 405 39308 48.7 0.788
ethanol.pdb 217 104861 7.0 0.158
water.pdb 2808 104854 7.1 0.801The crystal has 39300 ų available to ethanol, 0.48 cm³ per gram of ZIF-8. Filled with liquid ethanol, at 0.789 g/mL, it holds 405 molecules, 22 per unit cell. This is an upper bound of what the crystal adsorbs: the adsorbed phase is less dense than the liquid. The other two lines check the liquid: ethanol and water fill it at 0.158 + 0.801 = 0.959 g/mL, the density of the mixture.
Ethanol in the pores, water in the liquid
The input file zif8.inp (click to expand)
#
# ZIF-8 in an aqueous solution of ethanol (20% v/v). A slab of the crystal, periodic in x
# and y (3 x 3 unit cells), 2 unit cells thick in z, with the liquid between its two
# faces, which meet across the periodic boundary in z. Ethanol fills the pores of the
# crystal and the liquid; water, which the hydrophobic pores of ZIF-8 exclude, only the
# liquid.
#
# check_initial_placement
tolerance 2.0
output zif8_ethanol_water.pdb
pbc 51.099 51.099 80.0
# The crystal (5364 atoms), from z = 0.5 to 37.7
structure zif8.pdb
number 1
fixed 0. 0. 0. 0. 0. 0.
radius 1.5
end structure
# Ethanol in the pores: the free volume of the crystal (39300 A3, see free_volume)
# filled with liquid ethanol (0.789 g/mL)
structure ethanol.pdb
number 405
inside box 0. 0. 0. 51.099 51.099 38.16
end structure
# The liquid, 2 A beyond the faces of the crystal (105000 A3): 20% v/v ethanol
structure ethanol.pdb
number 217
inside box 0. 0. 39.66 51.099 51.099 80.0
end structure
structure water.pdb
number 2808
inside box 0. 0. 39.66 51.099 51.099 80.0
end structure
The crystal is a fixed molecule (see Fixed molecules), with its atoms inside the periodic cell. Ethanol has two structure blocks: one in the region of the crystal, where the distances to the atoms of the framework put the molecules in the cages, and one in the liquid. Water has a single block, in the liquid: it is the constraint that keeps water out of the pores. The radius of the atoms of the crystal, 1.5 Å, keeps the atoms of the guests 2.5 Å from those of the framework.
Check the initial placement first
Uncomment the check_initial_placement line of the input file, and run it as below (see Checking the initial placement): the initial placement, written to the output file in a fraction of a second, already has the ethanol molecules in the cages, and the liquid above the crystal.
When it does (see the views in the Julia script section), comment the line again, and run the packing.
Packing
packmol zif8.inpThe packing (19386 atoms) takes half a second.
Julia script
The crystal, fixed, and the ethanol in its pores:
using Packmol, PDBToolszif8 = structure_type("zif8.pdb"; number = 1, fixed = ([0., 0., 0.], [0., 0., 0.]), radius = 1.5,)pores = structure_type("ethanol.pdb"; number = 405, constraints = [InsideBox([0., 0., 0.], [51.099, 51.099, 38.16])],)The liquid, a region with ethanol and water:
liquid = InsideBox([0., 0., 39.66], [51.099, 51.099, 80.0])ethanol = structure_type("ethanol.pdb"; number = 217, constraints = [liquid])water = structure_type("water.pdb"; number = 2808, constraints = [liquid])The system, in the periodic cell of pbc 51.099 51.099 80.0 (from the origin), first with only the initial placement:
system = PackmolSystem([zif8, pores, ethanol, water]; output = "zif8_ethanol_water.pdb", tolerance = 2.0, unitcell = [51.099 0. 0.; 0. 51.099 0.; 0. 0. 80.0], unitcell_center = [25.5495, 25.5495, 40.0], check_initial_placement = true, # first, only the initial placement)packmol(system)system.status:not_packedThe initial placement, with the visualize function of PDBTools.jl (drag to rotate, scroll to zoom): the ethanol molecules are already in the cages, and the liquid above the crystal:
function show_system(system) return visualize(get_atoms(system), "resname ZIF" => (style = :sticks, color = "darkblue"), "resname ETOH and element C" => (style = :spheres, color = "palegreen"), "resname ETOH and not element C" => (style = :spheres, color = :element), "water" => (style = :sticks, color = :element, water = true); unitcell = UnitCell(system.unitcell), rotate = [(:z, 30), (:x, -70)], )endshow_system(system)Then the packing:
system.check_initial_placement = falsepackmol(system)show_system(system)free_volume(system) gives the volumes of the table above.