Esempio n. 1
0
def main():
    info()
    parser = argparse.ArgumentParser(description="""
    dpgen is a convenient script that uses DeepGenerator to prepare initial
    data, drive DeepMDkit and analyze results. This script works based on
    several sub-commands with their own options. To see the options for the
    sub-commands, type "dpgen sub-command -h".""",
                                     epilog="""
    Author: DeepGenTeam
    Version: {}
    Last updated: {}""".format(__version__, __date__))

    subparsers = parser.add_subparsers()

    # init surf model
    parser_init_surf = subparsers.add_parser(
        "init_surf", help="Generating initial data for surface systems.")
    parser_init_surf.add_argument('PARAM',
                                  type=str,
                                  help="parameter file, json/yaml format")
    parser_init_surf.add_argument('MACHINE',
                                  type=str,
                                  default=None,
                                  nargs="?",
                                  help="machine file, json/yaml format")
    parser_init_surf.set_defaults(func=gen_init_surf)

    # init bulk model
    parser_init_bulk = subparsers.add_parser(
        "init_bulk", help="Generating initial data for bulk systems.")
    parser_init_bulk.add_argument('PARAM',
                                  type=str,
                                  help="parameter file, json/yaml format")
    parser_init_bulk.add_argument('MACHINE',
                                  type=str,
                                  default=None,
                                  nargs="?",
                                  help="machine file, json/yaml format")
    parser_init_bulk.set_defaults(func=gen_init_bulk)
    # parser_init.add_argument("-p",'--parameter', type=str, dest='param',
    #                     help="parameter file, json/yaml format")
    # parser_init.add_argument("-s","--stage", type=int, dest='stage',
    #                     help="the stage of init, can be 1, 2, 3 or 4. "
    #                     "1: Setup vasp jobs for relaxation. "
    #                     "2: Collect vasp relaxed confs (if relax is not skiped). Perturb system. "
    #                     "3: Setup vasp jobs for MD of perturbed system. "
    #                     "4: Collect vasp md confs, make deepmd data. ")
    # parser_init.add_argument("directories", metavar="dir", default=".",
    #                             type=str, nargs="*",
    #                             help="directory to process (default to .)")
    # parser_init.set_defaults(func=gen_data)

    # run
    parser_run = subparsers.add_parser("run",
                                       help="Main process of Deep Generator.")
    parser_run.add_argument('PARAM',
                            type=str,
                            help="parameter file, json/yaml format")
    parser_run.add_argument('MACHINE',
                            type=str,
                            help="machine file, json/yaml format")
    parser_run.add_argument('-d',
                            '--debug',
                            action='store_true',
                            help="log debug info")
    parser_run.set_defaults(func=gen_run)

    # test
    parser_test = subparsers.add_parser("test",
                                        help="Auto-test for Deep Potential.")
    parser_test.add_argument('PARAM',
                             type=str,
                             help="parameter file, json/yaml format")
    parser_test.add_argument('MACHINE',
                             type=str,
                             help="machine file, json/yaml format")
    parser_test.set_defaults(func=gen_test)

    # db
    parser_db = subparsers.add_parser(
        "db", help="Collecting data from Deep Generator.")
    parser_db.add_argument('PATH',
                           type=str,
                           help="root path for dpgen modeling")
    parser_db.add_argument(
        'CALCULATOR',
        type=str,
        help="calculator used for labeling: vasp/pwscf/gaussian")
    parser_db.add_argument('OUTPUT',
                           type=str,
                           help="output filename : file.json/file.yaml")
    parser_db.add_argument("ID_PREFIX",
                           type=str,
                           default=None,
                           nargs="?",
                           help="prefix of an  entry id")

    parser_db.set_defaults(func=db_run)

    try:
        import argcomplete
        argcomplete.autocomplete(parser)
    except ImportError:
        # argcomplete not present.
        pass

    args = parser.parse_args()

    try:
        getattr(args, "func")
    except AttributeError:
        parser.print_help()
        sys.exit(0)
    args.func(args)
Esempio n. 2
0
def main():
    info()
    print("Description\n------------")
    parser = argparse.ArgumentParser(description="""
    dpgen is a convenient script that uses DeepGenerator to prepare initial
    data, drive DeepMDkit and analyze results. This script works based on
    several sub-commands with their own options. To see the options for the
    sub-commands, type "dpgen sub-command -h".""")

    subparsers = parser.add_subparsers()

    # init surf model
    parser_init_surf = subparsers.add_parser(
        "init_surf", help="Generating initial data for surface systems.")
    parser_init_surf.add_argument('PARAM',
                                  type=str,
                                  help="parameter file, json/yaml format")
    parser_init_surf.add_argument('MACHINE',
                                  type=str,
                                  default=None,
                                  nargs="?",
                                  help="machine file, json/yaml format")
    parser_init_surf.set_defaults(func=gen_init_surf)

    # init bulk model
    parser_init_bulk = subparsers.add_parser(
        "init_bulk", help="Generating initial data for bulk systems.")
    parser_init_bulk.add_argument('PARAM',
                                  type=str,
                                  help="parameter file, json/yaml format")
    parser_init_bulk.add_argument('MACHINE',
                                  type=str,
                                  default=None,
                                  nargs="?",
                                  help="machine file, json/yaml format")
    parser_init_bulk.set_defaults(func=gen_init_bulk)

    parser_auto_gen_param = subparsers.add_parser("auto_gen_param",
                                                  help="auto gen param.json")
    # parser_auto_gen_param.add_argument('meltpoint', type=float, help="melt point")
    parser_auto_gen_param.add_argument('PARAM',
                                       type=str,
                                       help="parameter file, json/yaml format")
    parser_auto_gen_param.set_defaults(func=auto_gen_param)

    # parser_init_reaction
    parser_init_reaction = subparsers.add_parser(
        "init_reaction", help="Generating initial data for reactive systems.")
    parser_init_reaction.add_argument('PARAM',
                                      type=str,
                                      help="parameter file, json/yaml format")
    parser_init_reaction.add_argument('MACHINE',
                                      type=str,
                                      default=None,
                                      nargs="?",
                                      help="machine file, json/yaml format")
    parser_init_reaction.set_defaults(func=gen_init_reaction)

    # run
    parser_run = subparsers.add_parser(
        "run", help="Main process of Deep Potential Generator.")
    parser_run.add_argument('PARAM',
                            type=str,
                            help="parameter file, json/yaml format")
    parser_run.add_argument('MACHINE',
                            type=str,
                            help="machine file, json/yaml format")
    parser_run.add_argument('-d',
                            '--debug',
                            action='store_true',
                            help="log debug info")
    parser_run.set_defaults(func=gen_run)

    # run/report
    parser_rr = subparsers.add_parser(
        "run/report",
        help=
        "Report the systems and the thermodynamic conditions of the labeled frames."
    )
    parser_rr.add_argument("JOB_DIR",
                           type=str,
                           help="the directory of the DP-GEN job,")
    parser_rr.add_argument('-s',
                           "--stat-sys",
                           action='store_true',
                           help="count the labeled frames for each system")
    parser_rr.add_argument(
        '-i',
        "--stat-iter",
        action='store_true',
        help=
        "print the iteration candidate,failed,accurate count and fp calculation,success and fail count"
    )
    parser_rr.add_argument(
        '-t',
        "--stat-time",
        action='store_true',
        help=
        "print the iteration time, warning!! assume model_devi parallel cores == 1"
    )
    parser_rr.add_argument(
        '-p',
        "--param",
        type=str,
        default='param.json',
        help=
        "the json file provides DP-GEN paramters, should be located in JOB_DIR"
    )
    parser_rr.add_argument('-v',
                           "--verbose",
                           action='store_true',
                           help="being loud")
    parser_rr.set_defaults(func=run_report)

    # collect
    parser_coll = subparsers.add_parser("collect", help="Collect data.")
    parser_coll.add_argument("JOB_DIR",
                             type=str,
                             help="the directory of the DP-GEN job")
    parser_coll.add_argument("OUTPUT",
                             type=str,
                             help="the output directory of data")
    parser_coll.add_argument(
        '-p',
        "--parameter",
        type=str,
        default='param.json',
        help=
        "the json file provides DP-GEN paramters, should be located in JOB_DIR"
    )
    parser_coll.add_argument('-v',
                             "--verbose",
                             action='store_true',
                             help="print number of data in each system")
    parser_coll.add_argument(
        '-m',
        "--merge",
        action='store_true',
        help="merge the systems with the same chemical formula")
    parser_coll.add_argument('-s',
                             "--shuffle",
                             action='store_true',
                             help="shuffle the data systems")
    parser_coll.set_defaults(func=gen_collect)

    # simplify
    parser_run = subparsers.add_parser("simplify", help="Simplify data.")
    parser_run.add_argument('PARAM',
                            type=str,
                            help="parameter file, json/yaml format")
    parser_run.add_argument('MACHINE',
                            type=str,
                            help="machine file, json/yaml format")
    parser_run.add_argument('-d',
                            '--debug',
                            action='store_true',
                            help="log debug info")
    parser_run.set_defaults(func=gen_simplify)

    # test
    parser_test = subparsers.add_parser("autotest",
                                        help="Auto-test for Deep Potential.")
    parser_test.add_argument('TASK',
                             type=str,
                             help="task can be make, run or post")
    parser_test.add_argument('PARAM',
                             type=str,
                             help="parameter file, json/yaml format")
    parser_test.add_argument('MACHINE',
                             type=str,
                             default=None,
                             nargs="?",
                             help="machine file, json/yaml format")
    parser_test.add_argument('-d',
                             '--debug',
                             action='store_true',
                             help="log debug info")
    parser_test.set_defaults(func=gen_test)

    # db
    parser_db = subparsers.add_parser("db",
                                      help="Collecting data from DP-GEN.")

    parser_db.add_argument('PARAM',
                           type=str,
                           help="parameter file, json format")

    parser_db.set_defaults(func=db_run)

    try:
        import argcomplete
        argcomplete.autocomplete(parser)
    except ImportError:
        # argcomplete not present.
        pass

    args = parser.parse_args()

    try:
        getattr(args, "func")
    except AttributeError:
        parser.print_help()
        sys.exit(0)
    args.func(args)
Esempio n. 3
0
def main():
    info()
    print("Description\n------------")
    parser = argparse.ArgumentParser(description="""
    dpgen is a convenient script that uses DeepGenerator to prepare initial
    data, drive DeepMDkit and analyze results. This script works based on
    several sub-commands with their own options. To see the options for the
    sub-commands, type "dpgen sub-command -h".""")

    subparsers = parser.add_subparsers()

    # init surf model
    parser_init_surf = subparsers.add_parser(
        "init_surf", help="Generating initial data for surface systems.")
    parser_init_surf.add_argument('PARAM', type=str, 
                             help="parameter file, json/yaml format")
    parser_init_surf.add_argument('MACHINE', type=str,default=None,nargs="?",
                        help="machine file, json/yaml format")
    parser_init_surf.set_defaults(func=gen_init_surf)
    
    # init bulk model
    parser_init_bulk = subparsers.add_parser(
        "init_bulk", help="Generating initial data for bulk systems.")
    parser_init_bulk.add_argument('PARAM', type=str, 
                             help="parameter file, json/yaml format")
    parser_init_bulk.add_argument('MACHINE', type=str,default=None,nargs="?",
                        help="machine file, json/yaml format")
    parser_init_bulk.set_defaults(func=gen_init_bulk)

    parser_auto_gen_param = subparsers.add_parser(
        "auto_gen_param", help="auto gen param.json")
    # parser_auto_gen_param.add_argument('meltpoint', type=float, help="melt point")
    parser_auto_gen_param.add_argument('PARAM', type=str, 
                        help="parameter file, json/yaml format")
    parser_auto_gen_param.set_defaults(func=auto_gen_param)
    # parser_init.add_argument("-p",'--parameter', type=str, dest='param',
    #                     help="parameter file, json/yaml format")
    # parser_init.add_argument("-s","--stage", type=int, dest='stage',
    #                     help="the stage of init, can be 1, 2, 3 or 4. "
    #                     "1: Setup vasp jobs for relaxation. "
    #                     "2: Collect vasp relaxed confs (if relax is not skiped). Perturb system. "
    #                     "3: Setup vasp jobs for MD of perturbed system. "
    #                     "4: Collect vasp md confs, make deepmd data. ")
    # parser_init.add_argument("directories", metavar="dir", default=".",
    #                             type=str, nargs="*",
    #                             help="directory to process (default to .)")
    # parser_init.set_defaults(func=gen_data)

    parser_init_reaction = subparsers.add_parser(
        "init_reaction", help="Generating initial data for reactive systems.")
    parser_init_reaction.add_argument('PARAM', type=str, 
                             help="parameter file, json/yaml format")
    parser_init_reaction.add_argument('MACHINE', type=str,default=None,nargs="?",
                        help="machine file, json/yaml format")
    parser_init_reaction.set_defaults(func=gen_init_reaction)

    # run 
    parser_run = subparsers.add_parser(
        "run",
        help="Main process of Deep Potential Generator.")
    parser_run.add_argument('PARAM', type=str,
                        help="parameter file, json/yaml format")
    parser_run.add_argument('MACHINE', type=str,
                        help="machine file, json/yaml format")
    parser_run.add_argument('-d','--debug', action='store_true',
                        help="log debug info")
    parser_run.set_defaults(func=gen_run)

    # run/report
    parser_rr = subparsers.add_parser(
        "run/report",
        help="Report the systems and the thermodynamic conditions of the labeled frames.")
    parser_rr.add_argument("JOB_DIR", type=str, 
                           help="the directory of the DP-GEN job,")
    parser_rr.add_argument('-s',"--stat-sys", action = 'store_true',
                           help="count the labeled frames for each system")
    parser_rr.add_argument('-i', "--stat-iter", action= 'store_true',
                            help="print the iteration candidate,failed,accurate count and fp calculation,success and fail count")
    parser_rr.add_argument('-t', "--stat-time", action= 'store_true',
                            help="print the iteration time, warning!! assume model_devi parallel cores == 1")
    parser_rr.add_argument('-p',"--param", type=str, default = 'param.json',
                           help="the json file provides DP-GEN paramters, should be located in JOB_DIR")
    parser_rr.add_argument('-v',"--verbose", action = 'store_true',
                           help="being loud")
    parser_rr.set_defaults(func=run_report)    

    # test 
    parser_test = subparsers.add_parser("test", help="Auto-test for Deep Potential.")
    parser_test.add_argument('PARAM', type=str,
                        help="parameter file, json/yaml format")
    parser_test.add_argument('MACHINE', type=str,
                        help="machine file, json/yaml format")
    parser_test.set_defaults(func=gen_test)    

    # db 
    parser_db = subparsers.add_parser(
        "db",
        help="Collecting data from DP-GEN.")

    parser_db.add_argument('PARAM', type=str,
                        help="parameter file, json format")

    parser_db.set_defaults(func=db_run)


    try:
        import argcomplete
        argcomplete.autocomplete(parser)
    except ImportError:
        # argcomplete not present.
        pass

    args = parser.parse_args()

    try:
        getattr(args, "func")
    except AttributeError:
        parser.print_help()
        sys.exit(0)
    args.func(args)
Esempio n. 4
0
def main():
    info()
    parser = argparse.ArgumentParser(description="""
    dpgen is a convenient script that uses DeepGenerator to prepare initial
    data, drive DeepMDkit and analyze results. This script works based on
    several sub-commands with their own options. To see the options for the
    sub-commands, type "dpgen sub-command -h".""",
                                     epilog="""
    Author: DeepGenTeam
    Version: {}
    Last updated: {}""".format(__version__, __date__))

    subparsers = parser.add_subparsers()

    # init surf model
    parser_init_surf = subparsers.add_parser(
        "init_surf", help="dpgen initial data preparation tools for surface systems.")
    parser_init_surf.add_argument('PARAM', type=str, 
                             help="parameter file, json format")
    parser_init_surf.add_argument('STAGE', type=int,
                        help="the stage of init, can be 1 or 2 "
                        "1: Setup vasp jobs for relaxation. "
                        "2: Collect vasp relaxed confs (if relax is not skiped). Perturb system.")
    parser_init_surf.set_defaults(func=gen_init_surf)
    
    # init bulk model
    parser_init_bulk = subparsers.add_parser(
        "init_bulk", help="dpgen initial data preparation tools for bulk systems.")
    parser_init_bulk.add_argument('PARAM', type=str, 
                             help="parameter file, json format")
    parser_init_bulk.add_argument('STAGE', type=int,
                             help="the stage of init, can be 1, 2, 3 or 4. "
                             "1: Setup vasp jobs for relaxation. "
                             "2: Collect vasp relaxed confs (if relax is not skiped). Perturb system. "
                             "3: Setup vasp jobs for MD of perturbed system. "
                             "4: Collect vasp md confs, make deepmd data. "
    )
    parser_init_bulk.set_defaults(func=gen_init_bulk)
    # parser_init.add_argument("-p",'--parameter', type=str, dest='param',
    #                     help="parameter file, json format")
    # parser_init.add_argument("-s","--stage", type=int, dest='stage',
    #                     help="the stage of init, can be 1, 2, 3 or 4. "
    #                     "1: Setup vasp jobs for relaxation. "
    #                     "2: Collect vasp relaxed confs (if relax is not skiped). Perturb system. "
    #                     "3: Setup vasp jobs for MD of perturbed system. "
    #                     "4: Collect vasp md confs, make deepmd data. ")
    # parser_init.add_argument("directories", metavar="dir", default=".",
    #                             type=str, nargs="*",
    #                             help="directory to process (default to .)")
    # parser_init.set_defaults(func=gen_data)

    # run 
    parser_run = subparsers.add_parser(
        "run",
        help="Runing DeepMD with generator model.")
    parser_run.add_argument('PARAM', type=str,
                        help="parameter file, json format")
    parser_run.add_argument('MACHINE', type=str,
                        help="machine file, json format")
    parser_run.set_defaults(func=gen_run)

    # test 
    parser_test = subparsers.add_parser("test", help="auto test for deep potential.")
    parser_test.add_argument('PARAM', type=str,
                        help="parameter file, json format")
    parser_test.add_argument('MACHINE', type=str,
                        help="machine file, json format")
    parser_test.set_defaults(func=gen_test)

    # # convert  model
    # parser_structure = subparsers.add_parser(
    #     "struct",
    #     help="structure conversion and analysis tools.")

    # parser_structure.add_argument(
    #     "-f", "--filenames", dest="filenames",
    #     metavar="filename", nargs="+",
    #     help="List of structure files.")

    # groups = parser_structure.add_mutually_exclusive_group(required=True)
    # groups.add_argument("-c", "--convert", dest="convert", action="store_true",
    #                     help="Convert from structure file 1 to structure "
    #                          "file 2. Format determined from filename. "
    #                          "Supported formats include POSCAR/CONTCAR, "
    #                          "CIF, lmp.")
    # groups.add_argument("-s", "--symmetry", dest="symmetry",
    #                     metavar="tolerance", type=float,
    #                    help="Determine the spacegroup using the "
    #                          "specified tolerance. 0.1 is usually a good "
    #                          "value for DFT calculations.")
    # parser_structure.set_defaults(func=gen_struct)


    try:
        import argcomplete
        argcomplete.autocomplete(parser)
    except ImportError:
        # argcomplete not present.
        pass

    args = parser.parse_args()

    try:
        getattr(args, "func")
    except AttributeError:
        parser.print_help()
        sys.exit(0)
    args.func(args)