Beispiel #1
0
def test_atoms_bohr():
    Mol = Molecule()
    Mol.setCellDim(2)
    Mol.newAtom()
    Mol.newAtom('H', (1, 1, 1), 1, [True, False], True)
    assert Mol.nat == 2
    assert Mol.ntyp == 2
    assert Mol.getTypes() == ['H', 'C']
    assert Mol.getCellDim() == 2
    assert atom_equal(Mol.getAtom(0, charge=True, fix=True, hidden=True),
                      ['C', (0, 0, 0), 0., [False, False, False], False])
    assert atom_equal(Mol.getAtom(1, charge=True, fix=True, hidden=True),
                      ['H', (1, 1, 1), 1., [True, False, False], True])
    assert list(map(len, Mol.getBonds(1.1))) == [1, 1, 1, 1, 1, 1, 1, 1]
    Mol.delAtom(1)
    assert Mol.nat == 1
    assert Mol.getTypes() == ['C']
    Mol.newAtoms(2)
    assert Mol.getTypes() == ['X', 'C']
    Mol.setAtom(1, 'O', (0.5, 0.5, 0.5), 2, [False, True], False)
    Mol.setAtom(2, 'U', (1, 1, 1), 2, [True], False)
    assert atom_equal(Mol.getAtom(1, charge=True, fix=True, hidden=True),
                      ['O', (0.5, 0.5, 0.5), 2., [False, True, False], False])
    assert atom_equal(Mol.getAtom(2, charge=True, fix=True, hidden=True),
                      ['U', (1, 1, 1), 2., [True, False, False], False])
    assert Mol.getTypes() == ['C', 'O', 'U']
    target = (['C', (0, 0, 0), 0., [False, False, False], False],
              ['O', (0.5, 0.5, 0.5), 2., [False, True, False], False],
              ['U', (1, 1, 1), 2., [True, False, False], False])
    for a, t in zip(Mol.getAtoms(True, True, True), target):
        assert atom_equal(a, t)