API documentaiton

Basic chemistry module.

The chemistry module contains three classes:

One can use the chemistry.Molecule.add_atom() and chemsitry.Molecule.add_bond() functions to build up a molecule.

Example illustrating how to create a methane molecule.

>>> from chemistry import Molecule
>>> mol = Molecule('Methane')
>>> carbon_index = mol.add_atom(atomic_number=6)
>>> hydrogen1_index = mol.add_atom(atomic_number=1)
>>> hydrogen2_index = mol.add_atom(atomic_number=1)
>>> hydrogen3_index = mol.add_atom(atomic_number=1)
>>> hydrogen4_index = mol.add_atom(atomic_number=1)
>>> bond1_index = mol.add_bond(carbon_index, hydrogen1_index)
>>> bond2_index = mol.add_bond(carbon_index, hydrogen2_index)
>>> bond3_index = mol.add_bond(carbon_index, hydrogen3_index)
>>> bond4_index = mol.add_bond(carbon_index, hydrogen4_index)
class chemistry.Atom(atomic_number)[source]

Class representing an atom.

bond_to(other_atom)[source]

Return the chemistry.Bond formed between the two atoms.

Parameters:other_atomchemistry.Atom to form chemistry.Bond to
Returns:chemistry.Bond
class chemistry.Bond(atom1, atom2)[source]

Class representing a bond between two atoms.

class chemistry.Molecule(identifier)[source]

Class representing a molecule consisting of atoms and bonds.

add_atom(atomic_number)[source]

Return the list index of the atom added to the molecule.

Parameters:atomic_number – atomic number of the atom to be added
Returns:index of the atom in the molecule
add_bond(atom1_index, atom2_index)[source]

Return the list index of the bond added to the molecule.

Parameters:
  • atom1_index – atom’s index in molecule
  • atom2_index – atom’s index in molecule
Returns:

index of the bond in the molecule