Skip to content

The defination of some parameters in STEMTOOL? #5

Description

@PhysXu

Hi, dear Dr. Mukherjee,

I am interested in the relative_strain and strain_map functions in atom_position .py of stemtool.

But, I did not find the annotations of parameters of n_list, coords, centers, mask in the github.

Could you kindly tell me the defination/details of these above four parameters?

Thanks in advance.

def relative_strain(n_list, coords):
    warnings.filterwarnings("ignore")
    identity = np.asarray(((1, 0), (0, 1)))
    axis_pos = np.asarray(((0, 0), (1, 0), (0, 1), (1, 1)))
    no_atoms = (np.shape(n_list))[0]
    coords_inv = np.linalg.inv(coords)
    cell_center = np.zeros((no_atoms, 2))
    e_xx = np.zeros(no_atoms)
    e_xy = np.zeros(no_atoms)
    e_yy = np.zeros(no_atoms)
    e_th = np.zeros(no_atoms)
    for ii in range(no_atoms):
        cc = np.zeros((4, 2))
        cc[0, :] = n_list[ii, 0:2] - n_list[ii, 0:2]
        cc[1, :] = n_list[ii, 2:4] - n_list[ii, 0:2]
        cc[2, :] = n_list[ii, 4:6] - n_list[ii, 0:2]
        cc[3, :] = n_list[ii, 6:8] - n_list[ii, 0:2]
        l_cc, _, _, _ = np.linalg.lstsq(axis_pos, cc, rcond=None)
        t_cc = np.matmul(l_cc, coords_inv) - identity
        e_yy[ii] = t_cc[0, 0]
        e_xx[ii] = t_cc[1, 1]
        e_xy[ii] = 0.5 * (t_cc[0, 1] + t_cc[1, 0])
        e_th[ii] = 0.5 * (t_cc[0, 1] - t_cc[1, 0])
        cell_center[ii, 0] = 0.25 * (
            n_list[ii, 0] + n_list[ii, 2] + n_list[ii, 4] + n_list[ii, 6]
        )
        cell_center[ii, 1] = 0.25 * (
            n_list[ii, 1] + n_list[ii, 3] + n_list[ii, 5] + n_list[ii, 7]
        )
    return cell_center, e_yy, e_xx, e_xy, e_th


def strain_map(centers, e_yy, e_xx, e_xy, e_th, mask):
    yr, xr = np.mgrid[0 : mask.shape[0], 0 : mask.shape[1]]
    cartcoord = list(zip(centers[:, 1], centers[:, 0]))

    e_yy[np.abs(e_yy) > 3 * np.median(np.abs(e_yy))] = 0
    e_xx[np.abs(e_xx) > 3 * np.median(np.abs(e_xx))] = 0
    e_xy[np.abs(e_xy) > 3 * np.median(np.abs(e_xy))] = 0
    e_th[np.abs(e_th) > 3 * np.median(np.abs(e_th))] = 0

    f_yy = scinterp.LinearNDInterpolator(cartcoord, e_yy)
    f_xx = scinterp.LinearNDInterpolator(cartcoord, e_xx)
    f_xy = scinterp.LinearNDInterpolator(cartcoord, e_xy)
    f_th = scinterp.LinearNDInterpolator(cartcoord, e_th)

    map_yy = f_yy(xr, yr)
    map_yy[np.isnan(map_yy)] = 0
    map_yy = np.multiply(map_yy, mask)

    map_xx = f_xx(xr, yr)
    map_xx[np.isnan(map_xx)] = 0
    map_xx = np.multiply(map_xx, mask)

    map_xy = f_xy(xr, yr)
    map_xy[np.isnan(map_xy)] = 0
    map_xy = np.multiply(map_xy, mask)

    map_th = f_th(xr, yr)
    map_th[np.isnan(map_th)] = 0
    map_th = np.multiply(map_th, mask)

    return map_yy, map_xx, map_xy, map_th

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions