Esempio n. 1
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()
Esempio n. 2
0
def test_make_recommended_supercell(simple_cubic, simple_cubic_2x2x2, tmpdir):
    args = Namespace(unitcell=simple_cubic, matrix=None, min_num_atoms=8, max_num_atoms=8)

    tmpdir.chdir()
    make_supercell(args)
    info = loadfn("supercell_info.json")
    assert IStructure.from_file("SPOSCAR") == simple_cubic_2x2x2
    assert info.structure == simple_cubic_2x2x2
    assert info.transformation_matrix == [[2, 0, 0], [0, 2, 0], [0, 0, 2]]
Esempio n. 3
0
def test_make_supercell_from_matrix(simple_cubic, simple_cubic_2x1x1, tmpdir):
    matrix = [2, 1, 1]
    args = Namespace(unitcell=simple_cubic, matrix=matrix, min_num_atoms=None, max_num_atoms=None)

    tmpdir.chdir()
    make_supercell(args)
    info = loadfn("supercell_info.json")
    assert IStructure.from_file("SPOSCAR") == simple_cubic_2x1x1
    assert info.structure == simple_cubic_2x1x1
    assert info.transformation_matrix == [[2, 0, 0], [0, 1, 0], [0, 0, 1]]