Skip to main content

formula()

Generate the molecular formula of a geometry in Hill order.

Usage

Source

formula(geo)

With carbon present, C comes first, then H, then the remaining elements alphabetically. Without carbon, all elements (including H) are alphabetical.

Parameters

geo: Geometry
Geometry.

Returns

str
Molecular formula.

Examples

    >>> import autogeom
    >>> autogeom.formula(autogeom.from_smiles("CO"))
'CH4O'
    >>> autogeom.formula(autogeom.from_smiles("Cl"))
'ClH'