Ejemplo n.º 1
0
def run(args):
    """Runs the matdb setup and cleanup to produce database files.
    """
    print("matdb  Copyright (C) 2019  HALL LABS")
    print("This program comes with ABSOLUTELY NO WARRANTY.")
    print(
        "This is free software, and you are welcome to redistribute it under "
        "certain conditions.")
    if args is None:
        return

    #No matter what other options the user has chosen, we will have to create a
    #database controller for the specification they have given us.

    cdb = Controller(args["dbspec"])

    matches = []
    configs = AtomsList()
    for pattern in args["p"]:
        for entry in cdb.find(pattern):
            for iatoms in entry.iconfigs:
                configs.append(iatoms)

    if args["format"] == "xyz":
        from matdb.conversion import to_xyz
        target = path.abspath(path.expanduser(args["o"]))
        to_xyz(configs, target, args["overwrite"])
Ejemplo n.º 2
0
def run(args):
    """Runs the matdb setup and cleanup to produce database files.
    """
    print("matdb  Copyright (C) 2019  HALL LABS")
    print("This program comes with ABSOLUTELY NO WARRANTY.")
    print(
        "This is free software, and you are welcome to redistribute it under "
        "certain conditions.")
    if args is None:
        return

    matplotlib.use('Agg')
    #No matter what other options the user has chosen, we will have to create a
    #database controller for the specification they have given us.
    from matdb.database import Controller
    cdb = Controller(args["dbspec"])

    #We allow any number of databases to be plotted together at the same
    #tame. The `s` argument gives a `fnmatch` pattern for database paths.
    #For example `Pd.phonon-2.dynmatrix` specifies the dynamical matrix *step*
    #for suffix `2` of the phonon *database* of configuration `Pd`.
    dbs = []
    if args["d"]:
        for dbp in args["d"]:
            dbs.extend(cdb.find(dbp))

    pots = []
    if args["pots"]:
        for potp in args["pots"]:
            pots.extend(cdb.trainers.find(potp))

    if args["generic"]:

        objs = dbs + pots
        from matdb.plotting.plotter import PlotManager
        manager = PlotManager(cdb)
        for cname in args["generic"]:
            manager.plot(objs, cname)

    if args["bands"]:
        from matdb.plotting.comparative import band_plot
        band_plot(dbs, pots, **args)

    if args["generate"]:
        if len(pots) > 1:
            raise ValueError("Generate only operates for a single trainer "
                             "at a time; don't specify so many patterns.")
        pot = pots[0]
        _generate_pkl(pot, dbs, **args)

    if args["html"]:
        _generate_html(pots, **args)
Ejemplo n.º 3
0
def Pd_db(tmpdir):
    from matdb.utility import relpath, reporoot
    from matdb.database import Controller
    from os import mkdir

    target = relpath("./tests/Pd/matdb")
    dbdir = str(tmpdir.join("pd_db"))
    mkdir(dbdir)

    #We need to copy the POSCAR over from the testing directory to the temporary
    #one.
    from shutil import copy
    POSCAR = relpath("./tests/Pd/POSCAR")
    copy(POSCAR, dbdir)

    Pd = Controller(target, dbdir)
    Pd.setup()

    #First, we need to copy the FORCE_SETS and total_dos.dat files so that we
    #don't have to recompile those (they are tested elsewhere).
    from matdb.utility import symlink
    troot = path.join(reporoot, "tests", "data", "Pd", "dynmatrix")
    files = ["FORCE_SETS", "total_dos.dat", "mesh.yaml"]
    for seq in Pd.find("Pd.phonon-*.dynmatrix"):
        for filename in files:
            target = path.join(seq.root, "phonopy", filename)
            source = path.join(troot,
                               "{0}__{1}".format(filename, seq.parent.name))
            symlink(target, source)

    Pd.cleanup()
    Pd.setup()

    files = ["OUTCAR", "output.xyz"]
    seq = Pd["Pd.modulate.modulations"]
    troot = path.join(reporoot, "tests", "data", "Pd", "modulations")
    for i in range(1, 6):
        key = "M.{0:d}".format(i)
        for filename in files:
            target = path.join(seq.root, key, filename)
            source = path.join(troot, "{0}__{1}".format(filename, key))
            symlink(target, source)

    return Pd
Ejemplo n.º 4
0
def run(args):
    """Runs the matdb setup and cleanup to produce database files.
    """
    print("matdb  Copyright (C) 2019  HALL LABS")
    print("This program comes with ABSOLUTELY NO WARRANTY.")
    print(
        "This is free software, and you are welcome to redistribute it under "
        "certain conditions.")
    if args is None:
        return

    #No matter what other options the user has chosen, we will have to create a
    #database controller for the specification they have given us.
    from matdb.database import Controller
    cdb = Controller(args["dbspec"])

    matches = []
    for pattern in args["p"]:
        for entry in cdb.find(pattern):
            matches.append(entry)

    for db in matches:
        _fix_precomp(db)