def test_replace_pattern_in_structure__in_uio66_replacing_linker_with_linker_does_not_change_positions():
    with Path("tests/uio66/uio66.cif") as path:
        structure = Atoms.load_cif(path)
    with Path("tests/uio66/uio66-linker.cif") as path:
        search_pattern = Atoms.load_cif(path)
    with Path("tests/uio66/uio66-linker-fluorinated.cif") as path:
        replace_pattern = Atoms.load_cif(path)

    final_structure = replace_pattern_in_structure(structure, search_pattern, replace_pattern)
    assert Counter(final_structure.elements) == {'C': 192, 'O': 120, 'F': 96, 'Zr': 24}
Beispiel #2
0
def test_atoms_load_cif__loads_elements():
    with Path("tests/uio66/uio66-linker.cif").open() as fd:
        atoms = Atoms.load_cif(fd)

    assert atoms.elements == [
        "C", "O", "O", "C", "C", "H", "H", "C", "C", "C", "C", "H", "H", "O",
        "C", "O"
    ]
Beispiel #3
0
def hkust1_cif():
    with Path("tests/hkust-1/hkust-1-with-bonds.cif") as path:
        yield Atoms.load_cif(path)
Beispiel #4
0
def hkust1_3x3x3_cif():
    with Path("tests/hkust-1/hkust-1-3x3x3.cif") as path:
        yield Atoms.load_cif(path)
"""
Run and visualize with:

python -m cProfile -o hkustperf.pstats  -s tottime hkustperf.py
snakeviz hkustperf.pstats

"""

import ase
import ase.io

import numpy as np

from mofun import find_pattern_in_structure, replace_pattern_in_structure, Atoms

hkust1_cif = Atoms.load_cif("../tests/hkust-1/hkust-1-with-bonds.cif")
benzene = Atoms.from_ase_atoms(ase.io.read("../tests/molecules/benzene.xyz"))
hkust1_repped = hkust1_cif.replicate(repldims=(3, 3, 3))
match_indices = find_pattern_in_structure(hkust1_repped, benzene)