Ejemplo n.º 1
0
def test_supercell(generate_structure):
    """Test to create a super cell"""
    from aiida_fleur.tools.StructureData_util import supercell
    from aiida_fleur.tools.StructureData_util import supercell_ncf
    from aiida.orm import Int
    from itertools import product

    structure = generate_structure()

    supercell = supercell(structure, Int(2), Int(3), Int(4))

    assert (supercell.cell[0] == np.array(structure.cell[0]) * 2).all()
    assert (supercell.cell[1] == np.array(structure.cell[1]) * 3).all()
    assert (supercell.cell[2] == np.array(structure.cell[2]) * 4).all()
    assert len(supercell.sites) == 2 * 3 * 4 * len(structure.sites)

    positions_old = [x.position for x in structure.sites]
    positions_rescaled = [x.position for x in supercell.sites]
    for position in positions_old:
        for x, y, z in product(range(2), range(3), range(4)):
            test_pos = tuple(
                np.array(position) + x * np.array(structure.cell[0]) +
                y * np.array(structure.cell[1]) +
                z * np.array(structure.cell[2]))
            assert test_pos in positions_rescaled

    no_struc = Int(1)
    no_supercell = supercell_ncf(no_struc, 2, 3, 4)
    assert no_supercell is None
Ejemplo n.º 2
0
def test_break_symmetry_wf_film_structure_only(generate_film_structure):
    """Check if it does not crash and able to destroy all symmetries"""
    from aiida_fleur.tools.StructureData_util import break_symmetry_wf, supercell_ncf
    from aiida_fleur.tools.StructureData_util import break_symmetry
    from aiida.orm import Dict

    structure = generate_film_structure()
    structure = supercell_ncf(structure, 2, 2, 1)

    out = break_symmetry_wf(
        structure,
        wf_para=Dict(dict={}),
    )
    structure_broken = out['new_structure']
    kind_names = [x.kind_name for x in structure_broken.sites]
    kind_names_should = [
        'Fe1', 'Fe2', 'Fe3', 'Fe4', 'Pt1', 'Pt2', 'Pt3', 'Pt4', 'Pt5', 'Pt6',
        'Pt7', 'Pt8'
    ]
    for kind_name in kind_names_should:
        assert kind_name in kind_names
    assert len(set(kind_names)) == len(kind_names_should)

    struc_b_fe, para_new_fe = break_symmetry(structure, atoms=['Fe'])
    kind_names = [x.kind_name for x in struc_b_fe.sites]
    kind_names_should = ['Fe1', 'Fe2', 'Fe3', 'Fe4', 'Pt']
    for kind_name in kind_names_should:
        assert kind_name in kind_names
    assert len(set(kind_names)) == len(kind_names_should)

    struc_b_pt, para_new_pt = break_symmetry(structure, atoms=['Pt'])
    kind_names = [x.kind_name for x in struc_b_pt.sites]
    kind_names_should = [
        'Fe', 'Pt1', 'Pt2', 'Pt3', 'Pt4', 'Pt5', 'Pt6', 'Pt7', 'Pt8'
    ]
    for kind_name in kind_names_should:
        assert kind_name in kind_names
    assert len(set(kind_names)) == len(kind_names_should)

    struc_b_site, para_new_site = break_symmetry(structure,
                                                 atoms=[],
                                                 site=[0, 1])
    kind_names = [x.kind_name for x in struc_b_site.sites]
    kind_names_should = ['Fe', 'Fe1', 'Fe2', 'Pt']
    for kind_name in kind_names_should:
        assert kind_name in kind_names
    assert len(set(kind_names)) == len(kind_names_should)

    pos = [structure.sites[0].position, structure.sites[1].position]

    struc_b_pos, para_new_pos = break_symmetry(structure, atoms=[], pos=pos)
    kind_names = [x.kind_name for x in struc_b_pos.sites]
    kind_names_should = ['Fe', 'Fe1', 'Fe2', 'Pt']
    for kind_name in kind_names_should:
        assert kind_name in kind_names
    assert len(set(kind_names)) == len(kind_names_should)
Ejemplo n.º 3
0
def test_find_primitive_cell_wf(generate_structure):
    from aiida_fleur.tools.StructureData_util import find_primitive_cell_wf, supercell_ncf
    from aiida_fleur.tools.StructureData_util import find_primitive_cells

    structure_primitive = generate_structure()
    structure = supercell_ncf(structure_primitive, 2, 2, 22)

    result = find_primitive_cell_wf(structure)
    result = result['primitive_cell']

    assert all(x in structure_primitive.cell for x in result.cell)

    resultlist = find_primitive_cells([structure.uuid, structure.uuid])
    for struc in resultlist:
        assert all(x in structure_primitive.cell for x in result.cell)
Ejemplo n.º 4
0
def test_find_equi_atoms(generate_film_structure):
    """Test if find_equi_atoms functions returns equidistant atoms"""
    from aiida_fleur.tools.StructureData_util import find_equi_atoms, supercell_ncf
    from numpy import array

    structure = generate_film_structure()
    structure = supercell_ncf(structure, 2, 2, 1)
    equi_info_symbol, n_equi_info_symbol = find_equi_atoms(structure)

    assert equi_info_symbol[0][0] == 'Fe'
    assert (equi_info_symbol[0][1] == array([0, 1, 6, 7])).all()
    assert equi_info_symbol[1][0] == 'Pt'
    assert (equi_info_symbol[1][1] == array([2, 3, 8, 9])).all()
    assert equi_info_symbol[2][0] == 'Pt'
    assert (equi_info_symbol[2][1] == array([4, 5, 10, 11])).all()

    assert n_equi_info_symbol == {'Fe': 1, 'Pt': 2}