def build_beamline(): beamLine = raycing.BeamLine(alignE=10000) beamLine.Wiggler = rsources.Wiggler(bl=beamLine, name=r"Flat-Top Wiggler", center=[0, 0, 0], nrays=500000, eE=2.9, eI=0.25, eEpsilonX=18.1, eEpsilonZ=0.0362, betaX=9.1, betaZ=2.8, xPrimeMax=0.3, zPrimeMax=0.005, eMin=9995, eMax=10005, K=35, period=150, n=11) beamLine.Generic_DCM = roes.DCM(bl=beamLine, name=r"Generic DCM", center=[0, 25300, 0], bragg=[10000], material=Si111, material2=Si111, cryst2perpTransl=6.5023) beamLine.Aperture = rapts.RectangularAperture(bl=beamLine, name=r"Aperture", center=[0, 28300, r"auto"], opening=[-10, 10, -0.1, 0.1]) beamLine.FSM = rscreens.Screen(bl=beamLine, name=r"FSM", center=[0, 30650, r"auto"]) return beamLine
def build_beamline(nrays=1e4, hkl=(1, 1, 1), stripe='Si', eMinRays=2400, eMaxRays=45000): filterDiamond = rm.Material('C', rho=3.52, kind='plate') if stripe.startswith('S'): materialVCM = stripeSi materialVFM = stripeSiO2 elif stripe.startswith('I'): materialVCM = stripeIr materialVFM = stripeIr else: raise ('Don' 't know the mirror material') height = 0 beamLine = raycing.BeamLine(azimuth=0, height=height) wigglerToStraightSection = 0 xWiggler = wigglerToStraightSection * beamLine.sinAzimuth yWiggler = wigglerToStraightSection * beamLine.cosAzimuth # rs.WigglerWS( # beamLine, name='SoleilW50', center=(xWiggler, yWiggler, height), # nrays=nrays, period=50., K=8.446, n=39, eE=3., eI=0.5, # eSigmaX=48.66, eSigmaZ=6.197, eEpsilonX=0.263, eEpsilonZ=0.008, # eMin=50, eMax=60050, eMinRays=eMinRays, eMaxRays=eMaxRays, eN=2000, # xPrimeMax=0.22, zPrimeMax=0.06, nx=40, nz=10) rs.Wiggler(beamLine, name='SoleilW50', center=(xWiggler, yWiggler, height), nrays=nrays, period=50., K=8.446, n=39, eE=3., eI=0.5, eSigmaX=48.66, eSigmaZ=6.197, eEpsilonX=0.263, eEpsilonZ=0.008, eMin=eMinRays, eMax=eMaxRays, xPrimeMax=0.22, zPrimeMax=0.06) beamLine.fsm0 = rsc.Screen(beamLine, 'FSM0', (0, 15000, height)) beamLine.feFixedMask = ra.RectangularAperture( beamLine, 'FEFixedMask', (0, 15750, height), ('left', 'right', 'bottom', 'top'), [-3.15, 3.15, -0.7875, 0.7875]) beamLine.fsmFE = rsc.Screen(beamLine, 'FSM-FE', (0, 16000, height)) beamLine.filter1 = roe.Plate(beamLine, 'Filter1', (0, 23620, height), pitch=math.pi / 2, limPhysX=(-9., 9.), limPhysY=(-4., 4.), surface='diamond 60 $\mu$m', material=filterDiamond, t=0.06, alarmLevel=0.) if stripe.startswith('I'): beamLine.filter2 = roe.Plate(beamLine, 'Filter2', (0, 23720, height), pitch=math.pi / 2, limPhysX=(-9., 9.), limPhysY=(-4., 4.), surface='diamond 0.4 mm', material=filterDiamond, t=0.4, alarmLevel=0.) beamLine.vcm = roe.SimpleVCM(beamLine, 'VCM', [0, 25290, height], surface=('Si', ), material=(materialVCM, ), limPhysX=(-15., 15.), limPhysY=(-680., 680.), limOptX=(-6, 6), limOptY=(-670., 670.), R=5.0e6, pitch=2e-3, alarmLevel=0.) beamLine.fsmVCM = rsc.Screen(beamLine, 'FSM-VCM', (0, 26300, height)) beamLine.dmm = roe.DCM( beamLine, 'DMM', [0, 27060, height], surface=('mL1', ), material=(mL, ), material2=(mL, ), limPhysX=(-12, 12), limPhysY=(-150, 150), cryst2perpTransl=20, cryst2longTransl=100, limPhysX2=(-12, 12), limPhysY2=(-200, 200), # targetOpenCL='auto', targetOpenCL='CPU', alarmLevel=0.05) beamLine.BSBlock = ra.RectangularAperture(beamLine, 'BSBlock', (0, 29100, height), ('bottom', ), (22, ), alarmLevel=0.) beamLine.slitAfterDCM = ra.RectangularAperture( beamLine, 'SlitAfterDCM', (0, 29200, height), ('left', 'right', 'bottom', 'top'), [-7, 7, -2, 2], alarmLevel=0.5) beamLine.fsmDCM = rsc.Screen(beamLine, 'FSM-DCM', (0, 29400, height)) beamLine.vfm = roe.SimpleVFM(beamLine, 'VFM', [0, 30575, height], surface=('SiO2', ), material=(materialVFM, ), limPhysX=(-20., 20.), limPhysY=(-700., 700.), limOptX=(-10, 10), limOptY=(-700, 700), positionRoll=math.pi, R=5.0e6, r=40.77, alarmLevel=0.2) beamLine.slitAfterVFM = ra.RectangularAperture( beamLine, 'SlitAfterVFM', (0, 31720, height), ('left', 'right', 'bottom', 'top'), [-7, 7, -2, 2], alarmLevel=0.5) beamLine.fsmVFM = rsc.Screen(beamLine, 'FSM-VFM', (0, 32000, height)) beamLine.ohPS = ra.RectangularAperture(beamLine, 'OH-PS', (0, 32070, height), ('left', 'right', 'bottom', 'top'), (-20, 20, 25, 55), alarmLevel=0.2) beamLine.slitEH = ra.RectangularAperture( beamLine, 'slitEH', (0, 43000, height), ('left', 'right', 'bottom', 'top'), [-20, 20, -7, 7], alarmLevel=0.5) beamLine.fsmSample = rsc.Screen(beamLine, 'FSM-Sample', (0, 45863, height)) return beamLine
def run(case): myBalder = raycing.BeamLine(azimuth=0, height=0) kwargs = dict(name='SoleilW50', center=(0, 0, 0), period=50., K=8.446, n=39, eE=3., eI=0.5, eSigmaX=48.66, eSigmaZ=6.197, eEpsilonX=0.263, eEpsilonZ=0.008, eMin=50, eMax=eMax * 1e3 + 50, xPrimeMax=0.2, zPrimeMax=0.05, eN=2000, nx=20, nz=10) kwargs['distE'] = 'BW' source = rs.Wiggler(myBalder, **kwargs) E = np.mgrid[source.E_min:(source.E_max + 0.5 * source.dE):source.dE] I0 = source.intensities_on_mesh()[0] flux = I0.sum(axis=(1, 2)) * source.dTheta * source.dPsi fig = plt.figure(figsize=(10, 6)) fig.suptitle(u'Integrated {0}'.format(case) + u' beam flux into 0.4$\\times$ 0.1 mrad$^2$', fontsize=14) # fig.subplots_adjust(right=0.88) ax = fig.add_subplot(111) ax.set_xlabel(r'energy (keV)') if case == 'monochromatic': ax.set_ylabel(r'flux (ph/s/(Si111 DCM bw)') else: ax.set_ylabel(r'flux (ph/s/0.1%bw)') if case == 'monochromatic': refl = stripePt.get_amplitude(E, np.sin(1e-3)) ras = refl[0] ax2 = ax.twinx() rI = (abs(ras)**2)**2 ax2.plot(E * 1e-3, rI, '-b', lw=2) ax2.set_ylabel('reflectivity of two Pt mirrors at 1 mrad', color='b') ax2.set_ylim(0, 1) fluxRes = flux * 2e-4 * 1e3 * rI else: fluxRes = flux ax.plot(E * 1e-3, fluxRes, '-r', lw=2, label='wiggler') ax.set_ylim(0, None) ax.set_xlim(0, eMax) saveName = 'fluxBalder-{0}'.format(case) fig.savefig(saveName + '.png') wb = xlwt.Workbook() ws = wb.add_sheet('flux') ws.write(0, 0, "energy (eV)") if case == 'monochromatic': ws.write(0, 1, "flux (ph/s/(Si111 DCM bw)") else: ws.write(0, 1, "flux (ph/s/0.1%bw)") for ie, (e, f) in enumerate(zip(E, fluxRes)): ws.write(ie + 1, 0, e) ws.write(ie + 1, 1, f) wb.save(saveName + '.xls') plt.show()
def build_beamline(nrays=raycing.nrays, eMinRays=550, eMaxRays=30550): x0, y0 = -30095.04, -30102.65 # straight section center xFar, yFar = -59999.67, -198.017 height = 1400. azimuth = np.arctan2(xFar - x0, yFar - y0) stripeSi = rm.Material('Si', rho=2.33) stripeRh = rm.Material('Rh', rho=12.41) stripePt = rm.Material('Pt', rho=21.45) si111_1 = rm.CrystalSi(hkl=(1, 1, 1), tK=-171+273.15) si311_1 = rm.CrystalSi(hkl=(3, 1, 1), tK=-171+273.15) si111_2 = rm.CrystalSi(hkl=(1, 1, 1), tK=-140+273.15) si311_2 = rm.CrystalSi(hkl=(3, 1, 1), tK=-140+273.15) filterDiamond = rm.Material('C', rho=3.52, kind='plate') beamLine = raycing.BeamLine(azimuth=azimuth, height=height) wigglerToStraightSection = 645.0 xWiggler = x0 + wigglerToStraightSection * beamLine.sinAzimuth yWiggler = y0 + wigglerToStraightSection * beamLine.cosAzimuth rs.Wiggler(beamLine, name='MPW80', center=( xWiggler, yWiggler, height), nrays=nrays, period=80., K=13, n=12, eE=3., eI=0.4, eSigmaX=200, eSigmaZ=15, eEpsilonX=4.3, eEpsilonZ=0.043, eMin=eMinRays, eMax=eMaxRays, xPrimeMax=1.5, zPrimeMax=0.25) # rs.GeometricSource(beamLine, 'Source', (xWiggler, yWiggler, height), # nrays=nrays, distE='flat', energies=(2000, 25000), # polarization='horizontal') sampleToStraightSection = 36554.1 beamLine.xSample = x0 + sampleToStraightSection * beamLine.sinAzimuth beamLine.ySample = y0 + sampleToStraightSection * beamLine.cosAzimuth beamLine.feFixedMask = ra.RectangularAperture( beamLine, 'FEFixedMask', (-36876.69, -23321.01, height), ('left', 'right', 'bottom', 'top'), [-8.3, 8.3, -2.35, 2.35]) beamLine.fePhotonShutter = ra.RectangularAperture( beamLine, 'FEPhotonShutter', (-37133.37, -23064.33, height), ('left', 'right', 'bottom', 'top'), [-10.5, 10.5, -8.0, 8.0], alarmLevel=0.) beamLine.feMovableMaskLT = ra.RectangularAperture( beamLine, 'FEMovableMaskLT', (-38979.62, -21218.07, height), ('left', 'top'), [-10, 3.], alarmLevel=0.5) beamLine.feMovableMaskRB = ra.RectangularAperture( beamLine, 'FEMovableMaskRB', (-39262.47, -20935.23, height), ('right', 'bottom'), [10, -3.], alarmLevel=0.5) beamLine.filter1 = roe.Plate( beamLine, 'Filter1', (-42740.918, -17456.772, height), pitch=np.pi/2, limPhysX=(-20., 20.), limPhysY=(-9., 9.), surface=('diamond 90 $\mu$m',), material=(filterDiamond,), t=0.09, targetOpenCL=targetOpenCL, alarmLevel=0.) beamLine.fsm1 = rsc.Screen( beamLine, 'DiamondFSM1', (-42920.68, -17277.01, height), compressX=1./2.44) beamLine.vcm = roe.VCM( beamLine, 'VCM', [-43819.49, -16378.20, height], surface=('Rh', 'Si', 'Pt'), material=(stripeRh, stripeSi, stripePt), limPhysX=(-53., 53.), limPhysY=(-655., 655.), limOptX=((-47., -15.5, 16.), (-16., 15.5, 47.)), limOptY=((-650., -655., -650.), (650., 655., 650.)), R=5.0e6, jack1=[-43328.05, -16869.64, 973.0732], jack2=[-44403.38, -15964.02, 973.0732], jack3=[-44233.68, -15794.31, 973.0732], tx1=[0.0, -695.], tx2=[0.0, 705.75], targetOpenCL=targetOpenCL, alarmLevel=0.) beamLine.fsm2 = rsc.Screen( beamLine, 'NormalFSM2', (-44745.34, -15452.36, height), compressX=1./2.44) beamLine.dcm = roe.DCMOnTripodWithOneXStage( beamLine, 'DCM', [-45342.09, -14855.6, 1415.], surface=('Si311', 'Si111'), material=(si311_1, si111_1), material2=(si311_2, si111_2), limPhysX=((-51.1, 6.1), (-6.1, 51.1)), limPhysY=(-30., 30.), cryst2perpTransl=20., cryst2longTransl=95., limPhysX2=((8.6, -48.6), (48.6, -8.6)), limPhysY2=(-90., 90.), jack1=[-45052.88, -15079.04, 702.4973], jack2=[-44987.82, -14490.02, 702.4973], jack3=[-45576.85, -14555.08, 702.4973], targetOpenCL=targetOpenCL, alarmLevel=0.) beamLine.fsm3 = rsc.Screen( beamLine, 'DiamondFSM3', (-46625.89, -13571.81, height), compressX=1./2.44) beamLine.BSBlock = ra.RectangularAperture( beamLine, 'BSBlock', (-45988.52, -14209.17, height), ('bottom',), (22,), alarmLevel=0.) beamLine.slitAfterDCM_LR = ra.RectangularAperture( beamLine, 'SlitAfterDCM_LR', (-46095.65, -14102.04, height), ('left', 'right'), [-25.0, 25.0], alarmLevel=0.5) beamLine.slitAfterDCM_BT = ra.RectangularAperture( beamLine, 'SlitAfterDCM_BT', (-46107.67, -14090.02, height), ('bottom', 'top'), [27.0, 77.0], alarmLevel=0.5) foilsZActuatorOffset = 0 beamLine.xbpm4foils = ra.SetOfRectangularAperturesOnZActuator( beamLine, 'XBPM4foils', (-46137.73, -14059.97, height), (u'Cu5µm', u'Al7µm', u'Al0.8µm', 'top-edge'), (1344.607 + foilsZActuatorOffset, 1366.607 + foilsZActuatorOffset, 1388.607 + foilsZActuatorOffset, 1400. + foilsZActuatorOffset), (45, 45, 45), (8, 8, 8), alarmLevel=0.) beamLine.vfm = roe.DualVFM( beamLine, 'VFM', [-47491.364, -12706.324, 1449.53], surface=('Rh', 'Pt'), material=(stripeRh, stripePt), limPhysX=(-56., 56.), limPhysY=(-714., 714.), limOptX=((1., -46.), (46., -4.)), limOptY=((-712., -712.), (712., 712.)), positionRoll=np.pi, R=5.0e6, r1=70., xCylinder1=23.5, hCylinder1=3.7035, r2=35.98, xCylinder2=-25.0, hCylinder2=6.9504, jack1=[-46987.20, -13210.49, 1272.88], jack2=[-48062.53, -12304.87, 1272.88], jack3=[-47892.83, -12135.16, 1272.88], tx1=[0.0, -713.], tx2=[0.0, 687.75], targetOpenCL=targetOpenCL, alarmLevel=0.2) beamLine.fsm4 = rsc.Screen( beamLine, 'DiamondFSM4', (-48350.17, -11847.53, height), compressX=1./2.44) beamLine.ohPSFront = ra.RectangularAperture( beamLine, 'OH-PS-FrontCollimator', (-48592.22, -11605.47, height), ('left', 'right', 'bottom', 'top'), (-23., 23., 30.48, 79.92), alarmLevel=0.2) beamLine.ohPSBack = ra.RectangularAperture( beamLine, 'OH-PS-BackCollimator', (-48708.19, -11489.51, height), ('left', 'right', 'bottom', 'top'), (-23., 23., 31.1, 81.1), alarmLevel=0.) beamLine.eh100To40Flange = ra.RoundAperture( beamLine, 'eh100To40Flange', [-53420.63, -6777.058, height], 19., alarmLevel=0.) eh100To40FlangeToslit = 1159. slitX = beamLine.eh100To40Flange.center[0] +\ eh100To40FlangeToslit * np.sin(azimuth) slitY = beamLine.eh100To40Flange.center[1] +\ eh100To40FlangeToslit * np.cos(azimuth) beamLine.slitEH = ra.RectangularAperture( beamLine, 'slitEH', (slitX, slitY, height), ('left', 'right', 'bottom', 'top'), [-5, 5, -2.5, 2.5], alarmLevel=0.5) beamLine.fsmAtSample = rsc.Screen( beamLine, 'FocusAtSample', (beamLine.xSample, beamLine.ySample, height)) return beamLine
betaX=9., betaZ=2., eMax=eMax, xPrimeMax=thetaMax * 1e3, zPrimeMax=psiMax * 1e3, distE='BW') if case == 'Veritas': kwargs['period'] = 48. kwargs['n'] = 81 kwargs['K'] = 4.51 if case == 'Hippie': kwargs['period'] = 53. kwargs['n'] = 73 kwargs['K'] = 5.28 sourceW = rs.Wiggler(**kwargs) energy = np.linspace(100., eMax, eN) theta = np.linspace(-1, 1, 101) * thetaMax psi = np.linspace(-1, 1, 101) * psiMax # theta = np.linspace(-1, 1, 15) * thetaMax # psi = np.linspace(-1, 1, 15) * psiMax dtheta, dpsi = theta[1] - theta[0], psi[1] - psi[0] I0W = sourceW.intensities_on_mesh(energy, theta, psi)[0] fluxW = I0W.sum(axis=(1, 2)) * dtheta * dpsi dE = energy[1] - energy[0] power = fluxW.sum() * dE * SIE0 * 1e3 print('total power = {} W'.format(power)) cumpower = np.cumsum(fluxW) * dE * SIE0 * 1e3 / power ind = np.argwhere(cumpower > 0.5)[0] y1, y2 = cumpower[ind - 1], cumpower[ind] x1, x2 = energy[ind - 1], energy[ind]