Esempio n. 1
0
def test_rescale_nowf(generate_structure):
    """Test to rescale some structure """
    from aiida_fleur.tools.StructureData_util import rescale_nowf
    from aiida_fleur.tools.StructureData_util import rescale
    from aiida.orm import Dict, Float

    structure = generate_structure()
    old_cell = np.array(structure.cell)

    rescaled = rescale_nowf(structure, 1.05)
    rescaled2 = rescale(structure, Float(1.05))
    rescaled_cell = np.array(rescaled.cell)
    rescaled_cell2 = np.array(rescaled2.cell)

    assert (rescaled_cell == 1.05**(1 / 3.) * old_cell).all()
    #assert (np.round(rescaled_cell2, 13) == 1.05**(1 / 3.) * old_cell).all()
    # This does not work, seems to check if it is the same object, not if values are the same
    # The precision between these functions is strangely different
    assert list(np.round(rescaled_cell[0], 13)) == list(rescaled_cell2[0])
    assert list(np.round(rescaled_cell[1], 13)) == list(rescaled_cell2[1])
    assert list(np.round(rescaled_cell[2], 13)) == list(rescaled_cell2[2])

    positions_old = [x.position for x in structure.sites]
    positions_rescaled = [x.position for x in rescaled.sites]
    for position in positions_old:
        assert tuple(pos * 1.05**(1 / 3.)
                     for pos in position) in positions_rescaled

    no_struc = Dict(dict={})
    no_rescaled = rescale_nowf(no_struc, 1.05)
    assert no_rescaled is None
Esempio n. 2
0
def eos_structures(inp_structure, scalelist):
    """
    Creates many rescalled StrucutureData nodes out of a crystal structure.
    Keeps the provanance in the database.

    :param StructureData, a StructureData node (pk, sor uuid)
    :param scalelist, list of floats, scaling factors for the cell

    :returns: list of New StructureData nodes with rescalled structure, which are linked to input Structure
    """
    structure = is_structure(inp_structure)
    if not structure:
        #TODO: log something (test if it gets here at all)
        return None
    re_structures = []

    for scale in scalelist:
        s = rescale(structure, Float(scale)) # this is a wf
        re_structures.append(s)

    return re_structures
Esempio n. 3
0
def create_eos_result_node(**kwargs):
    """
    This is a pseudo wf, to create the rigth graph structure of AiiDA.
    This wokfunction will create the output node in the database.
    It also connects the output_node to all nodes the information commes from.
    So far it is just also parsed in as argument, because so far we are to lazy
    to put most of the code overworked from return_results in here.
    """
    outdict = {}
    outpara = kwargs.get('results_node', {})
    outdict['output_eos_wc_para'] = outpara.copy()
    # copy, because we rather produce the same node twice
    # then have a circle in the database for now...
    outputdict = outpara.get_dict()
    structure = load_node(outputdict.get('initial_structure'))
    gs_scaling = outputdict.get('scaling_gs', 0)
    if gs_scaling:
        gs_structure = rescale(structure, Float(gs_scaling))
        outdict['gs_structure'] = gs_structure

    return outdict