예제 #1
0
def test_potcar_from_node(potcar_family):
    """Create a PotcarIo instance from a PotcarData node."""
    potcar_ga = get_data_class('vasp.potcar').find_one(element='Ga')
    from_ctor = PotcarIo(potcar_node=potcar_ga)
    verify_potcario(from_ctor)
    from_from = PotcarIo.from_(potcar_ga)
    assert from_ctor == from_from
예제 #2
0
def test_potcar_from_file_node(potcar_family):
    """Create a PotcarIo instance from a PotcarFileData node."""
    potcar_file_in = get_data_class('vasp.potcar_file').find_one(element='In')
    from_ctor = PotcarIo(potcar_file_node=potcar_file_in)
    verify_potcario(from_ctor)
    from_from = PotcarIo.from_(potcar_file_in)
    assert from_ctor == from_from
예제 #3
0
def test_potcar_from_path(aiida_env):
    """Create a PotcarIo instance from a file path."""
    potcar_path_as = data_path('potcar', 'As', 'POTCAR')
    from_ctor = PotcarIo(path=potcar_path_as)
    from_from = PotcarIo.from_(potcar_path_as)
    verify_potcario(from_from)
    assert from_ctor == from_from
예제 #4
0
def test_potcar_from_contents(potcar_family):
    """Create a PotcarIo from contents of a POTCAR file."""
    contents_as = read_file('potcar', 'As', 'POTCAR')
    from_ctor = PotcarIo(contents=contents_as)
    verify_potcario(from_ctor)
    assert from_ctor.node.uuid == get_data_class('vasp.potcar').find_one(element='As').uuid
    from_from = PotcarIo.from_(contents_as)
    assert from_ctor == from_from
예제 #5
0
def mock_vasp():
    """Verify input files are parseable and copy in output files."""
    from aiida.common.setup import AIIDA_CONFIG_FOLDER
    pwd = py_path.local('.')

    aiida_path = py_path.local(AIIDA_CONFIG_FOLDER)
    aiida_cfg = aiida_path.join('config.json')
    click.echo('DEBUG: AIIDA_PATH = {}'.format(os.environ.get('AIIDA_PATH')))
    click.echo('DEBUG: AIIDA_CONFIG_FOLDER = {}'.format(aiida_path.strpath))
    assert aiida_path.isdir()
    assert aiida_cfg.isfile()
    click.echo(aiida_cfg.read())

    incar = pwd.join('INCAR')
    assert incar.isfile(), 'INCAR input file was not found.'

    potcar = pwd.join('POTCAR')
    assert potcar.isfile(), 'POTCAR input file not found.'

    poscar = pwd.join('POSCAR')
    assert poscar.isfile(), 'POSCAR input file not found.'

    kpoints = pwd.join('KPOINTS')
    assert kpoints.isfile(), 'KPOINTS input file not found.'

    incar_parser = IncarParser(file_path=incar.strpath)
    assert incar_parser, 'INCAR could not be parsed.'
    assert PotcarIo(path=potcar.strpath), 'POTCAR could not be parsed.'
    assert PoscarParser(
        file_path=poscar.strpath), 'POSCAR could not be parsed.'
    assert KpParser(file_path=kpoints.strpath), 'KPOINTS could not be parsed.'

    system = incar_parser.get_quantity('incar', {})['incar'].get_dict().get(
        'system', '')
    test_case = re.findall(r'test-case:(.*)$', system)

    if not test_case:
        output_file('outcar', 'OUTCAR').copy(pwd.join('OUTCAR'))
        output_file('vasprun', 'vasprun.xml').copy(pwd.join('vasprun.xml'))
        output_file('chgcar', 'CHGCAR').copy(pwd.join('CHGCAR'))
        output_file('wavecar', 'WAVECAR').copy(pwd.join('WAVECAR'))
        output_file('eigenval', 'EIGENVAL').copy(pwd.join('EIGENVAL'))
        output_file('doscar', 'DOSCAR').copy(pwd.join('DOSCAR'))
        poscar.copy(pwd.join('CONTCAR'))
    else:
        test_case = test_case[0]
        test_data_path = py_path.local(data_path(test_case)).join('out')
        for out_file in test_data_path.listdir():
            out_file.copy(pwd)
예제 #6
0
def test_file_contents_equivalence(aiida_env):
    potcar_path_as = ['potcar', 'As', 'POTCAR']
    from_file = PotcarIo(path=data_path(*potcar_path_as))
    from_contents = PotcarIo(contents=read_file(*potcar_path_as))
    assert from_file.md5 == from_contents.md5
예제 #7
0
def potcar_attr(potcar, attribute):
    """Extract the number of valence electrons from a PotcarData object."""
    from aiida_vasp.io.potcar import PotcarIo

    potcar_io = PotcarIo.from_(potcar)
    return getattr(potcar_io.pymatgen, attribute)