def test_break_symmetry_film_parameters_only_complex(generate_film_structure):
    """Test if these break symmetry operation adjusted the complex parameter data right.
    This basicly tests
    from aiida_fleur.tools.StructureData_util import adjust_calc_para_to_structure
    for a separate test we would have to generate these structures again
    """
    from aiida_fleur.tools.StructureData_util import break_symmetry
    from aiida.orm import Dict

    structure = generate_film_structure()
    para = Dict(
        dict={
            'atom': {
                'element': 'Fe',
                'id': 26.1,
                'rmt': 2.1,
                'bmu': -1
            },
            'atom1': {
                'element': 'Pt',
                'id': 78.1,
                'rmt': 2.2,
                'bmu': 1
            },
            'comp': {
                'kmax': 5.0,
            }
        })

    structure_broken, para_out = break_symmetry(structure, parameterdata=para)
    struc_b_fe, para_new_fe = break_symmetry(structure, atoms=['Fe'], parameterdata=para)

    should1 = {
        'atom1': {
            'element': 'Fe',
            'id': '26.1',
            'rmt': 2.1,
            'bmu': -1
        },
        'atom2': {
            'element': 'Pt',
            'id': '78.1',
            'rmt': 2.2,
            'bmu': 1
        },
        'atom3': {
            'element': 'Pt',
            'id': '78.2',
            'rmt': 2.2,
            'bmu': 1
        },
        'comp': {
            'kmax': 5.0,
        }
    }

    assert para_out.get_dict() == should1

    should2 = {'atom1': {'bmu': -1, 'element': 'Fe', 'id': '26.1', 'rmt': 2.1}, 'comp': {'kmax': 5.0}}
    assert para_new_fe.get_dict() == should2
Example #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)
def test_create_corehole_para(generate_structure, data_regression):
    """Test if the create corehole para function has thr right interface and returns
    the correct things
    """
    from aiida_fleur.tools.create_corehole import create_corehole_para
    from aiida_fleur.tools.StructureData_util import break_symmetry

    dict2 = orm.Dict(dict=PARAMETERS2)
    struc = generate_structure()  #Si
    struc2, para_new = break_symmetry(struc, parameterdata=dict2)
    parameters1 = create_corehole_para(struc2,
                                       kind='Si1',
                                       econfig='[He] 2s1 2p6 | 3s2 3p3',
                                       parameterdata=para_new)
    assert isinstance(parameters1, orm.Dict)

    # with no parameterdata to modify
    parameters2 = create_corehole_para(struc2,
                                       kind='Si1',
                                       econfig='[He] 2s1 2p6 | 3s2 3p3')
    assert isinstance(parameters2, orm.Dict)

    data_regression.check({
        'parameters1': parameters1.get_dict(),
        'parameters2': parameters2.get_dict(),
    })
Example #4
0
def test_adjust_calc_para_to_structure(generate_structure):
    """Test intergace of check_structure_para_consistent"""
    from aiida_fleur.tools.StructureData_util import adjust_calc_para_to_structure
    from aiida_fleur.tools.StructureData_util import break_symmetry
    from aiida import orm

    structure = generate_structure()

    parameter_data = orm.Dict(
        dict={
            'atom1': {
                'element': 'Si',
                'rmt': 2.1,
                'jri': 981,
                'lmax': 12,
                'lnonsph': 6
            },
            'comp': {
                'kmax': 5.0,
            }
        })
    new_para = adjust_calc_para_to_structure(parameter_data, structure)
    # The parameter data should not be changed
    assert new_para.get_dict() == parameter_data.get_dict()

    structure_broken, parameters1 = break_symmetry(
        structure, parameterdata=parameter_data)
    new_para = adjust_calc_para_to_structure(parameter_data, structure_broken)
    # The parameter data should be changed and should be the same.
    assert new_para.get_dict() == parameters1.get_dict()
Example #5
0
def test_break_symmetry_corhole(generate_structure):
    """Test if what the corehole workflow does works"""
    from aiida_fleur.tools.StructureData_util import break_symmetry
    from aiida import orm

    structure = generate_structure()
    sites = structure.sites
    pos = sites[0].position
    kind_name = sites[0].kind_name
    para = orm.Dict(
        dict={
            'atom': {
                'element': 'Si',
                'rmt': 2.1,
                'jri': 981,
                'lmax': 12,
                'lnonsph': 6
            },
            'comp': {
                'kmax': 5.0,
            }
        })
    new_kinds_names = {'Si': [kind_name + '_corehole1']}
    inputs = dict(structure=structure,
                  atoms=[],
                  site=[],
                  pos=[(pos[0], pos[1], pos[2])],
                  new_kinds_names=new_kinds_names)
    if para is not None:
        inputs['parameterdata'] = para
    new_struc, new_para = break_symmetry(**inputs)

    #print(new_para.get_dict())
    kind_names = ['Si_corehole1', 'Si']
    for i, site in enumerate(new_struc.sites):
        assert site.kind_name == kind_names[i]

    # Test if the kind name was set to the atom lists
    should = {
        'atom1': {
            'element': 'Si',
            'rmt': 2.1,
            'jri': 981,
            'lmax': 12,
            'lnonsph': 6
        },
        'comp': {
            'kmax': 5.0
        },
        'atom2': {
            'element': 'Si',
            'rmt': 2.1,
            'jri': 981,
            'lmax': 12,
            'lnonsph': 6,
            'id': '14.1',
            'name': 'Si_corehole1'
        }
    }
    assert new_para.get_dict() == should
Example #6
0
def test_check_structure_para_consistent(generate_structure):
    """Test intergace of check_structure_para_consistent"""
    from aiida_fleur.tools.StructureData_util import check_structure_para_consistent
    from aiida_fleur.tools.StructureData_util import break_symmetry
    from aiida import orm

    structure = generate_structure()

    parameter_data = orm.Dict(
        dict={
            'atom': {
                'element': 'Si',
                'rmt': 2.1,
                'jri': 981,
                'lmax': 12,
                'lnonsph': 6
            },
            'comp': {
                'kmax': 5.0,
            }
        })
    assert check_structure_para_consistent(parameter_data, structure)

    structure_broken, parameters1 = break_symmetry(
        structure, parameterdata=parameter_data)
    assert check_structure_para_consistent(parameters1, structure_broken)
    assert check_structure_para_consistent(parameter_data, structure_broken)

    wrong_parameter_data = orm.Dict(
        dict={
            'atom': {
                'element': 'P',
                'rmt': 2.1,
                'jri': 981,
                'lmax': 12,
                'lnonsph': 6
            },
            'comp': {
                'kmax': 5.0,
            }
        })
    assert not check_structure_para_consistent(wrong_parameter_data, structure)
Example #7
0
def test_break_symmetry_film_parameters_only_simple(generate_film_structure):
    """Test if these break symmetry operation adjusted the parameter data right.
    This basicly tests
    from aiida_fleur.tools.StructureData_util import adjust_calc_para_to_structure
    for a separate test we would have to generate these structures again
    """
    from aiida_fleur.tools.StructureData_util import break_symmetry
    from aiida.orm import Dict

    structure = generate_film_structure()
    para = Dict(
        dict={
            'atom': {
                'element': 'Fe',
                'z': 26,
                'rmt': 2.1,
                'bmu': -1
            },
            'atom1': {
                'element': 'Pt',
                'rmt': 2.2,
                'bmu': 1
            },
            'comp': {
                'kmax': 5.0,
            }
        })

    structure_broken, para_out = break_symmetry(structure, parameterdata=para)
    should1 = {
        'atom1': {
            'element': 'Fe',
            'z': 26,
            'rmt': 2.1,
            'bmu': -1
        },
        'atom2': {
            'element': 'Pt',
            'rmt': 2.2,
            'bmu': 1
        },
        'comp': {
            'kmax': 5.0
        },
        'atom3': {
            'element': 'Fe',
            'z': 26,
            'rmt': 2.1,
            'bmu': -1,
            'id': '26.1'
        },
        'atom4': {
            'element': 'Pt',
            'rmt': 2.2,
            'bmu': 1,
            'id': '78.1'
        },
        'atom5': {
            'element': 'Pt',
            'rmt': 2.2,
            'bmu': 1,
            'id': '78.2'
        }
    }
    assert para_out.get_dict() == should1

    # breaking again should not change something
    structure_broken, para_out = break_symmetry(structure_broken,
                                                parameterdata=para_out)
    assert para_out.get_dict() == should1

    should2 = {
        'comp': {
            'kmax': 5.0
        },
        'atom1': {
            'element': 'Fe',
            'z': 26,
            'rmt': 2.1,
            'bmu': -1,
            'id': '26.1'
        },
        'atom2': {
            'element': 'Pt',
            'rmt': 2.2,
            'bmu': 1,
            'id': '78.1'
        },
        'atom3': {
            'element': 'Pt',
            'rmt': 2.2,
            'bmu': 1,
            'id': '78.2'
        }
    }
    structure_broken, para_out = break_symmetry(structure_broken,
                                                parameterdata=para_out,
                                                add_atom_base_lists=False)
    print(para_out.get_dict())
    assert para_out.get_dict() == should2

    struc_b_fe, para_new_fe = break_symmetry(structure,
                                             atoms=['Fe'],
                                             parameterdata=para)

    should3 = {
        'atom1': {
            'element': 'Fe',
            'z': 26,
            'rmt': 2.1,
            'bmu': -1
        },
        'atom2': {
            'element': 'Pt',
            'rmt': 2.2,
            'bmu': 1
        },
        'comp': {
            'kmax': 5.0
        },
        'atom3': {
            'element': 'Fe',
            'z': 26,
            'rmt': 2.1,
            'bmu': -1,
            'id': '26.1'
        }
    }
    assert para_new_fe.get_dict() == should3