Ejemplo n.º 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
def test_periodic_bond_tuples_should_be_sorted_by_atom_index():
    cell_vectors = [[10, 0, 0], [0, 10, 0], [0, 0, 10]]
    atoms = [(0.0, 0.0, 9.9, 1), (0.0, 0.0, 10.06, 1)]
    bonds = extrapolate_periodic_bonds(atoms, cell_vectors)
    assert bonds == [(0, 1)]
    atoms = [(0.0, 0.0, 10.06, 1), (0.0, 0.0, 9.9, 1)]
    bonds = extrapolate_periodic_bonds(atoms, cell_vectors)
    assert bonds == [(0, 1)]
def test_periodic_si_atoms_at_gt_2_77_angstrom_should_not_be_bonded():
    cell_vectors = [[10, 0, 0], [0, 10, 0], [0, 0, 10]]
    atoms = [(0.0, 0.0, 9.0, 14), (0.0, 0.0, 11.78, 14)]
    bonds = extrapolate_periodic_bonds(atoms, cell_vectors)
    assert len(bonds) == 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)
def test_perodic_h_atoms_at_lte_1_09_angstrom_should_be_bonded():
    cell_vectors = [[10, 0, 0], [0, 10, 0], [0, 0, 10]]
    atoms = [(0.0, 0.0, 9.0, 1), (0.0, 0.0, 10.09, 1)]
    bonds = extrapolate_periodic_bonds(atoms, cell_vectors)
    assert len(bonds) == 1
    assert bonds == [(0, 1)]
def test_periodic_atoms_too_close_should_not_be_bonded():
    cell_vectors = [[10, 0, 0], [0, 10, 0], [0, 0, 10]]
    atoms = [(0.0, 0.0, 9.9, 1), (0.0, 0.0, 10.059, 1)]
    bonds = extrapolate_periodic_bonds(atoms, cell_vectors)
    assert len(bonds) == 0