Ejemplo n.º 1
0
def test_defect_entries_maker(cubic_supercell_info, cubic_supercell, mocker):
    mock = mocker.patch("pydefect.input_maker.defect_entries_maker.defaults")
    mock.displace_distance = 0.0
    defect_set = DefectSet(defects={
        SimpleDefect(None, "H1", [1]),
        SimpleDefect("Ne", "He1", [0])
    })
    maker = DefectEntriesMaker(cubic_supercell_info, defect_set)

    va_h1_str = cubic_supercell.copy()
    va_h1_str.pop(0)
    va_h1_str = to_istructure(va_h1_str)

    ne_he1_str = cubic_supercell.copy()
    coords = ne_he1_str.pop(32).frac_coords
    ne_he1_str.append("Ne", coords)
    ne_he1_str = to_istructure(ne_he1_str)

    defect_entries = {
        DefectEntry("Ne_He1", 0, ne_he1_str, ne_he1_str.copy(), "m-3m",
                    (0.25, 0.0, 0.0)),
        DefectEntry("Va_H1", 1, va_h1_str, va_h1_str.copy(), "m-3m",
                    (0.0, 0.0, 0.0)),
    }

    assert maker.defect_entries == defect_entries
Ejemplo n.º 2
0
def make_defect_entries(args):
    supercell_info: SupercellInfo = loadfn("supercell_info.json")
    perfect = Path("perfect")

    try:
        perfect.mkdir()
        logger.info("Making perfect dir...")
        supercell_info.structure.to(filename=perfect / "POSCAR")
    except FileExistsError:
        logger.info(f"perfect dir exists, so skipped...")

    defect_set = DefectSet.from_yaml()
    maker = DefectEntriesMaker(supercell_info, defect_set)

    for defect_entry in maker.defect_entries:
        dir_path = Path(defect_entry.full_name)
        try:
            dir_path.mkdir()
            logger.info(f"Making {dir_path} dir...")
            if defect_entry.perturbed_structure:
                defect_entry.perturbed_structure.to(filename=dir_path /
                                                    "POSCAR")
            else:
                defect_entry.structure.to(filename=dir_path / "POSCAR")

            defect_entry.to_json_file(filename=dir_path / "defect_entry.json")
            defect_entry.to_prior_info(filename=dir_path / "prior_info.yaml")
        except FileExistsError:
            logger.info(f"{dir_path} dir exists, so skipped...")
Ejemplo n.º 3
0
def test_defect_entries_interstitials(cubic_supercell_info, mocker):
    mock = mocker.patch("pydefect.input_maker.defect_entries_maker.defaults")
    mock.displace_distance = 0.0

    defect_set = DefectSet(defects={SimpleDefect("H", "i1", [0])})
    maker = DefectEntriesMaker(cubic_supercell_info, defect_set)

    defect_entry = maker.defect_entries.pop()
    actual = defect_entry.structure[0].frac_coords
    np.testing.assert_array_equal(actual, [0.25, 0.25, 0.25])
Ejemplo n.º 4
0
def test_defect_entries_maker_insert_host_atoms(cubic_supercell_info, mocker):
    mock = mocker.patch("pydefect.input_maker.defect_entries_maker.defaults")
    mock.displace_distance = 0.0

    defect_set = DefectSet(defects={SimpleDefect("He", "H1", [0]),
                                    SimpleDefect("H", "He1", [0])})
    maker = DefectEntriesMaker(cubic_supercell_info, defect_set)

    for defect_entry in maker.defect_entries:
        if defect_entry.name == "H_He1":
            actual = defect_entry.structure[0].frac_coords
            np.testing.assert_array_equal(actual, [0.25, 0.0, 0.0])
        if defect_entry.name == "He_H1":
            actual = defect_entry.structure[31].frac_coords
            np.testing.assert_array_equal(actual, [0.0, 0.0, 0.0])