Exemple #1
0
def misorientationGrain(kocks, angs, frames, kor, gr_mis=False):
    '''
    It takes in the mesh, the grain number of interest, the angles output from
    FePX and then the number of frames.
    
    It outputs the misorientations angles calculated for that specific grain
    by using the built in misorientation function within the ODFPF library.
    
    Input: kocks - the kocks angle of the the grain being examined
           grNum - an integer of the grain that you want to find the 
                   misorientation for each element
           angs - a numpy array 3xnxnframes of the angles output from FePX
           frames - list of frames your interested in examining
           
   Output: misAngs - a numpy array of nxframes that contains the angle of
                     misorientation for each element with respect to the
                     original orientation of the grain
           misQuat - a numpy array of 4xnxnframes that contains the
                     misorientation quaternion for each element with respect to
                     the original orientation of the grain
    '''
    angs = np.atleast_3d(angs)
    if angs.shape[0] == 1:
        angs = angs.T
    lenQuat = angs.shape[1]
    deg = 'degrees'
    misAngs = np.zeros((lenQuat, len(frames)))
    misQuat = np.zeros((4, lenQuat, len(frames)))
    misQuat[0, :, :] = 1
    if (gr_mis):
        origQuat = rot.OrientConvert(kocks, 'rod', 'quat', deg, deg)
    else:
        origQuat = rot.OrientConvert(kocks, 'kocks', 'quat', deg, deg)
    csym = rot.CubSymmetries()
    j = 0
    for i in frames:
        if kor == 'axis' or kor == 'axisangle':
            tQuat = rot.QuatOfAngleAxis(np.squeeze(angs[0, :, i]),
                                        np.squeeze(angs[1:4, :, i]))
        else:
            tQuat = rot.OrientConvert(np.squeeze(angs[:, :, i]), kor, 'quat',
                                      deg, deg)
        misAngs[:, j], misQuat[:, :,
                               j] = rot.Misorientation(origQuat, tQuat, csym)
        j += 1

    return (misAngs, misQuat)
 #A list holding our deformation stats for the discrete and lofem methods
 deflist = []
 ldeflist = []
 #el_angs is a temporary variable that will hold the grain values that go into misoriD
 el_angs = np.zeros((3,nel,nsteps))
 #Our difference quats, lofem quaternion at nodes, lofem quaternion at the centroid of the element, and discrete method quats
 diff_misQuats = np.zeros((4,nel,nsteps))
 lQuats = np.zeros((4, npts, nsteps))
 leQuats = np.zeros((4, nel, nsteps))
 dQuats = np.zeros((4, nel, nsteps))
 #Just converting from our inputted orientation data to quaternions
 for j in range(nsteps):      
     el_angs[:,:,j] = fe.elem_fe_cen_val(ldata['angs'][:,indlog2,j], lcon2)
     lQuats[:,:,j] = rot.QuatOfRod(np.squeeze(ldata['angs'][:,indlog2,j]))
     leQuats[:,:,j] = rot.QuatOfRod(np.squeeze(el_angs[:,:,j]))
     dQuats[:,:,j] = rot.OrientConvert(np.squeeze(data['angs'][:,indlog,j]), 'kocks', 'quat', 'degrees', 'radians')
 #Here we're getting the misorientation angle and quaternion for our angles when taken with respect the original orientation
 #for the lofem method
 lemisAngs, lemisQuats = mis.misorientationGrain(mesh['kocks'][:,i-1], el_angs, frames, kor)
     
 for j in range(nsteps):
     #Getting misorientation between the lofem and disc elements
     temp2, tempQ = mis.misorientationGrain(data['angs'][:,indlog, j], el_angs[:,:,j], [0], kor)
     diff_misQuats[:,:,j] = np.squeeze(tempQ)
     misoriD[indlog, j] = np.squeeze(temp2)
     
     crd = np.squeeze(data['coord'][:,ucon, j])
     #Getting strain data
     epsVec = np.squeeze(ldata['strain'][:, indlog, j])
     #Taking the strain data and putting it into the tensorial view
     #FEpX saves strain data off as 11, 21, 31, 22, 32, 33 so we also have to do some other