Beispiel #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
Beispiel #2
0
def eos_structures_nocf(inp_structure, scalelist):
    """
    Creates many rescalled StructureData nodes out of a crystal structure.
    Does NOT keep the provenance in the database.

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

    :returns: dict of New StructureData nodes with rescalled structure, key=scale
    """
    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:
        structure_rescaled = rescale_nowf(structure, scale)  # this is not a cf
        re_structures[scale] = structure_rescaled

    return re_structures
Beispiel #3
0
def create_eos_result_node(**kwargs):
    """
    This is a pseudo cf, to create the right graph structure of AiiDA.
    This calcfunction will create the output nodes in the database.
    It also connects the output_nodes to all nodes the information comes from.
    This includes the output_parameter node for the eos, connections to run scfs,
    and returning of the gs_structure (best scale)
    So far it is just parsed in as kwargs argument, because 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.clone()
    # 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_nowf(structure, Float(gs_scaling))
        outdict['gs_structure'] = gs_structure

    return outdict