for j in range(i + 1, len(V)):
            mis.append(pyebsd.misorientation(V[i], V[j]))
    return mis


if __name__ == '__main__':
    fname = os.path.join('..', 'data', 'ADI_bcc_fcc.ang')
    scan = pyebsd.load_scandata(fname)

    sel = (scan.ph == 1) & (scan.CI > .2)

    # First nearest neighbors
    neighbors = scan.get_neighbors(1, sel=sel)
    # Experimental misorientations
    mis_exp = pyebsd.misorientation_neighbors(scan.M, neighbors,
                                              sel=sel).ravel()

    # Expected misorientations between KS variants
    mis_calc = misorientation_between_variants(
        pyebsd.OR())  # for KS OR variants

    fig, ax = plt.subplots()

    ax.hist(mis_exp[mis_exp > 2], bins=200, density=True, label='Experimental')
    ax.hist(mis_calc, bins=500, density=True, label='Theoretical')
    ax.legend()
    ax.set_xlabel('Misorientation angle (deg)')
    ax.set_ylabel('Frequency')

    plt.show()
import numpy as np
import pandas as pd
import pyebsd
import matplotlib.pyplot as plt

if __name__ == '__main__':
    # Symmetry operators sorted according to the KS variants convention
    C = pyebsd.list_cubic_symmetry_operators_KS()
    KS = pyebsd.OR(ps=[[1, 1, 1], [0, 1, 1]],
                   ds=[[-1, 0, 1], [-1, -1, 1]],
                   single=True)  # only the first matrix

    # The orientations in M_KS are in the order of the variants convetion
    # published in papers such as:
    # T. Furuhara, T. Chiba, T. Kaneshita, H. Wu, G. Miyamoto, Metall.
    # Mater. Trans. A 48 (2017) 2739–2752.
    M_KS = np.matmul(KS, C.transpose(0, 2, 1))  # KS * C^T

    v = 0  # variant
    variants_found = set()
    variants = pd.DataFrame(index=range(len(M_KS)))
    variants['Variant number'] = variants.index + 1
    variants['CP group'] = np.repeat(range(4), 6)
    variants['Bain group'] = -1
    for group in range(3):
        misang = [
            pyebsd.misorientation(M_KS[j], M_KS[v]) for j in range(len(M_KS))
        ]

        if v == 0:
            variants['Rotation from variant 1 (deg)'] = misang
Beispiel #3
0
def plot_hist_misorientation_variants(V, ax, title=None):
    mis = misorientation_between_variants(V)
    ax.hist(mis, bins=100)
    ax.set_xlabel('Misorientation angle (deg)')
    ax.set_ylabel('Frequency')
    ax.set_title(title)


if __name__ == '__main__':
    from itertools import cycle
    import matplotlib.pyplot as plt

    fig, axes = plt.subplots(2, 2, figsize=(14, 10))
    fig.subplots_adjust(hspace=.3)
    cyaxes = cycle(axes.ravel())

    V = pyebsd.OR()  # KS
    plot_hist_misorientation_variants(V, next(cyaxes), 'KS OR')

    V = pyebsd.OR(ds=([1, 1, 0], [1, 0, 0]))  # NW
    plot_hist_misorientation_variants(V, next(cyaxes), 'NW OR')

    V = pyebsd.OR(ps=([1, 0, 0], [1, 0, 0]), ds=([0, 1, 0], [0, 1, 1]))  # Bain
    plot_hist_misorientation_variants(V, next(cyaxes), 'Bain OR')

    V = pyebsd.OR(ps=([0, 1, 0], [1, 0, 1]), ds=([1, 0, 1], [-1, 1,
                                                             1]))  # Pitsch
    plot_hist_misorientation_variants(V, next(cyaxes), 'Pitsch OR')

    plt.show()
# fig1, ax1 = plt.subplots()
# pyebsd.initialize_frame_PF(ax1)
# pyebsd.plot_PF(R_bcc, ax=ax1, contour=True, cmap='Reds_r', proj=[1, 1, 0])
# pyebsd.plot_PF(R_fcc, ax=ax1, contour=True, cmap='Blues_r', proj=[1, 1, 1])

# fig2, ax2 = plt.subplots()
# pyebsd.initialize_frame_PF(ax2)
# pyebsd.plot_PF(R_bcc, ax=ax2, contour=True, cmap='Reds_r', proj=[1, 1, 1])
# pyebsd.plot_PF(R_fcc, ax=ax2, contour=True, cmap='Blues_r', proj=[1, 1, 0])


fig, ax = plt.subplots()
pyebsd.initialize_frame_PF(ax)

T_KS = pyebsd.OR()
# T_KS^-1 = T_KS^T
T_KS_T = T_KS.transpose([0, 2, 1])

M_KS = np.dot(T_KS, M_fcc_avg)
R_KS = M_KS.transpose(0, 2, 1)

# T_KS^T . M_bcc
M_KS_all = np.tensordot(C, M_KS,
                        axes=[[-1], [-2]]).transpose([2, 0, 1, 3])

R_fcc_inv = np.tensordot(T_KS_T, M_KS_all.reshape(-1, 3, 3),
                         axes=[[-1], [-2]]).transpose([2, 0, 3, 1])

# M_bcc_all = np.tensordot(C, M_bcc,
#                          axes=[[-1], [-2]]).transpose([2, 0, 1, 3])
Beispiel #5
0
import os
import sys

import numpy as np
import matplotlib.pyplot as plt

import pyebsd

T_KS = pyebsd.OR()  # K-S
T_NW = pyebsd.OR(ds=[[1, 1, 0], [1, 0, 0]])  # N-W

proj = [1, 1, 1]

ax = pyebsd.plot_PF(M=T_KS,
                    mfc=[1, 1, 1, 0],
                    mec='r',
                    mew=1,
                    marker='s',
                    ms=5,
                    proj=proj,
                    label='KS')
pyebsd.plot_PF(M=T_NW,
               mfc=[1, 1, 1, 0],
               mec='g',
               mew=1,
               marker='D',
               ms=5,
               proj=proj,
               label='NW',
               ax=ax)
pyebsd.draw_std_traces(ax, lw=.2)
import numpy as np
import matplotlib.pyplot as plt
import pyebsd

if __name__ == '__main__':
    # T. Furuhara, T. Maki, Mater. Sci. Eng. A 312 (2001) 145–154.
    M_KS = []
    M_KS.append(pyebsd.OR(ps=[[1, 1, 1], [0, 1, 1]], ds=[[-1, 0, 1], [-1, -1, 1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, 1, 1], [0, 1, 1]], ds=[[-1, 0, 1], [-1, 1, -1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, 1, 1], [0, 1, 1]], ds=[[0, 1, -1], [-1, -1, 1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, 1, 1], [0, 1, 1]], ds=[[0, 1, -1], [-1, 1, -1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, 1, 1], [0, 1, 1]], ds=[[1, -1, 0], [-1, -1, 1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, 1, 1], [0, 1, 1]], ds=[[1, -1, 0], [-1, 1, -1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, -1, 1], [0, 1, 1]], ds=[[1, 0, -1], [-1, -1, 1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, -1, 1], [0, 1, 1]], ds=[[1, 0, -1], [-1, 1, -1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, -1, 1], [0, 1, 1]], ds=[[-1, -1, 0], [-1, -1, 1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, -1, 1], [0, 1, 1]], ds=[[-1, -1, 0], [-1, 1, -1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, -1, 1], [0, 1, 1]], ds=[[0, 1, 1], [-1, -1, 1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, -1, 1], [0, 1, 1]], ds=[[0, 1, 1], [-1, 1, -1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[-1, 1, 1], [0, 1, 1]], ds=[[0, -1, 1], [-1, -1, 1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[-1, 1, 1], [0, 1, 1]], ds=[[0, -1, 1], [-1, 1, -1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[-1, 1, 1], [0, 1, 1]], ds=[[-1, 0, -1], [-1, -1, 1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[-1, 1, 1], [0, 1, 1]], ds=[[-1, 0, -1], [-1, 1, -1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[-1, 1, 1], [0, 1, 1]], ds=[[1, 1, 0], [-1, -1, 1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[-1, 1, 1], [0, 1, 1]], ds=[[1, 1, 0], [-1, 1, -1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, 1, -1], [0, 1, 1]], ds=[[-1, 1, 0], [-1, -1, 1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, 1, -1], [0, 1, 1]], ds=[[-1, 1, 0], [-1, 1, -1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, 1, -1], [0, 1, 1]], ds=[[0, -1, -1], [-1, -1, 1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, 1, -1], [0, 1, 1]], ds=[[0, -1, -1], [-1, 1, -1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, 1, -1], [0, 1, 1]], ds=[[1, 0, 1], [-1, -1, 1]], single=True))
    M_KS.append(pyebsd.OR(ps=[[1, 1, -1], [0, 1, 1]], ds=[[1, 0, 1], [-1, 1, -1]], single=True))