Exemplo n.º 1
0
    def __init__(self, p1=45., p2=45., p=45., w0=15., dist='g'):
        """
        Arguments :
        p1
        p2
        p
        w0
        """
        import numpy as np

        ## generates a random rotation axis, about which
        ## the given grain rotates. Axis is represented by 
        ## two angles: delta and phi. 
        # delta, phi = self.rot_axis()
        # print "Rotation axis's delta, phi ",\
        #     delta*180./np.pi, phi*180./np.pi

        # if dist=='g':
        #     B = self.transform_matrix(delta=delta,
        #                               phi=phi,
        #                               w=self.gaussian(w0))
        # if dist=='e':
        #     B = self.transform_matrix(delta=delta,
        #                               phi=phi,
        #                               w=self.expo(w0))
        # if dist=='l':
        #     B = self.transform_matrix(delta=delta,
        #                               phi=phi,
        #                               w=self.lognorm(w0))
        # if dist=='n':
        #     B = self.transform_matrix(delta = delta,
        #                             phi = phi,
        #                             w=self.normal(w0))

            
        # A transforms from SA to CA [ca<-sa]
        A = eul(ph = p1, th = p, tm = p2, echo=False)

        if dist=='g':
            w = self.gaussian(w0)
        elif dist=='e':
            w = self.expo(w0)
        elif dist=='l':
            w = self.lognorm(w0)
        elif dist=='n':
            w = self.normal(w0)

        C = self.rot_vectang(th = w, r = A)

        p1, p, p2 = eul(a=C, echo=False)

        self.angle=np.array([p1,p,p2])
Exemplo n.º 2
0
    def __init__(self, p1=45., p2=45., p=45., w0=15., dist='g'):
        """
        Arguments :
        p1
        p2
        p
        w0
        """
        import numpy as np

        ## generates a random rotation axis, about which
        ## the given grain rotates. Axis is represented by
        ## two angles: delta and phi.
        # delta, phi = self.rot_axis()
        # print "Rotation axis's delta, phi ",\
        #     delta*180./np.pi, phi*180./np.pi

        # if dist=='g':
        #     B = self.transform_matrix(delta=delta,
        #                               phi=phi,
        #                               w=self.gaussian(w0))
        # if dist=='e':
        #     B = self.transform_matrix(delta=delta,
        #                               phi=phi,
        #                               w=self.expo(w0))
        # if dist=='l':
        #     B = self.transform_matrix(delta=delta,
        #                               phi=phi,
        #                               w=self.lognorm(w0))
        # if dist=='n':
        #     B = self.transform_matrix(delta = delta,
        #                             phi = phi,
        #                             w=self.normal(w0))

        # A transforms from SA to CA [ca<-sa]
        A = eul(ph=p1, th=p, tm=p2, echo=False)

        if dist == 'g':
            w = self.gaussian(w0)
        elif dist == 'e':
            w = self.expo(w0)
        elif dist == 'l':
            w = self.lognorm(w0)
        elif dist == 'n':
            w = self.normal(w0)

        C = self.rot_vectang(th=w, r=A)

        p1, p, p2 = eul(a=C, echo=False)

        self.angle = np.array([p1, p, p2])
Exemplo n.º 3
0
def main(hkl, uvw, w0, ngr=1, ifig=10):
    import upf
    import matplotlib.pyplot as plt
    phi1, phi, phi2 = miller2euler(hkl, uvw)
    mat0 = eul(phi1, phi, phi2, echo=False)  # ca<-sa
    # print 'mat0:', mat0
    mmm = sample_mmm()
    mats = [mat0]
    # print mats
    for i in range(len(mmm)):
        mats.append(np.dot(mat0, mmm[i]))

    gauss = random.gauss
    r = random.random

    # print 'ind_mat:', ind_mat
    # print 'ngr:', ngr

    grs = []

    for i in range(ngr):
        ind_mat = int(r() * len(mats))
        if w0 == 0: w = 0
        else: w = gauss(mu=0., sigma=w0)
        # print 'w:',w
        # print 'mats:', mats[ind_mat]
        C = rot_vectang(th=w, r=mats[ind_mat])
        # print C
        phi1, phi, phi2 = eul(a=C, echo=False)
        grs.append([phi1, phi, phi2, 1])
        #print phi1,phi,phi2

    #print grs

    mypf = upf.polefigure(grains=grs, csym='cubic')
    mypf.pf(mode='contourf', cmode='gray_r', ifig=ifig)
    #mypf.pf(mode='dot',cmode='gray_r',ifig=ifig)
    plt.tight_layout()

    hkl = '%i%i%i' % (hkl[0], hkl[1], hkl[2])
    uvw = '%i%i%i' % (uvw[0], uvw[1], uvw[2])
    fn = 'hkl_%s_uvw_%s_th_%i_ngr_%i.txt' % (hkl, uvw, w0, ngr)
    f = open(fn, 'w')
    f.writelines(' dum\n dum\n dum\n B  %i \n' % ngr)
    for i in range(ngr):
        f.writelines('%8.3f    %8.3f    %8.3f    %12.7f\n' %
                     (grs[i][0], grs[i][1], grs[i][2], 1. / ngr))

    f.close()
    print '%s has created' % fn
Exemplo n.º 4
0
def main(hkl,uvw,w0,ngr=1,ifig=10):
    import upf
    import matplotlib.pyplot as plt
    phi1,phi,phi2 = miller2euler(hkl,uvw)
    mat0 = eul(phi1,phi,phi2,echo=False) # ca<-sa
    # print 'mat0:', mat0
    mmm = sample_mmm()
    mats = [mat0]
    # print mats
    for i in range(len(mmm)):
        mats.append(np.dot(mat0,mmm[i]))

    gauss = random.gauss
    r = random.random

    # print 'ind_mat:', ind_mat
    # print 'ngr:', ngr

    grs = []

    for i in range(ngr):
        ind_mat = int(r() * len(mats))
        if w0==0: w=0
        else: w = gauss(mu=0., sigma=w0)
        # print 'w:',w
        # print 'mats:', mats[ind_mat]
        C = rot_vectang(th=w, r=mats[ind_mat])
        # print C
        phi1, phi, phi2 = eul(a=C, echo=False)
        grs.append([phi1,phi,phi2,1])
        #print phi1,phi,phi2

    #print grs

    mypf = upf.polefigure(grains=grs,csym='cubic')
    mypf.pf(mode='contourf',cmode='gray_r',ifig=ifig)
    #mypf.pf(mode='dot',cmode='gray_r',ifig=ifig)
    plt.tight_layout()
    
    hkl = '%i%i%i'%(hkl[0],hkl[1],hkl[2])
    uvw = '%i%i%i'%(uvw[0],uvw[1],uvw[2])
    fn = 'hkl_%s_uvw_%s_th_%i_ngr_%i.txt'%(hkl,uvw,w0,ngr)
    f = open(fn,'w')
    f.writelines(' dum\n dum\n dum\n B  %i \n'%ngr)
    for i in range(ngr):
        f.writelines('%8.3f    %8.3f    %8.3f    %12.7f\n'%(
                grs[i][0],grs[i][1],grs[i][2],1./ngr))

    f.close()
    print '%s has created'%fn
Exemplo n.º 5
0
def miller2euler(hkl, uvw):
    """
    RD // uvw  // 1
    ND // hkl  // 3

    3 x 1 = 2
    """
    # mat [ca<-sa]
    mat = miller2mat(hkl, uvw)
    phi1, phi, phi2 = eul(a=mat, echo=False)
    return phi1, phi, phi2
Exemplo n.º 6
0
def miller2euler(hkl, uvw):
    """
    RD // uvw  // 1
    ND // hkl  // 3

    3 x 1 = 2
    """
    # mat [ca<-sa]
    mat = miller2mat(hkl, uvw)
    phi1, phi, phi2 = eul(a=mat, echo=False)
    return phi1, phi, phi2