def __init__(self, graph, unit_cell=None):
from molmod.bonds import bonds<EOL>if unit_cell is None:<EOL><INDENT>self.matrix = None<EOL>self.reciprocal = None<EOL><DEDENT>else:<EOL><INDENT>self.matrix = unit_cell.matrix<EOL>self.reciprocal = unit_cell.reciprocal<EOL><DEDENT>self.dm = graph.distances.astype(int)<EOL>dm = self.dm.astype(float)<EOL>self.dm0 = dm**<NUM_LIT:2><EOL>self.dmk = (dm+<NUM_LIT:0.1>)**(-<NUM_LIT:3>)<EOL>self.vdw_radii = np.array([periodic[number].vdw_radius for number in graph.numbers], dtype=float)<EOL>self.covalent_radii = np.array([periodic[number].covalent_radius for number in graph.numbers], dtype=float)<EOL>bond_edges = []<EOL>bond_lengths = []<EOL>for i, j in graph.edges:<EOL><INDENT>bond_edges.append((i, j))<EOL>bond_lengths.append(bonds.get_length(graph.numbers[i], graph.numbers[j]))<EOL><DEDENT>self.bond_edges = np.array(bond_edges, int)<EOL>self.bond_lengths = np.array(bond_lengths, float)<EOL>special_angles = SpecialAngles()<EOL>span_edges = []<EOL>span_lengths = []<EOL>for i, neighbors in graph.neighbors.items():<EOL><INDENT>number_i = graph.numbers[i]<EOL>if (number_i >= <NUM_LIT:5> and number_i <=<NUM_LIT:8>):<EOL><INDENT>valence = len(neighbors) + abs(number_i-<NUM_LIT:6>)<EOL><DEDENT>elif number_i >= <NUM_LIT> and number_i <= <NUM_LIT:16>:<EOL><INDENT>valence = len(neighbors) + abs(number_i-<NUM_LIT>)<EOL><DEDENT>else:<EOL><INDENT>valence = -<NUM_LIT:1><EOL><DEDENT>if valence < <NUM_LIT:2> or valence > <NUM_LIT:6>:<EOL><INDENT>default_angle = np.pi/<NUM_LIT>*<NUM_LIT><EOL><DEDENT>elif valence == <NUM_LIT:2>:<EOL><INDENT>default_angle = np.pi<EOL><DEDENT>elif valence == <NUM_LIT:3>:<EOL><INDENT>default_angle = np.pi/<NUM_LIT>*<NUM_LIT><EOL><DEDENT>elif valence == <NUM_LIT:4>:<EOL><INDENT>default_angle = np.pi/<NUM_LIT>*<NUM_LIT><EOL><DEDENT>elif valence == <NUM_LIT:5>:<EOL><INDENT>default_angle = np.pi/<NUM_LIT>*<NUM_LIT><EOL><DEDENT>elif valence == <NUM_LIT:6>:<EOL><INDENT>default_angle = np.pi/<NUM_LIT>*<NUM_LIT><EOL><DEDENT>for j in neighbors:<EOL><INDENT>number_j = graph.numbers[j]<EOL>for k in neighbors:<EOL><INDENT>if j < k and not frozenset([j, k]) in graph.edges:<EOL><INDENT>number_k = graph.numbers[k]<EOL>triplet = (<EOL>number_j, len(graph.neighbors[j]),<EOL>number_i, len(graph.neighbors[i]),<EOL>number_k, len(graph.neighbors[k]),<EOL>)<EOL>angle = special_angles.get_angle(triplet)<EOL>if angle is None:<EOL><INDENT>angle = default_angle<EOL><DEDENT>dj = bonds.get_length(number_i, number_j)<EOL>dk = bonds.get_length(number_i, number_k)<EOL>d = np.sqrt(dj**<NUM_LIT:2>+dk**<NUM_LIT:2>-<NUM_LIT:2>*dj*dk*np.cos(angle))<EOL>span_edges.append((j, k))<EOL>span_lengths.append(d)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>self.span_edges = np.array(span_edges, int)<EOL>self.span_lengths = np.array(span_lengths, float)<EOL>self.dm_quad = <NUM_LIT:0.0><EOL>self.dm_reci = <NUM_LIT:0.0><EOL>self.bond_quad = <NUM_LIT:0.0><EOL>self.span_quad = <NUM_LIT:0.0><EOL>self.bond_hyper = <NUM_LIT:0.0><EOL>self.bond_hyper_scale = <NUM_LIT><EOL>
Argument:
 | ``graph``  --  the molecular graph from which the force field terms
                  are extracted. See
                  :class:molmod.molecular_graphs.MolecularGraph

Optional argument:
 | ``unit_cell``  --  periodic boundry conditions, see
                      :class:`molmod.unit_cells.UnitCell`