Skip to content

Commit

Permalink
Pathway plotter.
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep committed Nov 8, 2018
1 parent 3cab68f commit ad86b7e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions pymatgen/analysis/synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def get_pathways(self):
pathways.append(path)

for p in pathways:
ref = p[0].rxn.calculated_reaction_energy
ref = p[-1].rxn.calculated_reaction_energy
for k in p:
print("%s, %.3f" % (k.name, k.rxn.calculated_reaction_energy - ref))

Expand All @@ -114,6 +114,17 @@ def print(self):
print(output)


def plot_pathways(pathways):
from pymatgen.util.plotting import pretty_plot
colors = ["r", "g", "b", "c", "m", "y", "k"]
plt = pretty_plot(12, 8)
for i, p in enumerate(pathways):
for j, k in enumerate(p):
energy = k.rxn.calculated_reaction_energy
plt.plot([j, j+1], [-energy, -energy], color=colors[i % len(colors)], linestyle='solid')
plt.text(j, -energy, k.name)
plt.show()

from pymatgen.util.testing import PymatgenTest


Expand All @@ -140,7 +151,11 @@ def test_func(self):

for rxn in a.get_unique_reactions():
print("%s (avg_nelements = %.2f)" % (rxn.name, rxn.avg_nelements))
rxn_tree.get_pathways()

rxn_tree = PDSynthesisTree(self.lfo_entries, "Li2FeO3")
pathways = rxn_tree.get_pathways()
plot_pathways(pathways)



if __name__ == "__main__":
Expand Down

0 comments on commit ad86b7e

Please sign in to comment.