Пример #1
0
def remove_nonsaturated_surface_metal_atoms(
    atoms=None,
    dz=None,
    ):
    """
    """
    #| - remove_nonsaturated_surface_metal_atoms

    # #################################################
    # #################################################
    z_positions = atoms.positions[:,2]

    z_max = np.max(z_positions)
    z_min = np.min(z_positions)

    # #################################################
    # #################################################
    df_coord_slab_i = get_structure_coord_df(atoms)

    # #################################################
    metal_atoms_to_remove = []
    for atom in atoms:
        if atom.symbol == metal_atom_symbol:
            z_pos_i = atom.position[2]
            if z_pos_i >= z_max - dz or z_pos_i <= z_min + dz:
                row_coord = df_coord_slab_i[
                    df_coord_slab_i.structure_index == atom.index].iloc[0]
                num_o_neighbors = row_coord.neighbor_count.get("O", 0)

                if num_o_neighbors < 6:
                    metal_atoms_to_remove.append(atom.index)

    slab_new = remove_atoms(atoms=atoms, atoms_to_remove=metal_atoms_to_remove)

    return(slab_new)
Пример #2
0
def remove_noncoord_oxygens(
    atoms=None,
    ):
    """
    """
    #| - remove_noncoord_oxygens
    df_coord_slab_i = get_structure_coord_df(atoms)

    # #########################################################
    df_i = df_coord_slab_i[df_coord_slab_i.element == "O"]
    df_i = df_i[df_i.num_neighbors == 0]

    o_atoms_to_remove = df_i.structure_index.tolist()

    # #########################################################
    o_atoms_to_remove_1 = []
    df_j = df_coord_slab_i[df_coord_slab_i.element == "O"]
    for j_cnt, row_j in  df_j.iterrows():
        neighbor_count = row_j.neighbor_count

        if neighbor_count.get("Ir", 0) == 0:
            if neighbor_count.get("O", 0) == 1:
                o_atoms_to_remove_1.append(row_j.structure_index)


    o_atoms_to_remove = list(set(o_atoms_to_remove + o_atoms_to_remove_1))

    slab_new = remove_atoms(atoms, atoms_to_remove=o_atoms_to_remove)

    return(slab_new)
Пример #3
0
def get_df_coord_local(
    name=None,
    ads=None,
    atoms=None,
    append_str=None,
):
    """
    """
    # | - get_df_coord_local

    directory = os.path.join(os.environ["PROJ_irox_oer"],
                             "workflow/seoin_irox_data/featurize_data",
                             "out_data/df_coord")

    if append_str is not None:
        file_name_i = name + "__" + ads + "__" + append_str + ".pickle"
    else:
        file_name_i = name + "__" + ads + ".pickle"

    path_i = os.path.join(directory, file_name_i)

    my_file = Path(path_i)
    if my_file.is_file():

        with open(path_i, "rb") as fle:
            df_coord_i = pickle.load(fle)

    else:
        # Create df_coord

        df_coord_i = get_structure_coord_df(
            atoms,
            porous_adjustment=True,
        )

        directory = os.path.join(os.environ["PROJ_irox_oer"],
                                 "workflow/seoin_irox_data/featurize_data",
                                 "out_data/df_coord")
        # file_name_i = name + "__o" + ".pickle"

        if not os.path.exists(directory):
            os.makedirs(directory)
        with open(os.path.join(directory, file_name_i), "wb") as fle:
            pickle.dump(df_coord_i, fle)

    return (df_coord_i)
Пример #4
0
def create_save_struct_coord_df(
    slab_final=None,
    slab_id=None,
):
    """
    """
    #| - create_save_struct_coord_df
    slab_id_i = slab_id

    df_coord_slab_final = get_structure_coord_df(slab_final)

    file_name_i = slab_id_i + ".pickle"
    file_path_i = os.path.join(
        os.environ["PROJ_irox_oer"],
        "workflow/creating_slabs/out_data/df_coord_files", file_name_i)
    my_file = Path(file_path_i)
    if not my_file.is_file():
        # df_coord_slab_final = get_structure_coord_df(slab_final)
        with open(file_path_i, "wb") as fle:
            pickle.dump(df_coord_slab_final, fle)
Пример #5
0
def process_sys(
    slab_id=None,
    slab=None,
    path_pre=None,
    mode="new",  # 'new' or 'old'
    ):
    """
    """
    #| - process_sys
    if mode == "old":
        str_append = ""
    elif mode == "new":
        str_append = "_after_rep"


    path_i = os.path.join(
        path_pre, slab_id + str_append + ".pickle")
    with open(path_i, "rb") as fle:
        df_coord_i = pickle.load(fle)

    df_matches_slab_i = df_matches_slab(slab, df_coord_i)


    df_coord_redone = None
    if not df_matches_slab_i:

        print("df_coord_" + mode + " is inconsistent with slab")

        df_coord_redone = get_structure_coord_df(slab)
        # print("path_i:", path_i)
        with open(path_i, "wb") as fle:
            # print("Writing file")
            pickle.dump(df_coord_redone, fle)

    # #####################################################
    out_dict = dict()
    # #####################################################
    out_dict["df_matches_slab"] = df_matches_slab_i
    out_dict["df_coord_redone"] = df_coord_redone
    # #####################################################
    return(out_dict)
Пример #6
0
# -

assert False

# +
slab_0 = io.read(
    "out_data/final_slabs_2/zimuby8uzj__fagepuha_94__001.cif"
    # "out_data/temp_out/slab_1_2.cif"
    )

slab_0.write("out_data/temp_out/slab_0.cif")
atoms = slab_0

# +

df_coord_slab_i = get_structure_coord_df(atoms)

# #########################################################
df_i = df_coord_slab_i[df_coord_slab_i.element == "O"]
df_i = df_i[df_i.num_neighbors == 0]

o_atoms_to_remove = df_i.structure_index.tolist()

# #########################################################
o_atoms_to_remove_1 = []
df_j = df_coord_slab_i[df_coord_slab_i.element == "O"]
for j_cnt, row_j in  df_j.iterrows():
    neighbor_count = row_j.neighbor_count

    if neighbor_count.get("Ir", 0) == 0:
        if neighbor_count.get("O", 0) == 1:
Пример #7
0
        str(att_num_i) + \
        ""
    # str(int(active_site_i)) + "__" +  \
    file_name_i += ".pickle"

    directory = os.path.join(os.environ["PROJ_irox_oer"],
                             "workflow/creating_slabs/maintain_df_coord",
                             "out_data/df_coord__init_slabs")

    path_i = os.path.join(directory, file_name_i)

    # #####################################################
    my_file = Path(path_i)
    if not my_file.is_file():
        df_coord_i = get_structure_coord_df(
            init_atoms_i,
            porous_adjustment=True,
        )

        if not os.path.exists(directory):
            os.makedirs(directory)
        with open(path_i, "wb") as fle:
            pickle.dump(df_coord_i, fle)
# -

# ### Main Loop

df_slab_i = df_slab_i[df_slab_i.phase > 1]

if False:
    iterator = tqdm(df_slab_i.index, desc="1st loop")
    for i_cnt, slab_id_i in enumerate(iterator):
Пример #8
0
    failed_to_sort_i = row_atoms_sorted_i.failed_to_sort
    # #####################################################

    if not failed_to_sort_i:

        df_coord_i = get_df_coord(
            mode="post-dft",  # 'bulk', 'slab', 'post-dft'
            post_dft_name_tuple=name_i,
        )
        if df_coord_i is None:
            if verbose:
                print("No df_coord found, running")
            # #################################################
            # Get df_coord for post-dft, sorted slab
            df_coord_i = get_structure_coord_df(
                atoms_sorted_good_i,
                porous_adjustment=True,
            )

            # Pickling data ###################################
            file_name_i = "_".join([str(i)
                                    for i in list(name_new_i)]) + ".pickle"
            file_path_i = os.path.join(directory, file_name_i)
            print(file_path_i)
            with open(file_path_i, "wb") as fle:
                pickle.dump(df_coord_i, fle)
            # #################################################

        if "H" in df_coord_i.element.unique():
            # if True:
            df_coord_porous_adj_False_i = get_df_coord(
                mode="post-dft",  # 'bulk', 'slab', 'post-dft'
Пример #9
0
def constrain_slab(atoms=None, ):
    """Constrain lower portion of slab geometry.

    Has a little bit of built in logic which should provide better slabs.
    """
    #| - constrain_slab
    slab = atoms

    positions = slab.positions

    z_pos = positions[:, 2]

    z_max = np.max(z_pos)
    z_min = np.min(z_pos)

    # ang_of_slab_to_constrain = (2 / 4) * (z_max - z_min)
    ang_of_slab_to_constrain = (z_max - z_min) - 6

    # #########################################################
    indices_to_constrain = []
    for atom in slab:
        if atom.symbol == metal_atom_symbol:
            if atom.position[2] < (z_min + ang_of_slab_to_constrain):
                indices_to_constrain.append(atom.index)

    for atom in slab:
        if atom.position[2] < (z_min + ang_of_slab_to_constrain - 2):
            indices_to_constrain.append(atom.index)

    df_coord_slab_i = get_structure_coord_df(slab)

    # #########################################################
    other_atoms_to_constrain = []
    for ind_i in indices_to_constrain:
        row_i = df_coord_slab_i[df_coord_slab_i.structure_index == ind_i]
        row_i = row_i.iloc[0]

        nn_info = row_i.nn_info

        for nn_i in nn_info:
            ind_j = nn_i["site_index"]
            other_atoms_to_constrain.append(ind_j)

    # print(len(indices_to_constrain))

    indices_to_constrain.extend(other_atoms_to_constrain)

    # print(len(indices_to_constrain))

    # #########################################################
    constrain_bool_mask = []
    for atom in slab:
        if atom.index in indices_to_constrain:
            constrain_bool_mask.append(True)
        else:
            constrain_bool_mask.append(False)

    # #########################################################
    slab_cpy = copy.deepcopy(slab)

    from ase.constraints import FixAtoms
    c = FixAtoms(mask=constrain_bool_mask)
    slab_cpy.set_constraint(c)

    # slab_cpy.constraints

    return (slab_cpy)
Пример #10
0
    slab_final = row_i.slab_final
    slab_id = row_i.slab_id
    # #####################################################

    if verbose_local:
        print(40 * "*")
        print("slab_id:", slab_id)

    file_name_i = slab_id + "_after_rep" + ".pickle"
    file_path_i = os.path.join(
        os.environ["PROJ_irox_oer"],
        "workflow/creating_slabs/out_data/df_coord_files", file_name_i)

    my_file = Path(file_path_i)
    if not my_file.is_file():
        df_coord_slab_final = get_structure_coord_df(slab_final)
        with open(file_path_i, "wb") as fle:
            pickle.dump(df_coord_slab_final, fle)
    else:
        if verbose_local:
            print("Already computed")

# + active=""
#
#
#
#
#
#
#
#