Exemplo n.º 1
0
    def process_item(self, item):
        """
        Process the list of entries into a phase diagram

        Args:
            item (set(entry)): a list of entries to process into a phase diagram
            
        Returns:
            [dict]: a list of thermo dictionaries to update thermo with
        """
        entries = self.__compat.process_entries(item)
        try:
            pd = PhaseDiagram(entries)
            analyzer = PDAnalyzer(pd)

            docs = []

            for e in entries:
                (decomp, ehull) = \
                    analyzer.get_decomp_and_e_above_hull(e)

                d = {"material_id": e.entry_id}
                d["thermo"] = {}
                d["thermo"][
                    "formation_energy_per_atom"] = pd.get_form_energy_per_atom(
                        e)
                d["thermo"]["e_above_hull"] = ehull
                d["thermo"]["is_stable"] = e in stable_entries
                d["thermo"][
                    "eq_reaction_e"] = analyzer.get_equilibrium_reaction_energy(
                        e)
                d["thermo"]["decomposes_to"] = [{
                    "material_id": de.entry_id,
                    "formula": de.composition.formula,
                    "amount": amt
                } for de, amt in decomp.items()]
                docs.append(d)
        except PhaseDiagramError as p:
            self.__logger.warning("Phase diagram error: {}".format(p))
            return []

        return docs
Exemplo n.º 2
0
# # visualize quaternary phase diagrams
# plotter_lda = PDPlotter(pd_lda,show_unstable = 200)
# plotter_lda.show()
# plotter_pbe = PDPlotter(pd_pbe,show_unstable = 200)
# plotter_pbe.show()
#

# printing results of the phase diagram
data_lda = collections.defaultdict(list)
data_pbe = collections.defaultdict(list)

print("LDA Phase diagram")
for e in entries_lda:
    decomp, ehull = a_lda.get_decomp_and_e_above_hull(e)
    formen = pd_lda.get_form_energy_per_atom(e)
    data_lda["Composition"].append(e.composition.reduced_formula)
    data_lda["Ehull (meV/atom)"].append(ehull * 13.605698066 * 1000)
    data_lda["Decomposition"].append(" + ".join(
        ["%.2f %s" % (v, k.composition.formula) for k, v in decomp.items()]))
    data_lda["Formation Energy (eV/atom)"].append(formen * 13.605698066)

df1 = DataFrame(data_lda,
                columns=[
                    "Composition", "Ehull (meV/atom)",
                    "Formation Energy (eV/atom)", "Decomposition"
                ])

print(df1)
print(" ")
print(" ")
Exemplo n.º 3
0
        ll = line.tolist()
    else:
        ll = line

    lt = [[ll[0][0], ll[1][0]], [ll[0][1], ll[1][1]]]

    lines_array.append(lt)
result["lines"] = lines_array

# stable labels
labels_array = []
for a in phase.stable_entries:
    a_dict = dict()
    a_dict["materialid"] = a.entry_id
    a_dict["name"] = a.name
    a_dict["formation_energy_per_atom"] = phase.get_form_energy_per_atom(a)
    a_dict["is_element"] = True

    for coord, entry in stable.items():
        if a.name == entry.name:
            a_dict["x"] = coord[0]
            a_dict["y"] = coord[1]

    # decomp, e_above_hull 받기
    decomp, e_above_hull = pda.get_decomp_and_e_above_hull(a)
    #pretty_decomp = [("{}:{}".format(k.composition.reduced_formula, k.entry_id), round(v, 2)) for k, v in decomp.items()]
    a_dict["reduced_formula"] = a.composition.reduced_formula
    a_dict["e_above_hull"] = e_above_hull
    #a_dict["pretty_decomp"] = pretty_decomp

    labels_array.append(a_dict)