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_atom – chemistry.Atom
to formchemistry.Bond
toReturns: chemistry.Bond
-
-
class
chemistry.
Molecule
(identifier)[source]¶ Class representing a molecule consisting of atoms and bonds.