コード例 #1
0
def test_irmof1_and_packed_irmof1_should_return_correct_cell_vectors_and_number_of_atoms_bonds(
):
    irmof1 = MOF('tests/IRMOF-1.cif')

    irmof1.calculate_vectors()
    cell_vectors = [[round(i, 3) for i in j] for j in irmof1.uc_vectors]
    assert cell_vectors == expected_cell_vectors

    irmof1.bonds = extrapolate_bonds(irmof1.atoms)
    assert len(irmof1.bonds) == 488

    irmof1.pbonds = extrapolate_periodic_bonds(irmof1.atoms, irmof1.uc_vectors)
    assert len(irmof1.pbonds) == 512

    irmof1_222 = irmof1.extend_unit_cell(pack=[2, 2, 2])

    assert len(irmof1_222.atoms) == len(irmof1.atoms) * 8

    packed_cell_vectors = [[round(i, 3) for i in j]
                           for j in irmof1_222.uc_vectors]
    expected_packed_cell_vectors = [[round((i * 2), 3) for i in j]
                                    for j in irmof1.uc_vectors]
    assert packed_cell_vectors == expected_packed_cell_vectors

    irmof1_222.bonds = extrapolate_bonds(irmof1_222.atoms)
    assert len(irmof1_222.bonds) == 4000

    irmof1_222.pbonds = extrapolate_periodic_bonds(irmof1_222.atoms,
                                                   irmof1_222.uc_vectors)
    assert len(irmof1_222.pbonds) == 4096
コード例 #2
0
def test_bond_tuples_should_be_sorted_by_atom_index():
    atoms = [(0.0, 0.0, 0.0, 1), (0.0, 0.0, 0.16, 1)]
    bonds = extrapolate_bonds(atoms)
    assert bonds == [(0, 1)]
    atoms = [(0.0, 0.0, 0.16, 1), (0.0, 0.0, 0.0, 1)]
    bonds = extrapolate_bonds(atoms)
    assert bonds == [(0, 1)]
コード例 #3
0
def test_zif8_should_return_correct_bonds_angles_dihedrals():
    zif8 = MOF('tests/ZIF-8.xyz')

    zif8.bonds = extrapolate_bonds(zif8.atoms)
    assert len(zif8.bonds) == 288

    zif8.angles = get_angles(zif8.bonds)
    assert len(zif8.angles) == 444
    assert zif8.angles == expected_angles

    zif8.dihedrals = get_dihedrals(zif8.bonds)
    assert len(zif8.dihedrals) == 480
    assert zif8.dihedrals == expected_dihedrals
コード例 #4
0
def test_ethane_should_have_seven_bonds():

    atoms = [(1.185080, -0.003838, 0.987524, 1),
             (0.751621, -0.022441, -0.020839, 6),
             (1.166929, 0.833015, -0.569312, 1),
             (1.115519, -0.932892, -0.514525, 1),
             (-0.751587, 0.022496, 0.020891, 6),
             (-1.166882, -0.833372, 0.568699, 1),
             (-1.115691, 0.932608, 0.515082, 1),
             (-1.184988, 0.004424, -0.987522, 1)]

    bonds = extrapolate_bonds(atoms)
    assert len(bonds) == 7

    expected_bonds = [(0, 1), (1, 2), (1, 3), (1, 4), (4, 5), (4, 6), (4, 7)]
    expected_bonds = {frozenset(s) for s in expected_bonds}
    bonds = {frozenset(s) for s in bonds}
    assert len(expected_bonds ^ bonds) == 0
コード例 #5
0
def test_zero_cell_vectors_should_give_same_bonds_with_nonperiodic():
    cell_vectors = [[0] * 3] * 3
    atoms = [(0, 0, 0, 1)]
    assert extrapolate_bonds(atoms) == extrapolate_periodic_bonds(
        atoms, cell_vectors)
コード例 #6
0
def test_atoms_at_0_16_angstrom_should_be_bonded():
    atoms = [(0.0, 0.0, 0.0, 1), (0.0, 0.0, 0.16, 1)]
    bonds = extrapolate_bonds(atoms)
    assert len(bonds) == 1
    assert bonds == [(0, 1)]
コード例 #7
0
def test_si_atoms_at_gt_2_77_angstrom_should_not_be_bonded():
    atoms = [(0.0, 0.0, 0.0, 14), (0.0, 0.0, 2.78, 14)]
    bonds = extrapolate_bonds(atoms)
    assert len(bonds) == 0
コード例 #8
0
def test_atoms_too_close_should_not_be_bonded():
    atoms = [(0.0, 0.0, 0.0, 1), (0.0, 0.0, 0.159, 1)]
    bonds = extrapolate_bonds(atoms)
    assert len(bonds) == 0
コード例 #9
0
def test_si_atoms_at_lte_2_77_angstrom_should_be_bonded():
    atoms = [(0.0, 0.0, 0.0, 14), (0.0, 0.0, 2.77, 14)]
    bonds = extrapolate_bonds(atoms)
    assert len(bonds) == 1
    assert bonds == [(0, 1)]
コード例 #10
0
def test_h_atoms_at_gt_1_09_angstrom_should_not_be_bonded():
    atoms = [(0.0, 0.0, 0.0, 1), (0.0, 0.0, 1.10, 1)]
    bonds = extrapolate_bonds(atoms)
    assert len(bonds) == 0
コード例 #11
0
def test_h_atoms_at_lte_1_09_angstrom_should_be_bonded():
    atoms = [(0.0, 0.0, 0.0, 1), (0.0, 0.0, 1.09, 1)]
    bonds = extrapolate_bonds(atoms)
    assert len(bonds) == 1
    assert bonds == [(0, 1)]