Builder

Build a molecule atom by atom on a tetrahedral grid.

Usage

Source

Builder(
    up=(0.0, 0.0, 1.0),
    left=(-1.0, 0.0, 0.0),
    *,
    xh_length=XH_LENGTH,
    xy_length=XY_LENGTH
)

Every atom has four bond slots, one per direction of the tetrahedral_basis. Bonded atoms have opposite parities: an atom of parity +1 bonds along the basis directions, and one of parity -1 along their negatives. A child added through slot i therefore bonds back to its parent through its own slot i. Filling in carbons gives the diamond lattice, and neighboring centers are always staggered.

Example

A C-N bond pointing up, with a methyl group to the left of the carbon:

b = Builder(up=(0, 0, 1), left=(-1, 0, 0)) c = b.add(“C”) n = b.add(“N”, c, toward=(0, 0, 1)) c2 = b.add(“C”, c, toward=(-1, 0, 0)) b.add_hydrogens() [3, 4, 5, 6, 7, 8, 9] b.geometry().symbols [‘C’, ‘N’, ‘C’, ‘H’, ‘H’, ‘H’, ‘H’, ‘H’, ‘H’, ‘H’]