예제 #1
0
def five_param_fz(r_go1togo2_go1, bpn_go1):
    """The function returns an array of unit boundary plane normals lying in the fundamental zone of bicrystal
    symmetry for an input array containing boundary plane normals in po1 reference frame.

    Parameters
    -----------
    r_go1togo2_go1: The sigma misorientation matrix for grain boundary in orthogonal coordinates measured in the
    reference frame of crystal 1 (po1).
    * numpy array of size (3 x 3)

    bpn_go1: Boundary plane array containing boundary plane vectors, stored row wise.
    * numpy array of size (n x 3)
    * For each vector the components are expressed in orthogonal reference frame of crystal 1 (po1).

    Returns
    --------
    bp_fz_norms_go1: Fundamental zone boundary plane array.
    * numpy array of size (n x 3)
    * Each row is a unit boundary plane vector in the bicrystal fundamental zone.
    * For each vector the components are expressed in orthogonal reference frame of crystal 1 (po1).

    symm_grp_ax: The principal axes of bicrystal symmetry group in orthogonal reference frame of crystal 1 (po1).
    * numpy array of size (3 x 3)
    * x_axis == symm_grp_axes[:, 0]; y_axis == symm_grp_axes[:, 1]; z_axis == symm_grp_axes[:, 2]

    bp_symm_grp: The bicrystal symmetry group of the grain boundary.
    * python string
    * allowed values limited to 'C_s', 'C_2h', 'D_3d', 'D_2h', 'D_4h', 'D_6h', 'D_8h' and 'O_h'.

    Notes
    -------
    * all inputs and outputs, for this method are in the reference frame of lower crystal 1 (po1).
    * bpn_go1 should always be input as a 2-D array; to input just one normal, say [1, 0, 0], use the
    following syntax, bpn_go1 = np.array([[1, 0, 0]]).

    See Also
    --------
    * GBpy.quaternion
    * five_param_symm_props
    * pick_fz_bpl
    """
    mis_quat_fz = GBq.mat2quat(r_go1togo2_go1); lat_pt_grp = 'O_h'
    x_g, y_g, z_g, bp_symm_grp = five_param_symm_props(mis_quat_fz, lat_pt_grp, 1e-04)
    symm_grp_ax = np.zeros((3, 3))
    symm_grp_ax[:, 0] = x_g; symm_grp_ax[:, 1] = y_g; symm_grp_ax[:, 2] = z_g
    ### normalizing the input boundary plane vectors array
    t1_vecs = bpn_go1
    new_col = np.linalg.norm(t1_vecs, axis=1)
    t1_vecs_norm = np.array([new_col,]*3).T
    t1_vecs = np.divide(t1_vecs, t1_vecs_norm)
    bpn_go1 = t1_vecs

    bp_fz_norms_go1, bp_fz_stereo = pick_fz_bpl(bpn_go1, bp_symm_grp, symm_grp_ax, 1e-04)

    return bp_fz_norms_go1, bp_symm_grp, symm_grp_ax
예제 #2
0
def pick_uni_mis(lat_type, n=70):
    elem = GBl.Lattice(lat_type)
    l_g_go = elem.l_p_po
    l_go_g = np.linalg.inv(l_g_go)
    gb_dir = os.path.dirname(inspect.getfile(GBpy))
    pkl_path =  gb_dir + '/pkl_files/symm_mats_O.pkl'
    symm_O = pickle.load(open(pkl_path))
    symm_O_inv = np.linalg.inv(symm_O)
    mis_g, id = extract_mis(99, gb_dir)
    mis_go = np.tensordot(np.tensordot(l_g_go, mis_g.transpose(1, 2, 0), 1).transpose(2, 0, 1), l_go_g, 1)
    mis_go_inv = np.linalg.inv(mis_go)

    num = len(symm_O)*len(symm_O_inv)
    mis_go_symm1 = np.tensordot(np.tensordot(symm_O_inv, mis_go.transpose(1, 2, 0), 1).transpose(3, 0, 1, 2), symm_O.transpose(1, 2, 0), 1).transpose(0, 1, 4, 2, 3)
    mis_go_symm2 = np.tensordot(np.tensordot(symm_O_inv, mis_go_inv.transpose(1, 2, 0), 1).transpose(3, 0, 1, 2), symm_O.transpose(1, 2, 0), 1).transpose(0, 1, 4, 2, 3)
    mis_go_symm = np.concatenate((mis_go_symm1, mis_go_symm2))
    mis_go_symm = mis_go_symm.reshape(len(mis_go_symm)*num, 3, 3)
    id_attr3 = np.tile(np.arange(1, num+1, 1).reshape(num, 1), (len(id), 1))
    id_attr3 = np.vstack([id_attr3, -id_attr3])
    id_symm = np.tile(np.repeat(id, num, axis=0), (2, 1))
    id_symm = np.hstack([id_symm, id_attr3])
    quat_go_symm = GBq.mat2quat(mis_go_symm)
    quat_go_symm_fil = GBq.antipodal(quat_go_symm)
    ### Add code for pi rotations
    quat_t = quat_go_symm_fil.transpose()
    quat_t_unq, ind = GBt.unique_rows_tol(quat_t, tol=1e-06, return_index=True)

    id_unq = id_symm[ind]

    ind_id_sort = np.argsort(id_unq[:, 0])
    id_sort = id_unq[ind_id_sort]

    quat_sort = quat_t_unq[ind_id_sort].transpose()
    ### sort again according to sig vals
    mis_c = mf.sphr2cube_3d(quat_sort)

    ### testing
    # mis_r = mf.cube2sphr_3d(mis_c)

    grid, gce = make_grid(n)
    mis_gr_c, id_g = mis_in_grid(mis_c, id_sort, grid, gce)
    id_g_unq = GBt.unique_rows_tol(id_g[:, [0, 1]], 1e-06)
    ind_id_unq_sort = np.argsort(id_g_unq[:, 0]); id_g_unq = id_g_unq[ind_id_unq_sort]
    mis_pick_ind = mf.set_int_ind(id, id_g_unq)
    mis_pick = mis_g[mis_pick_ind]
    print '\n', len(mis_pick), '\n', id_g_unq
    # mis_gr_quat = mf.cube2sphr_3d(mis_gr_c)
    # mis_gr_go = GBq.quat2mat(mis_gr_quat)
    # mis_gr = np.tensordot(np.tensordot(l_go_g, mis_gr_go.transpose(1, 2, 0), 1).transpose(2, 0, 1), l_g_go, 1)
    # ### convert to g frame
    # ### pick in fz, check the code !!
    # dum = 0
    return [mis_pick, mis_pick_ind]