Esempio n. 1
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]]))
Esempio n. 2
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]]))
Esempio n. 3
0
    def test_from_batch(self):
        mols = self._make_molecules()

        system = System()
        with system.batch() as batch:
            [batch.append(mol) for mol in mols]
        self._assert_init(system)
Esempio n. 4
0
    def test_from_batch(self):
        mols = self._make_molecules()

        system = System()
        with system.batch() as batch:
            [batch.append(mol) for mol in mols]
        self._assert_init(system)