def test_pourbaix(): """Test ZnO system from docs.""" refs = solvated('Zn') print(refs) refs += [('Zn', 0.0), ('ZnO', -3.323), ('ZnO2(aq)', -2.921)] pb = Pourbaix(refs, formula='ZnO') _, e = pb.decompose(-1.0, 7.0) assert e == pytest.approx(-3.625, abs=0.001) U = np.linspace(-2, 2, 3) pH = np.linspace(6, 16, 11) d, names, text = pb.diagram(U, pH, plot=False) print(d, names, text) assert d.shape == (3, 11) assert d.ptp() == 6 assert names == ['Zn', 'ZnO2(aq)', 'Zn++(aq)', 'HZnO2-(aq)', 'ZnOH+(aq)', 'ZnO', 'ZnO2--(aq)']
# creates: zno.png import numpy as np import matplotlib.pyplot as plt from ase.phasediagram import Pourbaix, solvated refs = solvated('Zn') print(refs) refs += [('Zn', 0.0), ('ZnO', -3.323), ('ZnO2(aq)', -2.921)] pb = Pourbaix(refs, Zn=1, O=1) print(pb.decompose(1.0, 9.0)) U = np.linspace(-2, 2, 200) pH = np.linspace(-2, 16, 300) d, names, text = pb.diagram(U, pH, plot=True, show=False) print(names, text) assert len(names) == 7 plt.savefig('zno.png')
energy = 0.0 refs.append((refcount, energy)) if 1: refs = [#({'O': 1}, 0.0), ('O4Ti2', -17.511826939900217), ('Sr4O4', -20.474907588620653), ('Sr4', 0.0), ('Ti2', 0.0)] else: refs = [({'O': 1}, 0.0), ({'Zn': 1}, 0.0), ({'Zn': 2, 'O': 2}, -5.33991412178575), ({'Zn': 4, 'O': 8}, -7.594)] pb = Pourbaix(refs + solvated('SrTi'), Sr=1, Ti=1, O=3) #pb = Pourbaix(refs, Zn=1, O=1) print(pb.decompose(0, 9)) pH = np.linspace(-1, 15, 17) if 0: d, names = pb.diagram([0], pH) print(d) print('\n'.join(names)) U = np.linspace(-2, 2, 5) if 0: d, names = pb.diagram(U, [0]) for i, u in zip(d, U): print(u, names[i]) if 1: U = np.linspace(-3, 3, 200)
# creates: SrTiO3_pourbaix.png import numpy as np import ase.db from ase.phasediagram import Pourbaix, solvated con = ase.db.connect('cubic_perovskites.db') refs = [] for row in con.select('reference'): refs.append((row.formula, row.standard_energy)) # Add other solid/dissolved phases not included before: refs += [('Ti6O', -5.443), ('Ti2O3', -13.907), ('Ti2O', -5.164), ('TiO', -4.838), ('SrO2', -5.356), ('Ti3O', -5.346), ('Ti3O5', -22.917), ('Sr4Ti3O10', -50.756), ('SrTi11O20', -93.313)] # Extract the dissolved phases: refs += solvated('SrTi') pb = Pourbaix(refs, Sr=1, Ti=1, O=3) U = np.linspace(-2, 2, 200) pH = np.linspace(-2, 15, 300) d, names, text = pb.diagram(U, pH, plot=True, show=False) import matplotlib.pyplot as plt plt.savefig('SrTiO3_pourbaix.png')
# creates: zno.png from ase.phasediagram import Pourbaix, solvated refs = solvated('Zn') print(refs) refs += [('Zn', 0.0), ('ZnO', -3.323), ('ZnO2(aq)', -2.921)] pb = Pourbaix(refs, Zn=1, O=1) print(pb.decompose(1.0, 9.0)) import numpy as np U = np.linspace(-2, 2, 200) pH = np.linspace(-2, 16, 300) d, names, text = pb.diagram(U, pH, plot=True) import matplotlib.pyplot as plt plt.savefig('zno.png')
('Sr4', 0.0), ('Ti2', 0.0) ] else: refs = [({ 'O': 1 }, 0.0), ({ 'Zn': 1 }, 0.0), ({ 'Zn': 2, 'O': 2 }, -5.33991412178575), ({ 'Zn': 4, 'O': 8 }, -7.594)] pb = Pourbaix(refs + solvated('SrTi'), Sr=1, Ti=1, O=3) #pb = Pourbaix(refs, Zn=1, O=1) print(pb.decompose(0, 9)) pH = np.linspace(-1, 15, 17) if 0: d, names = pb.diagram([0], pH) print(d) print('\n'.join(names)) U = np.linspace(-2, 2, 5) if 0: d, names = pb.diagram(U, [0]) for i, u in zip(d, U): print(u, names[i]) if 1: U = np.linspace(-3, 3, 200)
row.CB_ind <= 0 - E0 and row.VB_ind >= 1.23 - E0) or \ (row.gllbsc_dir_gap >= 1.4 and row.gllbsc_dir_gap <= 3.1 and row.CB_dir <= 0 - E0 and row.VB_dir >= 1.23 - E0): name = row.A_ion + row.B_ion + row.anion energy = row.standard_energy info.append([name, row.gllbsc_ind_gap + E0, row.gllbsc_dir_gap + E0, row.VB_ind + E0, row.CB_ind + E0, row.VB_dir + E0, row.CB_dir + E0]) refs = [] for row_ref in con.select('reference'): refs.append((row_ref.formula, row_ref.standard_energy)) # Extract the dissolved phases: refs += solvated(row.A_ion + row.B_ion) for U in Us: pb = Pourbaix(refs, name) results, refs_energy = pb.decompose(U, pH, verbose=False) Ediff = (energy - refs_energy) / 5 Ediff = min(Ediff, ub) Ediff = max(Ediff, lb) xs.append(len(info) - 1) ys.append(U) heats.append(Ediff) import matplotlib.pyplot as plt import matplotlib.cm as cm from matplotlib.collections import PatchCollection import matplotlib.patches as patches