Exemple #1
0
    def __str__(self):
        """String representation."""
        table = [list(self.fields.keys())]
        for it in range(self.num_iterations):
            row = map(str, (self[k][it] for k in self.keys()))
            table.append(row)

        stream = StringIO()
        pprint_table(table, out=stream)
        stream.seek(0)

        return "".join(stream)
Exemple #2
0
    def __str__(self):
        """String representation."""
        table = [list(self.fields.keys())]
        for it in range(self.num_iterations):
            row = map(str, (self[k][it] for k in self.keys()))
            table.append(row)

        stream = StringIO()
        pprint_table(table, out=stream)
        stream.seek(0)

        return "".join(stream)
Exemple #3
0
def compute_hints(ecut_list, etotal, atols_mev, pseudo, min_numpts=1, stream=sys.stdout):
    de_low, de_normal, de_high = [a / (1000 * Ha_eV) for a in atols_mev]

    num_ene = len(etotal)
    etotal_inf = etotal[-1]

    ihigh   = check_conv(etotal, de_high, min_numpts=min_numpts)
    inormal = check_conv(etotal, de_normal)
    ilow    = check_conv(etotal, de_low)

    accidx = {"H": ihigh, "N": inormal, "L": ilow}

    table = []
    app = table.append

    app(["iter", "ecut", "etotal", "et-e_inf [meV]", "accuracy",])
    for idx, (ec, et) in enumerate(zip(ecut_list, etotal)):
        line = "%d %.1f %.7f %.3f" % (idx, ec, et, (et-etotal_inf)* Ha_eV * 1.e+3)
        row = line.split() + ["".join(c for c,v in accidx.items() if v == idx)]
        app(row)

    if stream is not None:
        from pymatgen.util.string_utils import pprint_table
        stream.write("pseudo: %s\n" % pseudo.name)
        pprint_table(table, out=stream)

    ecut_high, ecut_normal, ecut_low = 3 * (None,)
    exit = (ihigh != -1)

    if exit:
        ecut_low    = ecut_list[ilow]
        ecut_normal = ecut_list[inormal]
        ecut_high   = ecut_list[ihigh]

    aug_ratios = [1,]
    aug_ratio_low, aug_ratio_normal, aug_ratio_high = 3 * (1,)

    data = {
        "exit"       : ihigh != -1,
        "etotal"     : list(etotal),
        "ecut_list"  : ecut_list,
        "aug_ratios" : aug_ratios,
        "low"        : {"ecut": ecut_low, "aug_ratio": aug_ratio_low},
        "normal"     : {"ecut": ecut_normal, "aug_ratio": aug_ratio_normal},
        "high"       : {"ecut": ecut_high, "aug_ratio": aug_ratio_high},
        "pseudo_name": pseudo.name,
        "pseudo_path": pseudo.path,
        "atols_mev"  : atols_mev,
        "dojo_level" : 0,
    }

    return data
Exemple #4
0
    def show_intrawork_deps(self):
        """Show the dependencies within the `Workflow`."""
        table = [["Task #"] + [str(i) for i in range(len(self))]]

        for ii, task1 in enumerate(self):
            line = (1 + len(self)) * [""]
            line[0] = str(ii)
            for jj, task2 in enumerate(self):
                if task1.depends_on(task2):
                    line[jj+1] = "^"

            table.append(line)

        pprint_table(table)
Exemple #5
0
    def show_status(self, stream=sys.stdout):
        """
        Report the status of the workflows and the status 
        of the different tasks on the specified stream.
        """
        for i, work in enumerate(self):
            print(80 * "=")
            print("Workflow #%d: %s, Finalized=%s\n" %
                  (i, work, work.finalized))

            table = [[
                "Task", "Status", "Queue_id", "Errors", "Warnings", "Comments",
                "MPI", "OMP", "num_restarts", "max_restarts", "Task Class"
            ]]

            for task in work:
                task_name = os.path.basename(task.name)

                # Parse the events in the main output.
                report = task.get_event_report()

                events = map(str, 3 * ["N/A"])
                if report is not None:
                    events = map(str, [
                        report.num_errors, report.num_warnings,
                        report.num_comments
                    ])

                cpu_info = map(str, [task.mpi_ncpus, task.omp_ncpus])
                task_info = map(str, [
                    task.num_restarts, task.max_num_restarts,
                    task.__class__.__name__
                ])

                table.append([task_name,
                              str(task.status),
                              str(task.queue_id)] + events + cpu_info +
                             task_info)

            pprint_table(table, out=stream)
Exemple #6
0
    def show_status(self, stream=sys.stdout):
        """
        Report the status of the workflows and the status 
        of the different tasks on the specified stream.
        """
        for i, work in enumerate(self):
            print(80*"=")
            print("Workflow #%d: %s, Finalized=%s\n" % (i, work, work.finalized) )

            table = [[
                     "Task", "Status", "Queue_id", 
                     "Errors", "Warnings", "Comments", 
                     "MPI", "OMP", 
                     "num_restarts", "max_restarts", "Task Class"
                     ]]

            for task in work:
                task_name = os.path.basename(task.name)

                # Parse the events in the main output.
                report = task.get_event_report()

                events = map(str, 3*["N/A"])
                if report is not None: 
                    events = map(str, [report.num_errors, report.num_warnings, report.num_comments])

                cpu_info = map(str, [task.mpi_ncpus, task.omp_ncpus])
                task_info = map(str, [task.num_restarts, task.max_num_restarts, task.__class__.__name__])

                table.append(
                    [task_name, str(task.status), str(task.queue_id)] + 
                    events + 
                    cpu_info + 
                    task_info
                    )

            pprint_table(table, out=stream)
Exemple #7
0
 def print_table(self, stream=sys.stdout):
     pprint_table(self.to_table(), out=stream)
Exemple #8
0
def compute_hints(ecut_list,
                  etotal,
                  atols_mev,
                  pseudo,
                  min_numpts=1,
                  stream=sys.stdout):
    de_low, de_normal, de_high = [a / (1000 * Ha_eV) for a in atols_mev]

    num_ene = len(etotal)
    etotal_inf = etotal[-1]

    ihigh = check_conv(etotal, de_high, min_numpts=min_numpts)
    inormal = check_conv(etotal, de_normal)
    ilow = check_conv(etotal, de_low)

    accidx = {"H": ihigh, "N": inormal, "L": ilow}

    table = []
    app = table.append

    app([
        "iter",
        "ecut",
        "etotal",
        "et-e_inf [meV]",
        "accuracy",
    ])
    for idx, (ec, et) in enumerate(zip(ecut_list, etotal)):
        line = "%d %.1f %.7f %.3f" % (idx, ec, et,
                                      (et - etotal_inf) * Ha_eV * 1.e+3)
        row = line.split() + [
            "".join(c for c, v in accidx.items() if v == idx)
        ]
        app(row)

    if stream is not None:
        from pymatgen.util.string_utils import pprint_table
        stream.write("pseudo: %s\n" % pseudo.name)
        pprint_table(table, out=stream)

    ecut_high, ecut_normal, ecut_low = 3 * (None, )
    exit = (ihigh != -1)

    if exit:
        ecut_low = ecut_list[ilow]
        ecut_normal = ecut_list[inormal]
        ecut_high = ecut_list[ihigh]

    aug_ratios = [
        1,
    ]
    aug_ratio_low, aug_ratio_normal, aug_ratio_high = 3 * (1, )

    data = {
        "exit": ihigh != -1,
        "etotal": list(etotal),
        "ecut_list": ecut_list,
        "aug_ratios": aug_ratios,
        "low": {
            "ecut": ecut_low,
            "aug_ratio": aug_ratio_low
        },
        "normal": {
            "ecut": ecut_normal,
            "aug_ratio": aug_ratio_normal
        },
        "high": {
            "ecut": ecut_high,
            "aug_ratio": aug_ratio_high
        },
        "pseudo_name": pseudo.name,
        "pseudo_path": pseudo.path,
        "atols_mev": atols_mev,
        "dojo_level": 0,
    }

    return data