Пример #1
0
    def test_read_write_csv(self):
        Zn_solids = ["Zn", "ZnO", "ZnO2"]
        sol_g = [0.0, -3.338, -1.315]
        Zn_ions = ["Zn[2+]", "ZnOH[+]", "HZnO2[-]", "ZnO2[2-]", "ZnO"]
        liq_g = [-1.527, -3.415, -4.812, -4.036, -2.921]
        liq_conc = [1e-6, 1e-6, 1e-6, 1e-6, 1e-6]
        solid_entry = list()
        for sol in Zn_solids:
            comp = Composition(sol)
            delg = sol_g[Zn_solids.index(sol)]
            solid_entry.append(PourbaixEntry(PDEntry(comp, delg)))
        ion_entry = list()
        for ion in Zn_ions:
            comp_ion = Ion.from_formula(ion)
            delg = liq_g[Zn_ions.index(ion)]
            conc = liq_conc[Zn_ions.index(ion)]
            PoE = PourbaixEntry(IonEntry(comp_ion, delg))
            PoE.set_conc(conc)
            ion_entry.append(PoE)
        entries = solid_entry + ion_entry
        PourbaixEntryIO.to_csv("pourbaix_test_entries.csv", entries)

        (elements, entries) = PourbaixEntryIO.from_csv(
            "pourbaix_test_entries.csv")
        self.assertEqual(elements,
                         [Element('Zn'), Element('H'), Element('O')],
                         "Wrong elements!")
        self.assertEqual(len(entries), 8, "Wrong number of entries!")
        os.remove("pourbaix_test_entries.csv")
Пример #2
0
    def test_read_write_csv(self):
        Zn_solids = ["Zn", "ZnO", "ZnO2"]
        sol_g = [0.0, -3.338, -1.315]
        Zn_ions = ["Zn[2+]", "ZnOH[+]", "HZnO2[-]", "ZnO2[2-]", "ZnO"]
        liq_g = [-1.527, -3.415, -4.812, -4.036, -2.921]
        liq_conc = [1e-6, 1e-6, 1e-6, 1e-6, 1e-6]
        solid_entry = list()
        for sol in Zn_solids:
            comp = Composition(sol)
            delg = sol_g[Zn_solids.index(sol)]
            solid_entry.append(PourbaixEntry(PDEntry(comp, delg)))
        ion_entry = list()
        for ion in Zn_ions:
            comp_ion = Ion.from_formula(ion)
            delg = liq_g[Zn_ions.index(ion)]
            conc = liq_conc[Zn_ions.index(ion)]
            PoE = PourbaixEntry(IonEntry(comp_ion, delg))
            PoE.conc = conc
            ion_entry.append(PoE)
        entries = solid_entry + ion_entry
        PourbaixEntryIO.to_csv("pourbaix_test_entries.csv", entries)

        (elements,
         entries) = PourbaixEntryIO.from_csv("pourbaix_test_entries.csv")
        self.assertEqual(
            elements, [Element('Zn'),
                       Element('H'), Element('O')], "Wrong elements!")
        self.assertEqual(len(entries), 8, "Wrong number of entries!")
        os.remove("pourbaix_test_entries.csv")
Пример #3
0
 def setUp(self):
     module_dir = os.path.dirname(os.path.abspath(__file__))
     (elements, entries) = PourbaixEntryIO.from_csv(
         os.path.join(module_dir, "test_entries.csv"))
     self.num_simplices = {
         "Zn(s)": 7,
         "ZnO2(s)": 7,
         "Zn[2+]": 4,
         "ZnO2[2-]": 4,
         "ZnHO2[-]": 4
     }
     self.e_above_hull_test = {"ZnHO[+]": 0.0693, "ZnO(aq)": 0.0624}
     self.decomp_test = {
         "ZnHO[+]": {
             "ZnO(s)": 0.5,
             "Zn[2+]": 0.5
         },
         "ZnO(aq)": {
             "ZnO(s)": 1.0
         }
     }
     self.pd = PourbaixDiagram(entries)
     self.analyzer = PourbaixAnalyzer(self.pd)
     self.multi_data = loadfn(os.path.join(test_dir, 'multicomp_pbx.json'))
     warnings.simplefilter("ignore")
Пример #4
0
 def setUp(self):
     module_dir = os.path.dirname(os.path.abspath(__file__))
     (elements, entries) = PourbaixEntryIO.from_csv(os.path.join(module_dir,
                                                 "test_entries.csv"))
     self._entries = entries
     self._pd = PourbaixDiagram(entries)
     self.list_of_stable_entries = ["ZnO(s)", "Zn[2+]", "ZnO2(s)", "ZnHO2[-]", "ZnO2[2-]", "Zn(s)"]
Пример #5
0
 def setUp(self):
     module_dir = os.path.dirname(os.path.abspath(__file__))
     (elements, entries) = PourbaixEntryIO.from_csv(
         os.path.join(module_dir, "test_entries.csv"))
     self._entries = entries
     self._pd = PourbaixDiagram(entries)
     self.list_of_stable_entries = [
         "ZnO(s)", "Zn[2+]", "ZnO2(s)", "ZnHO2[-]", "ZnO2[2-]", "Zn(s)"
     ]
Пример #6
0
 def setUp(self):
     module_dir = os.path.dirname(os.path.abspath(__file__))
     (elements, entries) = PourbaixEntryIO.from_csv(os.path.join(module_dir,
                                                 "test_entries.csv"))
     self.num_simplices = {"Zn(s)": 7, "ZnO2(s)": 7, "Zn[2+]": 4, "ZnO2[2-]": 4, "ZnHO2[-]": 4}
     self.e_above_hull_test = {"ZnHO[+]": 0.0693, "ZnO(aq)": 0.0624}
     self.decomp_test = {"ZnHO[+]": {"ZnO(s)": 0.5, "Zn[2+]": 0.5}, "ZnO(aq)": {"ZnO(s)": 1.0}}
     self.pd = PourbaixDiagram(entries)
     self.analyzer = PourbaixAnalyzer(self.pd)
Пример #7
0
    def setUp(self):
        warnings.simplefilter("ignore")

        module_dir = os.path.dirname(os.path.abspath(__file__))
        (elements, entries) = PourbaixEntryIO.from_csv(os.path.join(module_dir,
                                                    "test_entries.csv"))
        self.num_simplices = {"Zn(s)": 7, "ZnO2(s)": 7, "Zn[2+]": 4, "ZnO2[2-]": 4, "ZnHO2[-]": 4}
        self.e_above_hull_test = {"ZnHO[+]": 0.0693, "ZnO(aq)": 0.0624}
        self.decomp_test = {"ZnHO[+]": {"ZnO(s)": 0.5, "Zn[2+]": 0.5}, "ZnO(aq)": {"ZnO(s)": 1.0}}
        self.pd = PourbaixDiagram(entries)
        self.multi_data = loadfn(os.path.join(test_dir, 'multicomp_pbx.json'))
        self.plotter = PourbaixPlotter(self.pd)
Пример #8
0
 def setUp(self):
     module_dir = os.path.dirname(os.path.abspath(__file__))
     (elements, entries) = PourbaixEntryIO.from_csv(
         os.path.join(module_dir, "test_entries.csv"))
     self.num_simplices = {
         "Zn(s)": 7,
         "ZnO2(s)": 7,
         "Zn[2+]": 4,
         "ZnO2[2-]": 4,
         "ZnHO2[-]": 4
     }
     self.e_above_hull_test = {"ZnHO[+]": 0.0693, "ZnO(aq)": 0.0624}
     self.decomp_test = {
         "ZnHO[+]": {
             "ZnO(s)": 0.5,
             "Zn[2+]": 0.5
         },
         "ZnO(aq)": {
             "ZnO(s)": 1.0
         }
     }
     self.pd = PourbaixDiagram(entries)
     self.plotter = PourbaixPlotter(self.pd)
Пример #9
0
 def setUp(self):
     module_dir = os.path.dirname(os.path.abspath(__file__))
     (elements, entries) = PourbaixEntryIO.from_csv(
         os.path.join(module_dir, "test_entries.csv"))
     self._entries = entries
     self._pd = PourbaixDiagram(entries)
Пример #10
0
 def setUp(self):
     module_dir = os.path.dirname(os.path.abspath(__file__))
     (elements, entries) = PourbaixEntryIO.from_csv(os.path.join(module_dir,
                                                 "test_entries.csv"))
     self._entries = entries
     self._pd = PourbaixDiagram(entries)
Пример #11
0
Created on Wed Feb 28 15:40:02 2018

@author: jherfson
"""
from pymatgen.analysis.pourbaix.entry import PourbaixEntry, IonEntry  #, MultiEntry
from pymatgen.analysis.pourbaix.entry import PourbaixEntryIO
from pymatgen.analysis.phase_diagram import PDEntry
from pymatgen.core.ion import Ion
from pymatgen.core.structure import Composition

Zn_solids = ["Zn", "ZnO", "ZnO2"]
sol_g = [0.0, -3.338, -1.315]
Zn_ions = ["Zn[2+]", "ZnOH[+]", "HZnO2[-]", "ZnO2[2-]", "ZnO"]
liq_g = [-1.527, -3.415, -4.812, -4.036, -2.921]
liq_conc = [1e-6, 1e-6, 1e-6, 1e-6, 1e-6]
solid_entry = list()
for sol in Zn_solids:
    comp = Composition(sol)
    delg = sol_g[Zn_solids.index(sol)]
    solid_entry.append(PourbaixEntry(PDEntry(comp, delg)))
ion_entry = list()
for ion in Zn_ions:
    comp_ion = Ion.from_formula(ion)
    delg = liq_g[Zn_ions.index(ion)]
    conc = liq_conc[Zn_ions.index(ion)]
    PoE = PourbaixEntry(IonEntry(comp_ion, delg))
    PoE.conc = conc
    ion_entry.append(PoE)
entries = solid_entry + ion_entry
PourbaixEntryIO.to_csv("pourbaix_test_entries.csv", entries)