Packmol Interface¶
Packmol is a powerful tool for creating initial configurations for molecular dynamics simulations by packing molecules into a given region of space. rdkit2ase provides a python interface to Packmol. If you have packmol installed, you can use it via pack create periodic boxes from ase.Atoms
objects.
[1]:
import rdkit2ase
The interface takes
a list of lists of
ase.Atoms
objects to be packed,the number of each type of molecule, if larger than the number of provided
ase.Atoms
objects the objects will be duplicated,the density of the final box in kg/m³.
You can either specify the path to the Packmol executable, or use a Julia installation with the Packmol package.
[2]:
water = rdkit2ase.smiles2conformers("O", numConfs=10)
etoh = rdkit2ase.smiles2conformers("CCO", numConfs=10)
box = rdkit2ase.pack(
data=[water, etoh], counts=[5, 5], density=800, packmol="packmol.jl"
)
[3]:
print(box)
Atoms(symbols='OH2OH2OH2OH2OH2C2OH6C2OH6C2OH6C2OH6C2OH6', pbc=True, cell=[8.728901107040366, 8.728901107040366, 8.728901107040366], atomtypes=..., bfactor=..., occupancy=..., residuenames=..., residuenumbers=...)
You can utilize all other features here as well.
[4]:
waters = rdkit2ase.match_substructure(
box,
smiles="O",
)
etohs = rdkit2ase.match_substructure(
box,
smiles="CCO",
)
print(f"Found {len(waters)} water molecules and {len(etohs)} ethanol molecules.")
Found 5 water molecules and 5 ethanol molecules.