Installation via pip install rdkit2ase
. For more information please visit the
documentation.
A common use case is to create 3D structures from SMILES strings. This can be
achieved using the rdkit2ase.rdkit2ase
function.
import ase
from rdkit import Chem
from rdkit2ase import rdkit2ase, ase2rdkit
mol = Chem.MolFromSmiles("O")
atoms: ase.Atoms = rdkit2ase(mol)
mol = ase2rdkit(atoms)
Because this is such a common use case, there is a convenience function
rdkit2ase.smiles2atoms
that combines the two steps.
import ase
from rdkit2ase import smiles2atoms
atoms: ase.Atoms = smiles2atoms("O")
print(atoms)
>>> Atoms(symbols='OH2', pbc=False)
Given the molecular units, you can build periodic boxes with a given density
using the rdkit2ase.pack
function.
If you have packmol (at least v20.15.0
) you
can use the rdkit2ase interface as follows:
from rdkit2ase import pack, smiles2conformers
water = smiles2conformers("O", 2)
ethanol = smiles2conformers("CCO", 5)
density = 1000 # kg/m^3
box = pack([water, ethanol], [7, 5], density)
print(box)
>>> Atoms(symbols='C10H44O12', pbc=True, cell=[8.4, 8.4, 8.4])
Many additional features are described in the documentation.