Exemplo n.º 1
0
 def energy_fig(self, abs_chem_pot, label):
     single_energies = []
     for d, e, c in zip(self.defects, self.defect_entries,
                        self.corrections):
         single_energies.append(
             make_single_defect_energy(self.perfect, d, e, abs_chem_pot, c))
     defect_energies = make_defect_energies(single_energies)
     plotter = DefectEnergyPlotlyPlotter(title=f"Label {label[0]}",
                                         defect_energies=defect_energies,
                                         vbm=self.perfect.vbm,
                                         cbm=self.perfect.cbm,
                                         supercell_vbm=self.perfect.vbm,
                                         supercell_cbm=self.perfect.cbm)
     return plotter.create_figure()
Exemplo n.º 2
0
def test_generate_defect_energies():
    defect_energies = [
        SingleDefectEnergy("Va_O1", 0, -1, 1),
        SingleDefectEnergy("Va_Mg1", 0, -2, 2),
        SingleDefectEnergy("Va_O1", 1, 7, 3),
        SingleDefectEnergy("Va_Mg1", -1, -14, 4),
        SingleDefectEnergy("Va_O1", 2, 15, 5),
        SingleDefectEnergy("Va_Mg1", -2, -14, 6)
    ]
    actual = make_defect_energies(defect_energies)
    expected = [
        DefectEnergy("Va_Mg1", [0, -1, -2], [-2, -14, -14], [2, 4, 6]),
        DefectEnergy("Va_O1", [0, 1, 2], [-1, 7, 15], [1, 3, 5])
    ]
    assert actual == expected
Exemplo n.º 3
0
def make_defect_formation_energy(args):
    title = latexify(
        args.perfect_calc_results.structure.composition.reduced_formula)
    chem_pot_diag = ChemPotDiag.from_yaml(args.chem_pot_diag)
    abs_chem_pot = chem_pot_diag.abs_chem_pot_dict(args.label)

    single_energies = []
    for d in args.dirs:
        if args.skip_shallow and loadfn(
                d / "band_edge_states.json").is_shallow:
            continue
        single_energies.append(
            make_single_defect_energy(args.perfect_calc_results,
                                      loadfn(d / "calc_results.json"),
                                      loadfn(d / "defect_entry.json"),
                                      abs_chem_pot,
                                      loadfn(d / "correction.json")))

    defect_energies = make_defect_energies(single_energies)
    if args.print:
        print("         charge          E_f   correction    ")
        for e in defect_energies:
            print(e)
            print("")

        print("-- cross points -- ")
        for e in defect_energies:
            print(e.name)
            print(e.cross_points(args.unitcell.vbm, args.unitcell.cbm))
            print("")
        return

    plotter = DefectEnergyMplPlotter(
        title=title,
        defect_energies=defect_energies,
        vbm=args.unitcell.vbm,
        cbm=args.unitcell.cbm,
        supercell_vbm=args.perfect_calc_results.vbm,
        supercell_cbm=args.perfect_calc_results.cbm,
        y_range=args.y_range)

    plotter.construct_plot()
    plotter.plt.savefig(f"energy_{args.label}.pdf")