def test_bond_orders(): # Get a molecule with some bonds wat = _make_water() wat_o = wat.copy() # 0,1 0,2 assert_npequal(wat.bond_orders, np.array([0, 0])) # Remove a bond wat.bonds = np.array([[0, 1]]) assert_npequal(wat.bond_orders, np.array([0])) wat.bond_orders = np.array([2]) # Try with a system s = System() s.add(wat_o) s.add(wat) assert_npequal(s.bond_orders, np.array([0, 0, 2])) s.reorder_molecules([1, 0]) # Bonds get sorted accordingly assert_npequal(s.bond_orders, np.array([2, 0, 0])) s.bonds = np.array([[0, 1], [0, 2], [3, 4], [3, 5]]) assert_npequal(s.bond_orders, np.array([2, 0, 0, 0]))
def test_bonds(): # TODO: deprecate this shit from chemlab.io import datafile bz = datafile("tests/data/benzene.mol").read('molecule') na = Molecule([Atom('O', [0.0, 0.0, 0.0]), Atom('H', [0.0, 0.0, 0.0]), Atom('H', [0.0, 0.0, 0.0]), ]) # Adding bonds s = System() with s.batch() as b: b.append(bz) assert_npequal(s.bonds, bz.bonds) assert_npequal(bz.bond_orders, [1, 2, 2, 1, 1, 2]) assert_npequal(s.bond_orders, bz.bond_orders) s.add(bz) assert_npequal(s.type_array, ['C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C']) eq_(s.dimensions['atom'], 12) assert_npequal(s.bonds, np.concatenate((bz.bonds, bz.bonds + 7))) # Reordering s.bonds = np.array([[0, 1], [6, 8]]) s.reorder_molecules([1, 0]) assert_eqbonds(s.bonds, np.array([[6, 7], [0, 2]])) # Selection ss = subsystem_from_molecules(s, [1]) assert_npequal(ss.bonds, np.array([[0, 1]]))
def test_bonds(): # TODO: deprecate this shit from chemlab.io import datafile bz = datafile("tests/data/benzene.mol").read('molecule') na = Molecule([ Atom('O', [0.0, 0.0, 0.0]), Atom('H', [0.0, 0.0, 0.0]), Atom('H', [0.0, 0.0, 0.0]), ]) # Adding bonds s = System() with s.batch() as b: b.append(bz) assert_npequal(s.bonds, bz.bonds) assert_npequal(bz.bond_orders, [1, 2, 2, 1, 1, 2]) assert_npequal(s.bond_orders, bz.bond_orders) s.add(bz) assert_npequal( s.type_array, ['C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C']) eq_(s.dimensions['atom'], 12) assert_npequal(s.bonds, np.concatenate((bz.bonds, bz.bonds + 7))) # Reordering s.bonds = np.array([[0, 1], [6, 8]]) s.reorder_molecules([1, 0]) assert_eqbonds(s.bonds, np.array([[6, 7], [0, 2]])) # Selection ss = subsystem_from_molecules(s, [1]) assert_npequal(ss.bonds, np.array([[0, 1]]))
def test_from_actual_empty(self): mols = self._make_molecules() system = System([]) [system.add(mol) for mol in mols]
def test_from_actual_empty(self): mols = self._make_molecules() system = System([]) [system.add(mol) for mol in mols] self._assert_init(system)