def custom_thetaz(plane_normal, theta, phi): #thetaz is the angle between the incident x-ray and the z-axis, #theta is the diffraction angle thetazrange = arange(0, pi, pi / 100000) r = plane_normal[0] * sin(thetazrange) * cos(phi) + plane_normal[1] * sin( thetazrange) * sin(phi) + plane_normal[2] * cos(thetazrange) f = abs( sin(theta) - r / ((sin(thetazrange) * cos(phi))**2 + (sin(thetazrange) * sin(phi))**2 + cos(thetazrange)**2)**0.5 / vlen(plane_normal)) fmin = min(f) I = list(f).index(fmin) thetaz = thetazrange[I] return thetaz
def custom_thetaz(plane_normal,theta,phi): #thetaz is the angle between the incident x-ray and the z-axis, #theta is the diffraction angle thetazrange = arange(0,pi,pi/100000); r = plane_normal[0]*sin(thetazrange)*cos(phi)+plane_normal[1]*sin(thetazrange)*sin(phi)+plane_normal[2]*cos(thetazrange); f = abs(sin(theta)-r/((sin(thetazrange)*cos(phi))**2+(sin(thetazrange)*sin(phi))**2+cos(thetazrange)**2)**0.5/vlen(plane_normal)); fmin = min(f); I = list(f).index(fmin); thetaz = thetazrange[I]; return thetaz;
c_axis = array([0., 0., 1.]) * c axis = array([a_axis, b_axis, c_axis]) la = Lattice(basis=axis) at = Atom() at.set('position', zeros(3)) la.plot3d_basis(labelwidth=0.01) surfacenormal = array([0, 0, 1]) ######################################### # the k-space and diffraction plane la.cal_kbasis() kbasis = la.get('kbasis') planenormal = h * kbasis[0] + k * kbasis[1] + l * kbasis[2] theta = arcsin(vlen(planenormal) / k_photon / 2) ########################################## #angle between diffraction plane and surface theta1 = arccos(vlen(planenormal * array([0, 0, 1])) / vlen(planenormal)) phi1 = arctan(planenormal[1] / planenormal[0]) textwidth = 0.005 ####################### # the surface x, y = mgrid[-100:101, -100:101] / 100 * a z = x - x mlab.mesh(x, y, z, opacity=0.5) text = 'film surface' mlab.text(1.1 * a, 0, 'film surface', z=0, width=len(text) * textwidth)
c_axis=array([0.,0.,1.])*c; axis=array([a_axis,b_axis,c_axis]); la=Lattice(basis=axis); at=Atom(); at.set('position',zeros(3)); la.plot3d_basis(labelwidth = 0.01); surfacenormal=array([0,0,1]) ######################################### # the k-space and diffraction plane la.cal_kbasis(); kbasis=la.get('kbasis'); planenormal = h*kbasis[0]+k*kbasis[1]+l*kbasis[2]; theta = arcsin(vlen(planenormal)/k_photon/2); ########################################## #angle between diffraction plane and surface theta1 = arccos(vlen(planenormal*array([0,0,1]))/vlen(planenormal)); phi1 = arctan(planenormal[1]/planenormal[0]); textwidth=0.005; ####################### # the surface x,y=mgrid[-100:101,-100:101]/100*a; z=x-x; mlab.mesh(x,y,z,opacity=0.5); text='film surface' mlab.text(1.1*a,0,'film surface',z=0,width=len(text)*textwidth)