def main(ngrains=100, sigma=15., c2a=1.6235, mu=0., prc='cst', isc=False, tilt_1=0., tilts_about_ax1=0., tilts_about_ax2=0.): """ Arguments ========= ngrains = 100 sigma = 15. c2a = 1.6235 prc = 'cst' or 'ext' tilts_about_ax1 = 0. -- Systematic tilting abount axis 1 tilts_about_ax2 = 0. -- Systematic tilting abount axis 2 tilt_1 = 0. -- Tilt in the basis pole. (systematic tilting away from ND) """ if isc: h = mmm() else: h = np.array([np.identity(3)]) gr = [] for i in xrange(ngrains): dth = random.uniform(-180., 180.) if prc == 'cst': g = gen_gr_fiber(th=dth, sigma=sigma, mu=mu, tilt=tilt_1, iopt=0) # Basal//ND elif prc == 'ext': g = gen_gr_fiber(th=dth, sigma=sigma, mu=mu, tilt=tilt_1, iopt=1) # Basal//ED else: raise IOError, 'Unexpected option' for j in xrange(len(h)): temp = np.dot(g, h[j].T) ## tilts_about_ax1 if abs(tilts_about_ax1) > 0: g_tilt = rd_rot(tilts_about_ax1) temp = np.dot(temp, g_tilt.T) ## tilts_about_ax2? elif abs(tilts_about_ax2) > 0: g_tilt = td_rot(tilts_about_ax2) temp = np.dot(temp, g_tilt.T) elif abs(tilts_about_ax2) > 0 and abs(tilts_about_ax2) > 0: raise IOError, 'One tilt at a time is allowed.' phi1, phi, phi2 = euler(a=temp, echo=False) gr.append([phi1, phi, phi2, 1. / ngrains]) mypf = upf.polefigure(grains=gr, csym='hexag', cdim=[1, 1, c2a]) mypf.pf_new(poles=[[0, 0, 0, 2], [1, 0, -1, 0]], cmap='jet', ix='TD', iy='RD') return np.array(gr)
def gen_gr_fiber(th,sigma,mu,iopt,tilt): """ Arguments ========= th = 7. sigma = 15. iopt = 0 (basal//ND); 1 (basal//ED) """ hkl, uvw = basal_fib(iopt) if iopt==0: g_casa = miller2mat(hkl,uvw) g_sasa = nd_rot(th) elif iopt==1: g_casa = miller2mat_RT(uvw=uvw,xyz=hkl) g_sasa = rd_rot(th) g = np.dot(g_casa,g_sasa) if tilt!=0: g_tilt = rd_rot(tilt) g = np.dot(g_tilt.T,g) dth = gauss(mu=mu, sigma=sigma) return rot_vectang(th=dth, r=g)
def gen_gr_fiber(th, sigma, mu, iopt, tilt): """ Arguments ========= th = 7. sigma = 15. iopt = 0 (basal//ND); 1 (basal//ED) """ hkl, uvw = basal_fib(iopt) if iopt == 0: g_casa = miller2mat(hkl, uvw) g_sasa = nd_rot(th) elif iopt == 1: g_casa = miller2mat_RT(uvw=uvw, xyz=hkl) g_sasa = rd_rot(th) g = np.dot(g_casa, g_sasa) if tilt != 0: g_tilt = rd_rot(tilt) g = np.dot(g_tilt.T, g) dth = gauss(mu=mu, sigma=sigma) return rot_vectang(th=dth, r=g)
def main(ngrains=100,sigma=15.,c2a=1.6235,mu=0., prc='cst',isc=False,tilt_1=0., tilts_about_ax1=0.,tilts_about_ax2=0.): """ Arguments ========= ngrains = 100 sigma = 15. c2a = 1.6235 prc = 'cst' or 'ext' tilts_about_ax1 = 0. -- Systematic tilting abount axis 1 tilts_about_ax2 = 0. -- Systematic tilting abount axis 2 tilt_1 = 0. -- Tilt in the basis pole. (systematic tilting away from ND) """ if isc: h = mmm() else: h=np.array([np.identity(3)]) gr = [] for i in xrange(ngrains): dth = random.uniform(-180., 180.) if prc=='cst': g = gen_gr_fiber(th=dth,sigma=sigma,mu=mu,tilt=tilt_1,iopt=0) # Basal//ND elif prc=='ext': g = gen_gr_fiber(th=dth,sigma=sigma,mu=mu,tilt=tilt_1,iopt=1) # Basal//ED else: raise IOError, 'Unexpected option' for j in xrange(len(h)): temp = np.dot(g,h[j].T) ## tilts_about_ax1 if abs(tilts_about_ax1)>0: g_tilt = rd_rot(tilts_about_ax1) temp = np.dot(temp,g_tilt.T) ## tilts_about_ax2? elif abs(tilts_about_ax2)>0: g_tilt = td_rot(tilts_about_ax2) temp = np.dot(temp,g_tilt.T) elif abs(tilts_about_ax2)>0 and abs(tilts_about_ax2)>0: raise IOError, 'One tilt at a time is allowed.' phi1,phi,phi2 = euler(a=temp, echo=False) gr.append([phi1,phi,phi2,1./ngrains]) mypf=upf.polefigure(grains=gr,csym='hexag',cdim=[1,1,c2a]) mypf.pf_new(poles=[[0,0,0,2],[1,0,-1,0]],cmap='jet',ix='TD',iy='RD') return np.array(gr)