def define_branch_CC(E0=9000, d23 = .2, alphaAsym=np.deg2rad(0), f_lens=10., FOV1 = 1e-3, FOV2 = 100e-6, N = 1024): # crystal reflection hkl index hkl = [2,2,0] # viewing point upstream of monochromator im0 = optics.PPM('im0', z=400-.01, FOV = FOV1, N=N) slit = optics.Slit('s0', x_width=1., y_width=100e-3, dx=0, dy=50e-3, z=400) # first crystal: symmetric reflection crystal1 = optics.Crystal('c1', hkl=hkl, length=10e-2, width=20e-3, z=400, E0=E0, alphaAsym=0, orientation=0, pol='s', delta=0.e-6) # second crystal: symmetric reflection, orientation flipped relative to crystal 1 z12 = np.cos(2*crystal1.beta0)*0.02 crystal2 = optics.Crystal('c2', hkl=hkl, length=10e-2, width=20e-3, z=crystal1.z+z12, E0=E0, alphaAsym=alphaAsym, orientation=2, pol='s', delta=0.e-6) # printing crystal incidence and reflection angles for confirmation print('crystal 2 incidence angle: {:.2f} degrees'.format(crystal2.alpha*180/np.pi)) print('crystal 2 exit angle: {:.2f} degrees'.format(crystal2.beta0*180/np.pi)) im1 = optics.PPM('im1', z=crystal2.z+d23/2+z_off, FOV=FOV1, N=N) # third crystal, symmetric reflection, same orientation as crystal2 z23 = d23 + 2*z_off crystal3 = optics.Crystal('c3', hkl=hkl, length=10e-2, width=10e-3, z=crystal2.z+z23, E0=E0, alphaAsym=-alphaAsym, orientation=2, pol='s', asym_type='emergence') # fourth crystal, symmetric reflection, same orientation as crystal1 z34 = z12 crystal4 = optics.Crystal('c4', hkl=hkl, length=10e-2, width=10e-3, z=crystal3.z+z34, E0=E0, alphaAsym=0, orientation=0, pol='s', asym_type='emergence') # viewing point just downstream of monochromator im2 = optics.PPM('im2', z=crystal4.z+.01, FOV=FOV1, N=N) # spectrometer lens crl1 = CRL_no_abs('crl1', z=im2.z+.01, E0=E0, f=f_lens, diameter=5e-3, orientation=1) # viewing point at spectrometer lens focal plane im3 = optics.PPM('im3', z=crl1.z+f_lens, FOV=FOV2, N=N) # spectrometer crystal crystal5 = optics.Crystal('c5', hkl=[5,5,5], length=10e-2, width=10e-2, z=crl1.z+f_lens*2, E0=E0, alphaAsym=0, orientation=1, pol='s', asym_type='emergence') # viewing point at crossing z56 = np.cos(np.pi-2*crystal5.alpha)*.1 im4 = optics.PPM('im4', z=crystal5.z-z56, FOV=FOV2, N=N) # force tilt tilt1 = Force_tilt('tilt1', delta_a = -tilt, z=im4.z+.01, orientation = 1) # list of devices to propagate through devices = [im0, crystal1, crystal2, im1, crystal3, crystal4, im2, crl1, im3, crystal5, tilt1, im4] return devices
def define_devices( f1, f2, slit_width = 1e-3, hkl = [1,1,1], alphaAsym = 0., E0=18e3, f0 = 290., d23=7.): # viewing point upstream of monochromator im0 = optics.PPM('im0', z=870, FOV=5e-3, N=256) crl0 = optics.CRL('crl0', z=920, E0=E0, f=f0, diameter=2e-3) # first crystal: symmetric reflection crystal1 = optics.Crystal('c1', hkl=hkl, length=10e-2, width=20e-3, z=930, E0=E0, alphaAsym=0, orientation=0, pol='s', delta=0.e-6) # second crystal: asymmetric reflection, orientation flipped relative to crystal1 crystal2 = optics.Crystal('c2', hkl=hkl, length=10e-2, width=20e-3, z=crystal1.z+.2, E0=E0,alphaAsym=alphaAsym, orientation=2,pol='s', delta=0e-6) # printing crystal incidence and reflection angles for confirmation print('crystal 2 incidence angle: {:.2f} degrees'.format(crystal2.alpha*180/np.pi)) print('crystal 2 exit angle: {:.2f} degrees'.format(crystal2.beta0*180/np.pi)) im_upstream = optics.PPM('im_upstream', z=crystal2.z + f1 - .1, FOV=2e-3, N=256) # CRL with ~1 meter focal length (modeled as single element for now) crl1 = optics.CRL('crl1', z=crystal2.z+f1, E0=E0, f=f2, diameter=5e-3) # viewing point downstream of first crl im1 = optics.PPM('im1', z=crl1.z+.1,N=256,FOV=5e-3) # slit at focus slit = optics.Slit('slit', z=crl1.z+f2, x_width=slit_width, y_width=2e-3) # viewing point at focus focus = optics.PPM('focus', z=crl1.z+f2 + 1e-3, FOV=5e-3, N=256) # second CRL with ~1 meter focal length, for collimation crl2 = optics.CRL('crl2', z=crl1.z+2*f2, E0=E0, f=f2, diameter=5e-3) # third crystal, symmetric reflection, same orientation as crystal2 crystal3 = optics.Crystal('c3', hkl=hkl, length=10e-2, width=10e-3, z=crl2.z+d23, E0=E0,alphaAsym=0, orientation=2, asym_type='emergence',pol='s') # fourth crystal, asymmetric reflection, same orientation as crystal1 crystal4 = optics.Crystal('c4', hkl=hkl, length=10e-2, width=10e-3, z=crl2.z+d23 + (f1-d23)*np.cos(crystal1.beta0*2), E0=E0,alphaAsym=-alphaAsym, asym_type='emergence', orientation=0,pol='s') # viewing point just downstream of monochromator im2 = optics.PPM('im2', z=crystal4.z+.1, FOV=5e-3, N=256) # list of devices to propagate through devices = [crl0,im0,crystal1,crystal2,im_upstream,im1,crl1,slit,focus,crl2,crystal3,crystal4,im2] return devices
def add_shapeError(devices, shapeError, crystal): for i, device in enumerate(devices): if device.name == 'c{}'.format(crystal): devices[i] = optics.Crystal(device.name, hkl=device.hkl, length=device.length, width=device.width, z=device.z, E0=device.E0, alphaAsym=device.alphaAsym, orientation=device.orientation, pol=device.pol, delta=device.delta, shapeError = shapeError)
def change_miscut(devices, eta_err, crystal): for i, device in enumerate(devices): if device.name == 'c{}'.format(crystal): devices[i] = optics.Crystal(device.name, hkl=device.hkl, length=device.length, width=device.width, z=device.z, E0=device.E0, alphaAsym=device.alphaAsym + eta_err, orientation=device.orientation, pol=device.pol, delta=device.delta)
def define_devices(delta=0, crystal=1, E0=E0): # asymmetry angle etaA = np.deg2rad(9.4) etaB = np.deg2rad(70) etaC = np.deg2rad(9.4) # crystal reflection hkl index hklA = [4, 0, 0] hklB = [12, 8, 4] hklC = [4, 0, 0] # viewing point upstream of monochromator im0 = optics.PPM('im0', z=870, FOV=2e-3, N=256) crl0 = optics.CRL('crl0', z=920, E0=E0, f=290., diameter=2e-3) # crystal pair A crystal1 = optics.Crystal('c1', hkl=hklA, length=10e-2, width=20e-3, z=930., E0=E0, alphaAsym=-etaA, asym_type='emergence', orientation=2, pol='s') # second crystal: asymmetric reflection, orientation flipped relative to crystal1 crystal2 = optics.Crystal('c2', hkl=hklA, length=10e-2, width=20e-3, z=crystal1.z + .2, E0=E0, alphaAsym=-etaA, asym_type='emergence', orientation=0, pol='s') # viewing point downstream of crystal 2 im1 = optics.PPM('after_A', z=crystal2.z + .1, N=2048, FOV=16e-3) # crystal pair B crystal3 = optics.Crystal('c3', hkl=hklB, length=10e-2, width=10e-3, z=crystal2.z + .5, E0=E0, alphaAsym=etaB, asym_type='emergence', orientation=0, pol='s') crystal4 = optics.Crystal('c4', hkl=hklB, length=10e-2, width=10e-3, z=crystal3.z + .2, E0=E0, alphaAsym=-etaB, asym_type='emergence', orientation=2, pol='s') # viewing after crystal 4 im2 = optics.PPM('after_B', z=crystal4.z + .1, N=2048, FOV=16e-3) # crystal pair C crystal5 = optics.Crystal('c5', hkl=hklC, length=10e-2, width=10e-3, z=crystal4.z + .5, E0=E0, alphaAsym=etaC, asym_type='emergence', orientation=2, pol='s') crystal6 = optics.Crystal('c6', hkl=hklC, length=10e-2, width=10e-3, z=crystal5.z + .2, E0=E0, alphaAsym=etaC, asym_type='emergence', orientation=0, pol='s') # viewing point just downstream of monochromator im3 = optics.PPM('output', z=crystal6.z + .1, FOV=2e-3, N=256) # list of devices to propagate through devices = [ im0, crl0, crystal1, crystal2, im1, crystal3, crystal4, im2, crystal5, crystal6, im3 ] for device in devices: if device.name == 'c{}'.format(crystal): device.delta = delta return devices