Exemple #1
0
def test_potcar_from_linklist(with_pbe_potcars, multi_component_structure):
    from aiida_cusp.data.inputs.vasp_potcar import VaspPotcarFile
    from aiida_cusp.data.inputs.vasp_poscar import VaspPoscarData
    poscar = VaspPoscarData(structure=multi_component_structure)
    potmap = VaspPotcarData.from_structure(multi_component_structure, 'pbe')
    complete_potcar = VaspPotcarData.potcar_from_linklist(poscar, potmap)
    # build the expected potcar
    potcar_contents = []
    for symbol in poscar.get_poscar().site_symbols:
        potcar_file = VaspPotcarFile.from_tags(name=symbol)[0]
        potcar_contents.append(potcar_file.get_content())
    expected_potcar_contents = "\n".join(potcar_contents) + "\n"
    assert str(complete_potcar) == expected_potcar_contents
Exemple #2
0
def test_potcar_from_linklist_raises_on_missing(symbol, with_pbe_potcars,
                                                multi_component_structure):
    from aiida_cusp.data.inputs.vasp_potcar import VaspPotcarData
    from aiida_cusp.utils.exceptions import VaspPotcarDataError
    poscar = VaspPoscarData(structure=multi_component_structure)
    potmap = VaspPotcarData.from_structure(multi_component_structure, 'pbe')
    # pop an arbitrary potential from the map and check that the call to
    # potcar_from_linklist() fails for the given structure
    potmap.pop(symbol)
    expected_error = ("Found no potential in passed potential-element map for "
                      "site symbol '{}'".format(symbol))
    with pytest.raises(VaspPotcarDataError) as exception:
        _ = VaspPotcarData.potcar_from_linklist(poscar, potmap)
    assert str(exception.value) == expected_error