コード例 #1
0
ファイル: cmd_upf.py プロジェクト: chrisjsewell/aiida_core
def exportfamily(folder, group_name):
    """
    Export a pseudopotential family into a folder.
    Call without parameters to get some help.
    """
    import os
    from aiida.common.exceptions import NotExistent
    from aiida.orm import DataFactory

    # pylint: disable=invalid-name
    UpfData = DataFactory('upf')
    try:
        group = UpfData.get_upf_group(group_name)
    except NotExistent:
        echo.echo_critical("upf family {} not found".format(group_name))

    # pylint: disable=protected-access
    for node in group.nodes:
        dest_path = os.path.join(folder, node.filename)
        if not os.path.isfile(dest_path):
            with open(dest_path, 'w') as dest:
                with node._get_folder_pathsubfolder.open(
                        node.filename) as source:
                    dest.write(source.read())
        else:
            echo.echo_warning("File {} is already present in the "
                              "destination folder".format(node.filename))
コード例 #2
0
ファイル: test_pw.py プロジェクト: nvarini/aiida_core
if auto_pseudos:
    valid_pseudo_groups = UpfData.get_upf_groups(filter_elements=elements)

    try:
        pseudo_family = sys.argv[3]
    except IndexError:
        print >> sys.stderr, "Error, auto_pseudos set to True. You therefore need to pass as second parameter"
        print >> sys.stderr, "the pseudo family name."
        print >> sys.stderr, "Valid UPF families are:"
        print >> sys.stderr, "\n".join("* {}".format(i.name)
                                       for i in valid_pseudo_groups)
        sys.exit(1)

    try:
        UpfData.get_upf_group(pseudo_family)
    except NotExistent:
        print >> sys.stderr, "auto_pseudos is set to True and pseudo_family='{}',".format(
            pseudo_family)
        print >> sys.stderr, "but no group with such a name found in the DB."
        print >> sys.stderr, "Valid UPF groups are:"
        print >> sys.stderr, ",".join(i.name for i in valid_pseudo_groups)
        sys.exit(1)

parameters = ParameterData(
    dict={
        'CONTROL': {
            'calculation': 'scf',
            'restart_mode': 'from_scratch',
            'wf_collect': True,
            'tstress': True,