Exemplo n.º 1
0
def test_make_defect_entry(defect_entry):
    relaxed_coords = \
        [[0.25, 0.0, 0.0], [0.5, 0.5, 0.0], [0.5, 0.0, 0.5], [0.0, 0.5, 0.5],
         [0.0, 0.0, 0.51], [0.0, 0.51, 0.0], [0.5, 0.0, 0.0], [0.5, 0.5, 0.5]]
    relaxed_defect = IStructure(
        Lattice.cubic(10.0), ["Li"] + ["H"] * 3 + ["He"] * 4, relaxed_coords)

    unrelaxed_coords = \
        [[0.25, 0.0, 0.0], [0.5, 0.5, 0.0], [0.5, 0.0, 0.5], [0.0, 0.5, 0.5],
         [0.0, 0.0, 0.5], [0.0, 0.5, 0.0], [0.5, 0.0, 0.0], [0.5, 0.5, 0.5]]

    unrelaxed_defect = IStructure(
        Lattice.cubic(10.0), ["Li"] + ["H"] * 3 + ["He"] * 4, unrelaxed_coords)

    actual = make_defect_entry(name="Va_O1",
                               charge=1,
                               perfect_structure=perfect,
                               defect_structure=relaxed_defect)

    expected = DefectEntry(name="Va_O1",
                           charge=1,
                           structure=unrelaxed_defect,
                           perturbed_structure=None,
                           site_symmetry="4mm",
                           defect_center=(0.125, 0.0, 0.0))

    assert actual == expected
def make_defect_entry_main(args):
    charge_state = calc_charge_state(args)
    structure = Structure.from_file(args.dir / "POSCAR")
    defect_entry = make_defect_entry(name=args.name,
                                     charge=charge_state,
                                     perfect_structure=args.perfect,
                                     defect_structure=structure)
    defect_entry.to_json_file()
Exemplo n.º 3
0
def make_defect_entry_from_poscars(dirname, perf_poscar, defect_poscar):
    names = dirname.split("_")
    try:
        name = "_".join(names[:-1])
        charge = int(names[-1])
    except ValueError:
        logger.warning(f"Directory name {dirname} is invalid.")
        raise

    perfect = IStructure.from_file(perf_poscar)
    defect = IStructure.from_file(defect_poscar)

    defect_entry = make_defect_entry(name=name,
                                     charge=charge,
                                     perfect_structure=perfect,
                                     defect_structure=defect)
    defect_entry.to_json_file()