Пример #1
0
def test(vasp_files):
    d = vasp_files / "KInO2_Va_O_2"
    defect_entry: DefectEntry = loadfn(d / "Va_O1_2/defect_entry.json")
    calc_results: CalcResults = loadfn(d / "Va_O1_2/calc_results.json")
    perfect_calc_results: CalcResults = loadfn(d / "perfect_calc_results.json")
    unitcell: Unitcell = loadfn(d / "unitcell.json")

    make_efnv_correction(defect_entry.charge,
                         calc_results,
                         perfect_calc_results,
                         unitcell.dielectric_constant,
                         1)
Пример #2
0
    def _inner(_dir: Path):
        calc_results = get_calc_results(_dir, args.check_calc_results)
        defect_entry = loadfn(_dir / "defect_entry.json")
        efnv = make_efnv_correction(defect_entry.charge, calc_results,
                                    args.perfect_calc_results,
                                    args.unitcell.dielectric_constant)
        efnv.to_json_file(_dir / "correction.json")

        title = defect_entry.full_name
        plotter = SitePotentialMplPlotter.from_efnv_corr(title=title,
                                                         efnv_correction=efnv)
        plotter.construct_plot()
        plotter.plt.savefig(fname=_dir / "correction.pdf")
        plotter.plt.clf()
Пример #3
0
def make_efnv_correction_from_vasp(args):
    for d in args.dirs:
        logger.info(f"Parsing data in {d} ...")
        defect_entry: DefectEntry = loadfn(d / "defect_entry.json")
        calc_results = loadfn(d / "calc_results.json")
        efnv = make_efnv_correction(defect_entry.charge, calc_results,
                                    args.perfect_calc_results,
                                    args.unitcell.dielectric_constant)
        efnv.to_json_file(d / "correction.json")

        title = defect_entry.full_name
        plotter = SitePotentialMplPlotter.from_efnv_corr(title=title,
                                                         efnv_correction=efnv)
        plotter.construct_plot()
        plotter.plt.savefig(fname=d / "correction.pdf")
        plotter.plt.clf()
Пример #4
0
def test_make_efnv_correction(mocker):
    mock_perfect = mocker.Mock(spec=CalcResults, autospec=True)
    mock_defect = mocker.Mock(spec=CalcResults, autospec=True)

    mock_perfect.structure = IStructure(Lattice.cubic(10),
                                        species=["H"] + ["He"] * 3 + ["Li"],
                                        coords=[[0, 0, 0], [1 / 2, 1 / 2, 0],
                                                [1 / 2, 0, 1 / 2],
                                                [0, 1 / 2, 1 / 2],
                                                [0, 0, 1 / 2]])
    mock_defect.structure = IStructure(Lattice.cubic(10),
                                       species=["He"] * 3 + ["Li"],
                                       coords=[[1 / 2, 1 / 2, 0],
                                               [1 / 2, 0, 1 / 2],
                                               [0, 1 / 2, 1 / 2],
                                               [0, 0, 1 / 2]])
    mock_perfect.potentials = [3.0, 4.0, 5.0, 6.0, 7.0]
    mock_defect.potentials = [14.0, 25.0, 36.0, 47.0]

    mock_ewald = mocker.patch("pydefect.cli.vasp.make_efnv_correction.Ewald")
    ewald = mocker.Mock()
    ewald.lattice_energy = 1e3
    ewald.atomic_site_potential.return_value = 1e4
    mock_ewald.return_value = ewald

    efnvc = make_efnv_correction(charge=2,
                                 calc_results=mock_defect,
                                 perfect_calc_results=mock_perfect,
                                 dielectric_tensor=np.eye(3))

    unit_conversion = 180.95128169876497

    assert efnvc.charge == 2
    assert efnvc.point_charge_correction == -4e3 * unit_conversion
    assert efnvc.defect_region_radius == 5.0
    assert efnvc.sites == [
        PotentialSite("He", 5 * np.sqrt(2), 10.0, 2e4 * unit_conversion),
        PotentialSite("He", 5 * np.sqrt(2), 20.0, 2e4 * unit_conversion),
        PotentialSite("He", 5 * np.sqrt(2), 30.0, 2e4 * unit_conversion),
        PotentialSite("Li", 5.0, 40.0, None),
    ]