예제 #1
0
def build_beamline(nrays=1e5):
    beamLine = raycing.BeamLine(height=0)
#    source=rs.GeometricSource(
#        beamLine, 'GeometricSource', (0, 0, 0),
#        nrays=nrays, distx='flat', dx=0.12, distz='flat', dz=0.12,
#        dxprime=0, dzprime=0,
#        distE='flat', energies=(E0-dE, E0+dE), polarization='horizontal')
    rs.GeometricSource(
        beamLine, 'GeometricSource', (0, 0, 0),
        nrays=nrays, distx='annulus', dx=(0, 0.056),
        dxprime=0, dzprime=0,
        distE='flat', energies=(E0-dE, E0+dE), polarization='horizontal')

    beamLine.fsm1 = rsc.Screen(beamLine, 'DiamondFSM1', (0, 10., 0))
#    beamLine.fzp = roe.NormalFZP(beamLine, 'FZP', [0, 10., 0], pitch=np.pi/2,
#      material=mGold, f=2., E=E0, N=50)
    beamLine.fzp = roe.GeneralFZPin0YZ(
        beamLine, 'FZP', [0, 10., 0], pitch=np.pi/2,
        material=mGold, f1='inf', f2=(0, 0, 2.), E=E0, N=500, phaseShift=np.pi)

#    source.dx = 2 * beamLine.fzp.rn[-1]
#    source.dz = source.dx
    beamLine.fzp.order = 1
    beamLine.fsm2 = rsc.Screen(beamLine, 'DiamondFSM2', (0, 12., 0))
    return beamLine
예제 #2
0
def build_beamline(nrays=raycing.nrays):
    fixedExit = 15.

    beamLine = raycing.BeamLine(azimuth=0, height=0)
    hDiv = 1.5e-3
    vDiv = 2.5e-4
    beamLine.source = rs.GeometricSource(beamLine,
                                         'GeometricSource', (0, 0, 0),
                                         nrays=nrays,
                                         dx=0.1,
                                         dy=0,
                                         dz=2.,
                                         dxprime=hDiv / 2,
                                         dzprime=0,
                                         distE='flat',
                                         energies=eLimits,
                                         polarization='horizontal')

    beamLine.feMovableMask = ra.RectangularAperture(
        beamLine, 'FEMovableMask', [0, 10000, 0],
        ('left', 'top', 'right', 'bottom'), [-10, 3., 10, -3.])
    beamLine.feMovableMask.set_divergence(
        beamLine.source, [-hDiv / 2, vDiv / 2, hDiv / 2, -vDiv / 2])

    yDCM = 21000.
    si111 = rm.CrystalSi(hkl=(1, 1, 1), tK=-171 + 273.15)
    beamLine.dcm = roe.DCM(beamLine,
                           'DCM', (0, yDCM, 0),
                           surface=('Si111', ),
                           material=(si111, ))
    beamLine.dcm.bragg = math.asin(rm.ch / (2 * si111.d * E0))
    beamLine.dcm.cryst2perpTransl = fixedExit / 2. / math.cos(
        beamLine.dcm.bragg)

    beamLine.fsm1 = rsc.Screen(beamLine, 'FSM1', (0, yDCM + 700, 0))

    yVFM = 24000.
    beamLine.vfm = roe.ToroidMirror(beamLine,
                                    'VFM', (0, yVFM, fixedExit),
                                    pitch=4.0e-3)
    beamLine.vfm.R = yVFM / beamLine.vfm.pitch
    beamLine.vfm.r = 2. / 3. * yVFM * beamLine.vfm.pitch
    yFlatMirror = yVFM + 2000.
    zFlatMirror = (yFlatMirror - yVFM) * 2. * beamLine.vfm.pitch + fixedExit
    beamLine.vdm = roe.OE(beamLine,
                          'FlatMirror', (0, yFlatMirror, zFlatMirror),
                          pitch=-beamLine.vfm.pitch,
                          positionRoll=math.pi)

    ySample = 1.5 * yVFM
    yQWP = ySample - 3000.
    beamLine.qwp = roe.OE(beamLine,
                          'QWP', (0, yQWP, zFlatMirror),
                          roll=math.pi / 4,
                          material=(crystalDiamond, ))
    beamLine.qwp.pitch = theta0

    beamLine.fsm2 = rsc.Screen(beamLine, 'FSM2', (0, ySample, zFlatMirror))

    return beamLine
예제 #3
0
def build_beamline(nrays=1e5):
    beamLine = raycing.BeamLine(height=0)
    sourceCenter = [0, 0, 0]
    mirrorCenter = [0, p, p*np.tan(inclination)]

    kw = dict(
        nrays=nrays, distE='flat', energies=(E0-dE, E0+dE),
        polarization='horizontal', pitch=inclination)
    if case == 'elliptical':  # point source
        kw.update(dict(
            dx=0, dz=0, distxprime='flat', dxprime=1e-4,
            distzprime='flat', dzprime=1e-4))
        Mirror = roe.EllipticalMirrorParam
        kwMirror = dict(f1=sourceCenter, q=q)
    elif case == 'parabolical':  # collimated source
        kw.update(dict(
            dx=1, dz=1, distx='flat', distz='flat',
            distxprime=None, distzprime=None))
        Mirror = roe.ParabolicalMirrorParam
        dp = q * np.sin(2*pitch)
        di = q * np.sin(inclination)
        kwMirror = dict(f2=[mirrorCenter[0] + dp*np.sin(globalRoll),
                            mirrorCenter[1] + q,
                            mirrorCenter[2] + dp*np.cos(globalRoll) + di])
    rs.GeometricSource(
        beamLine, 'GeometricSource', sourceCenter, **kw)
    beamLine.fsm1 = rsc.Screen(beamLine, 'beforeMirror', mirrorCenter)
    beamLine.ellMirror = Mirror(
        beamLine, 'EllM', mirrorCenter, rotationSequence='RyRzRx',
        pitch=pitch+inclination*np.cos(globalRoll), positionRoll=globalRoll,
        yaw=inclination*np.sin(globalRoll), **kwMirror)

    beamLine.fsm2 = rsc.Screen(beamLine, '@focus', [0, 0, 0])
    beamLine.fsm2dY = np.linspace(-2, 2, 5) * q*0.1
    return beamLine
예제 #4
0
def build_beamline(nrays=1e5):
    beamLine = raycing.BeamLine(height=0)
#    rs.GeometricSource(beamLine, 'GeometricSource', (0, 0, 0),
#      nrays=nrays, dx=0, dz=0, distxprime='flat', dxprime=1e-4,
#      distzprime='flat', dzprime=1e-4,
#      distE='flat', energies=(E0-dE, E0+dE), polarization='horizontal')
    rs.GeometricSource(
        beamLine, 'GeometricSource', (0, 0, 0),
        nrays=nrays, distx='annulus', dx=(0, 1), dxprime=0, dzprime=0,
        distE='flat', energies=(E0-dE, E0+dE), polarization='horizontal')
    beamLine.fsm1 = rsc.Screen(beamLine, 'DiamondFSM1', (0., p-100, 0.))
    siCryst = rm.CrystalSi(hkl=(1, 1, 1), geom='Bragg-Fresnel')
    pitch = \
        siCryst.get_Bragg_angle(E0) - siCryst.get_dtheta_symmetric_Bragg(E0)
#    pitch = np.pi/2
    f = 0, p * np.cos(pitch), p * np.sin(pitch)
    beamLine.fzp = roe.GeneralFZPin0YZ(
        beamLine, 'FZP', [0., p, 0.], pitch=pitch,
        material=siCryst, f1='inf', f2=f, E=E0, N=340)
    beamLine.fzp.order = 1
    beamLine.fsm2 = rsc.Screen(beamLine, 'DiamondFSM2', [0, 0, 0],
                               z=(0, -np.sin(2*pitch), np.cos(2*pitch)))
    if showIn3D:
        beamLine.fsm2RelPos = [p]
    else:
        beamLine.fsm2RelPos = np.linspace(0, p, 21)
    return beamLine
예제 #5
0
def build_beamline():
    beamLine = raycing.BeamLine()

    beamLine.geometricSource01 = rsources.GeometricSource(
        bl=beamLine,
        name=None,
        center=[0, 0, 0],
        nrays=1000,
        distE=r"flat",
        dx=0.001,
        dz=0.001,
        dxprime=0,
        dzprime=0,
        energies=[Emin, Emax])

    beamLine.screen02 = rscreens.Screen(bl=beamLine, center=[0, 10000, 0])

    beamLine.lauePlate01 = roes.BentLaueCylinder(
        #    beamLine.lauePlate01 = roes.LauePlate(
        bl=beamLine,
        name=None,
        center=[0, 10000, 0],
        pitch=0.0,
        R=1e4,
        crossSection='parabolic',
        material=crystalSi01,
        targetOpenCL='CPU')

    beamLine.screen01 = rscreens.Screen(bl=beamLine,
                                        name=None,
                                        center=[0.0, 20000, 0.0])

    return beamLine
예제 #6
0
파일: crl_stack.py 프로젝트: silexanaej/xrt
def build_beamline(nrays=1e4):
    beamLine = raycing.BeamLine(height=0)
    #    rs.CollimatedMeshSource(beamLine, 'CollimatedMeshSource', dx=2, dz=2,
    #      nx=21, nz=21, energies=(E0,), withCentralRay=False, autoAppendToBL=True)
    rs.GeometricSource(beamLine,
                       'CollimatedSource',
                       nrays=nrays,
                       dx=0.5,
                       dz=0.5,
                       distxprime=None,
                       distzprime=None,
                       energies=(E0, ))

    beamLine.fsm1 = rsc.Screen(beamLine, 'FSM1', (0, p - 100, 0))

    beamLine.lens = Lens(beamLine,
                         'CRL', [0, p, 0],
                         pitch=np.pi / 2,
                         t=0,
                         material=mBeryllium,
                         focus=parabolaParam,
                         zmax=zmax,
                         nCRL=(q, E0),
                         alarmLevel=0.1)

    beamLine.fsm2 = rsc.Screen(beamLine, 'FSM2')
    beamLine.fsm2.dqs = np.linspace(-140, 140, 71)
    #    beamLine.fsm2.dqs = np.linspace(-70, 70, 15)
    return beamLine
예제 #7
0
def build_beamline(nrays=raycing.nrays):
    fixedExit = 15.

    beamLine = raycing.BeamLine(azimuth=0, height=0)
    rs.GeometricSource(
        beamLine, 'GeometricSource', (0, 0, -fixedExit),
        nrays=nrays, dx=5., dy=0, dz=5., dxprime=0., dzprime=0.,
        distE='flat', energies=eLimits, polarization='horizontal')

    p = 20000.
    si111 = rm.CrystalSi(hkl=(1, 1, 1), tK=-171+273.15)
    beamLine.dcm = roe.DCM(beamLine, 'DCM', (0, p - 2000, -fixedExit),
                           surface=('Si111',), material=(si111,))
    beamLine.dcm.bragg = math.asin(rm.ch / (2 * si111.d * E0))
    beamLine.dcm.cryst2perpTransl = fixedExit/2./math.cos(beamLine.dcm.bragg)

    beamLine.fsm1 = rsc.Screen(beamLine, 'FSM1', (0, p - 1000, 0))

    beamLine.qwp = roe.LauePlate(beamLine, 'QWP', (0, p, 0),
                                 material=(crystalDiamond,))
    beamLine.qwp.pitch = theta0 + math.pi/2
    q = 50.
    beamLine.fsm2 = rsc.Screen(beamLine, 'FSM2', (0, p + q, 0))

    return beamLine
예제 #8
0
def build_beamline(nrays=1e5):
    beamLine = raycing.BeamLine()
    beamLine.source = Source(
        beamLine, eN=1000, nx=40, nz=20, nrays=nrays, **kwargs)
    beamLine.fsm0 = rsc.Screen(beamLine, 'FSM0', (0, 0, 0))
    beamLine.fsm1 = rsc.Screen(beamLine, 'FSM1', (0, R0, 0))
    return beamLine
예제 #9
0
파일: warp.py 프로젝트: wholden/xrt
def build_beamline():
    beamLine = raycing.BeamLine()
    beamLine.oe = ToroidMirrorDistorted(beamLine,
                                        'warped',
                                        center=[0, p, 0],
                                        pitch=pitch,
                                        R=Rnom,
                                        r=rdefocus)
    dx = beamLine.oe.limPhysX[1] - beamLine.oe.limPhysX[0]
    dy = beamLine.oe.limPhysY[1] - beamLine.oe.limPhysY[0]
    #    beamLine.source = rs.GeometricSource(
    #        beamLine, 'CollimatedSource', nrays=nrays, dx=source_dX, dz=source_dZ,
    #        dxprime=dx/p/2, dzprime=dy/p*np.sin(pitch)/2)
    kwargs = dict(eE=3.,
                  eI=0.5,
                  eEspread=0,
                  eEpsilonX=eEpsilonX * 1e9 * emittanceFactor,
                  eEpsilonZ=eEpsilonZ * 1e9 * emittanceFactor,
                  betaX=betaX,
                  betaZ=betaZ,
                  period=18.5,
                  n=108,
                  K=K,
                  filamentBeam=(what != 'rays'),
                  xPrimeMax=dx / 2 / p * 1e3,
                  zPrimeMax=dy / 2 / p * np.sin(pitch) * 1e3,
                  xPrimeMaxAutoReduce=False,
                  zPrimeMaxAutoReduce=False,
                  eMin=E0 - dE / 2,
                  eMax=E0 + dE / 2)
    beamLine.source = rs.Undulator(beamLine, nrays=nrays, **kwargs)
    beamLine.fsm0 = rsc.Screen(beamLine, 'FSM0', [0, p + q, 0])
    beamLine.fsm1 = rsc.Screen(beamLine, 'FSM1',
                               [0, p + q, q * np.tan(2 * pitch)])
    return beamLine
예제 #10
0
def build_beamline():
    beamLine = raycing.BeamLine(height=0)
    rs.GeometricSource(beamLine, 'GeometricSource', dx=3., dz=3.,
                       dxprime=1.6e-4, distzprime=None)
    beamLine.fsm1 = rsc.Screen(beamLine, 'FSM1', (0, pLaueSCM - 100, 0))
    beamLine.laueSCM = roe.BentLaueCylinder(
        beamLine, 'LaueSCM', (0, pLaueSCM, 0), material=(siCrystal,))
    beamLine.fsm2 = rsc.Screen(beamLine, 'FSM2', [0, pLaueSCM + qLaueSCM, 0])
    return beamLine
예제 #11
0
def build_beamline(nrays=mynrays):
    beamLine = raycing.BeamLine()
    beamLine.source = rs.Undulator(beamLine, nrays=nrays, **kwargs)
    beamLine.fsm0 = rsc.Screen(beamLine, 'FSM0', (0, R0, 0))
    beamLine.slit = ra.RectangularAperture(beamLine, 'squareSlit', [0, R0, 0],
                                           ('left', 'right', 'bottom', 'top'),
                                           [-slitDx, slitDx, -slitDz, slitDz])

    beamLine.fsm1 = rsc.Screen(beamLine, 'FSM1', [0, R0, 0])
    return beamLine
예제 #12
0
def build_beamline(nrays=mynrays):
    beamLine = raycing.BeamLine()
    rs.Undulator(beamLine, nrays=nrays, **kwargs)

    beamLine.fsm0 = rsc.Screen(beamLine, 'FSM0', (0, R0-1, 0))
    beamLine.slit = ra.DoubleSlit(
        beamLine, 'squareSlit', [0, R0, 0], ('left', 'right', 'bottom', 'top'),
        [-slitDx/2, slitDx/2, -slitDz/2, slitDz/2], shadeFraction=0.1)
    beamLine.fsm1 = rsc.Screen(beamLine, 'FSM1', [0, R0+dR, 0])
    return beamLine
예제 #13
0
def build_beamline(nrays=1000):
    beamLine = raycing.BeamLine(height=0)
    rs.GeometricSource(beamLine,
                       'GeometricSource', (0, 0, 0),
                       nrays=nrays,
                       dx=0.,
                       dz=0.,
                       distxprime='annulus',
                       distE='lines',
                       energies=(E0, ),
                       polarization='horizontal')
    beamLine.fsm1 = rsc.Screen(beamLine, 'DiamondFSM1', (0, rSample, 0))
    beamLine.capillaries = []
    beamLine.firstInLayer = []
    beamLine.xzMax = 0
    for n in range(layers):
        if n > 0:
            ms = range(n)
            i6 = range(6)
        else:
            ms = 0,
            i6 = 0,
        beamLine.firstInLayer.append(len(beamLine.capillaries))
        for i in i6:
            for m in ms:
                x = 2 * (r0 + wall) * (n**2 + m**2 - n * m)**0.5
                alpha = np.arcsin(x / rSample)
                roll1 = -np.arctan2(np.sqrt(3) * m, 2 * n - m)
                roll = roll1 + i * np.pi / 3.
                capillary = BentCapillary(
                    beamLine,
                    'BentCapillary', [0, 0, 0],
                    roll=roll,
                    material=mGlass,
                    limPhysY=[rSample * np.cos(alpha), f],
                    f=f,
                    rSample=rSample,
                    entranceAlpha=alpha,
                    rIn=r0,
                    rOut=r0)
                beamLine.capillaries.append(capillary)
                if beamLine.xzMax < capillary.b0:
                    beamLine.xzMax = capillary.b0
    print('max divergence =', alpha)
    beamLine.xzMax += 2 * r0
    print(len(beamLine.capillaries))
    beamLine.sources[0].dxprime = 0, np.arcsin(
        (2 * n + 1) * (r0 + wall) / rSample)
    #    beamLine.sources[0].dxprime = (np.arcsin((2*n-3) * (r0+wall) / rSample),
    #        np.arcsin((2*n+1) * (r0+wall) / rSample))
    #    beamLine.sources[0].dxprime = 0, np.arcsin(r0 / rSample)
    beamLine.fsm2 = rsc.Screen(beamLine, 'DiamondFSM2', (0, f, 0))
    return beamLine
예제 #14
0
def build_beamline():
    P02_2 = raycing.BeamLine()

    P02_2.Undulator01 = rsources.GeometricSource(
        bl=P02_2,
        nrays=5e4,
        name='source',
        polarization='horizontal',
        dx=0.5,
        dz=0.5,
        dxprime=0.005e-3,
        dzprime=0.005e-3,
        distx='normal',
        distz='normal',
        energies=(60000, 60) if powder else (1000, 100000),
        distE='normal' if powder else 'flat')

    P02_2.FSM_Source = rscreens.Screen(bl=P02_2,
                                       name=r"FSM_Source",
                                       center=[0, 29001, 0])

    P02_2.Sample = roes.LauePlate(
        bl=P02_2,
        name=r"CeO2 Powder Sample" if powder else "Silicon 001 wafer",
        center=[0, 65000, 0],
        pitch='90deg',
        yaw=0 if powder else '45deg',
        rotationSequence='RxRyRz',
        material=PowderSample if powder else MonoCrystalSample,
        targetOpenCL=(0, 0),
        precisionOpenCL='float32')

    P02_2.FSM_Sample = rscreens.Screen(bl=P02_2,
                                       name=r"After Sample",
                                       center=[0, 65100, 0])

    P02_2.RoundBeamStop01 = rapts.RoundBeamStop(bl=P02_2,
                                                name=r"BeamStop",
                                                center=[0, 65149, 0],
                                                r=5)

    P02_2.Frame = rapts.RectangularAperture(
        bl=P02_2,
        name=r"Frame",
        center=[0, 65149.5, 0],
        opening=[-dSize, dSize, -dSize, dSize])

    P02_2.FSM_Detector = rscreens.Screen(bl=P02_2,
                                         name=r"Detector",
                                         center=[0, 65150, 0])

    return P02_2
예제 #15
0
    def make_screens(self):
        """ One screen at the exit and one somewhere far """
        self.beamLine.exitScreen = rsc.Screen(self.beamLine,
                                     'Exitscreen',
                                     (0, self.y_outrance, 0))

        self.beamLine.farScreen = rsc.Screen(self.beamLine,
                                     'FarScreen',
                                     (0, self.far_screen_dist, 0))

        # Just reuse the far screen for now
        self.beamLine.totalScreen = rsc.Screen(self.beamLine,
                                     'FarScreen',
                                     (0, self.far_screen_dist, 0))
예제 #16
0
파일: Grating.py 프로젝트: silexanaej/xrt
def build_beamline(nrays=raycing.nrays):
    beamLine = raycing.BeamLine(height=0)
    rs.GeometricSource(
        beamLine, 'GeometricSource', (0, 0, 0),
        nrays=nrays, dx=0., dz=0., dxprime=2e-4, dzprime=1e-4,
        distE='lines', energies=(75, 100, 125), polarization='horizontal')
#    beamLine.feFixedMask = ra.RectangularAperture(beamLine,
#      'FEFixedMask', 0, 10000,
#      ('left', 'right', 'bottom', 'top'), [-3., 3., -1., 1.])
    beamLine.fsm1 = rsc.Screen(beamLine, 'DiamondFSM1', (0., 10001., 0.))
    beamLine.grating = Grating(beamLine, 'PlaneGrating', [0., 15000., 0.],
                               pitch=np.radians(10), material=mGold)
    beamLine.grating.order = np.arange(-2, 3)
    beamLine.fsm2 = rsc.Screen(beamLine, 'DiamondFSM2', (0., fsm2pos, 0.))
    return beamLine
예제 #17
0
def build_beamline(nrays=1e4):
    beamLine = raycing.BeamLine(height=0)
    rs.GeometricSource(
        beamLine, 'CollimatedSource', nrays=nrays,
        dx=0.5, dz=0.5, distxprime=None, distzprime=None, energies=(E0,))

    beamLine.lenses = []
    ilens = 0
    while True:
        roll = 0.
        if Lens == roe.ParabolicCylinderFlatLens:
            roll = -np.pi/4 if ilens % 2 == 0 else np.pi/4
        lens = Lens(
            beamLine, 'Lens{0:02d}'.format(ilens), center=[0, p + dz*ilens, 0],
            pitch=np.pi/2, roll=roll, t=0.1, material=material,
            limPhysX=[-2, 2], limPhysY=[-2, 2], shape='round',
            focus=parabolaParam, zmax=zmax, alarmLevel=0.1)
        beamLine.lenses.append(lens)
        if ilens == 0:
            nCRL = lens.get_nCRL(q, E0)
        ilens += 1
        if nCRL - ilens < 0.5:
            break

    beamLine.fsmF = rsc.Screen(beamLine, 'FSM-focus', [0, p+q, 0])
    return beamLine
예제 #18
0
def build_beamline():
    beamLine = raycing.BeamLine(height=0)
    beamLine.source = rs.LaguerreGaussianBeam(
        beamLine, 'Laguerre-Gaussian', w0=w0, vortex=(lVortex, pVortex),
        energies=(E0,))
    beamLine.fsmFar = rsc.Screen(beamLine, 'FSM', [0, 0, 0])
    return beamLine
예제 #19
0
def build_beamline(nrays=2e5):
    beamLine = raycing.BeamLine()
    rs.Undulator(
        beamLine,
        'P06',
        nrays=nrays,
        eEspread=0.0011,
        eSigmaX=34.64,
        eSigmaZ=6.285,
        eEpsilonX=1.,
        eEpsilonZ=0.01,
        period=31.4,
        K=2.1392 - 0.002,
        n=63,
        eE=6.08,
        eI=0.1,
        xPrimeMax=1.5e-2,
        zPrimeMax=1.5e-2,
        eMin=eMin,
        eMax=eMax,
        distE='BW',
        xPrimeMaxAutoReduce=False,
        zPrimeMaxAutoReduce=False,
        #        targetOpenCL='CPU',
        taper=(1.09, 11.254))
    beamLine.fsm1 = rsc.Screen(beamLine, 'FSM1', (0, 90000, 0))
    return beamLine
예제 #20
0
def build_beamline(nrays=1e5):
    beamLine = raycing.BeamLine(azimuth=0, height=0)
    rs.GeometricSource(beamLine,
                       'GeometricSource',
                       nrays=nrays,
                       dx=beamH,
                       dy=0,
                       dz=beamV,
                       distxprime='flat',
                       distzprime='flat',
                       polarization=None)
    beamLine.analyzer = Toroid(beamLine,
                               analyzerName,
                               surface=('', ),
                               limPhysX=(-dxCrystal / 2, dxCrystal / 2),
                               limPhysY=(-dyCrystal / 2, dyCrystal / 2),
                               Rm=Rm,
                               Rs=Rs,
                               shape='rect',
                               **facetKWargs)
    beamLine.detector = rsc.Screen(beamLine, 'Detector', z=(0, 0, 1))
    #    beamLine.s1h = ra.RectangularAperture(
    #        beamLine, 'horizontal. slit', 0, Rs-10.,
    #        ('left', 'right'), [-0.1, 0.1])
    return beamLine
예제 #21
0
def build_beamline(nrays=mynrays):
    beamLine = raycing.BeamLine()
    beamLine.source = rs.Undulator(beamLine, nrays=nrays, **kwargs)
    beamLine.fsm0 = rsc.Screen(beamLine, 'FSM0', (0, R0, 0))
    #    beamLine.slit = ra.RectangularAperture(
    #        beamLine, 'squareSlit', [0, R0, 0], ('left', 'right', 'bottom', 'top'),
    #        [-slitDx, slitDx, -slitDz, slitDz])

    beamLine.slit = ra.SiemensStar(bl=beamLine,
                                   name='SiemensStar',
                                   center=[0, R0, 0],
                                   nSpokes=nSpokes,
                                   rX=slitDx,
                                   rZ=slitDz,
                                   phi0=0.5 * np.pi / nSpokes)

    beamLine.fsm1 = rsc.Screen(beamLine, 'FSM1', [0, R0, 0])
    return beamLine
예제 #22
0
def build_beamline(nrays=1e5):
    beamLine = raycing.BeamLine(height=0)
    rs.GeometricSource(beamLine,
                       'GeometricSource',
                       nrays=nrays,
                       dx=3.,
                       dz=3.,
                       dxprime=1.6e-4,
                       distzprime=None)
    beamLine.fsm1 = rsc.Screen(beamLine, 'FSM1', (0, pLaueDCM - 100, 0))
    beamLine.laueDCM1 = roe.BentLaueCylinder(beamLine,
                                             'LaueDCM1', (0, pLaueDCM, 0),
                                             material=(si111, ))
    beamLine.laueDCM2 = roe.BentLaueCylinder(beamLine,
                                             'LaueDCM2', [0, 0, fixedExit],
                                             material=(si111, ))
    beamLine.fsm2 = rsc.Screen(beamLine, 'FSM2',
                               [0, pLaueDCM + qLaueDCM, fixedExit])
    return beamLine
예제 #23
0
파일: HOMS.py 프로젝트: slaclab/RayTraceSim
def build_beamline(und_x, und_xp, und_y, und_yp, und_z, p1h_x, p1h_z, m1h_x,
                   m1h_alpha, m1h_z, p2h_x, p2h_z, m2h_x, m2h_alpha, m2h_z,
                   p3h_x, p3h_z, dg3_x, dg3_z):
    HOMS = raycing.BeamLine()

    HOMS.Source = rsources.GeometricSource(bl=HOMS,
                                           name=None,
                                           center=[-und_x, und_z, und_y],
                                           dx=0.1,
                                           dz=0.1,
                                           dxprime=0.0000005,
                                           dzprime=0.0000005)

    HOMS.P1H = rscreens.Screen(bl=HOMS,
                               name=None,
                               center=[-p1h_x * 1e3, p1h_z * 1e3, 0])

    HOMS.M1H = roes.OE(bl=HOMS,
                       name=None,
                       center=[-m1h_x * 1e3, m1h_z * 1e3, 0],
                       pitch=m1h_alpha,
                       positionRoll=-np.pi / 2)

    HOMS.P2H = rscreens.Screen(bl=HOMS,
                               name=None,
                               center=[-p2h_x * 1e3, p2h_z * 1e3, 0])

    HOMS.M2H = roes.OE(bl=HOMS,
                       name=None,
                       center=[-m2h_x * 1e3, m2h_z * 1e3, 0],
                       pitch=-m2h_alpha,
                       positionRoll=np.pi / 2)

    HOMS.P3H = rscreens.Screen(bl=HOMS,
                               name=None,
                               center=[-p3h_x * 1e3, p3h_z * 1e3, 0])

    HOMS.DG3 = rscreens.Screen(bl=HOMS,
                               name=None,
                               center=[-dg3_x * 1e3, dg3_z * 1e3, 0])

    return HOMS
예제 #24
0
def build_beamline(nrays=raycing.nrays):
    beamLine = raycing.BeamLine(azimuth=0, height=0)
    rs.GeometricSource(
        beamLine, 'GeometricSource', nrays=nrays, dx=beamH, dy=0,
        dz=0.05, distxprime='flat', distzprime='flat', polarization=None)
    beamLine.analyzer = Cylinder(
        beamLine, analyzerName, surface=('',), R=Rm,
        limPhysX=(-dxCrystal/2, dxCrystal/2),
        limPhysY=(-dyCrystal/2, dyCrystal/2))
    beamLine.detector = rsc.Screen(beamLine, 'Detector')
    return beamLine
예제 #25
0
파일: Cylinder.py 프로젝트: wholden/xrt
def build_beamline(nrays=raycing.nrays):
    beamLine = raycing.BeamLine(height=0)
    rs.GeometricSource(beamLine,
                       'GeometricSource', (0, 0, 0),
                       nrays=nrays,
                       dx=0.,
                       dz=0.,
                       dxprime=5e-4,
                       dzprime=1e-5,
                       distE='lines',
                       energies=(E0, ),
                       polarization='horizontal')
    beamLine.fsm1 = rsc.Screen(beamLine, 'DiamondFSM1', (0, 100, 0))

    if isFlat:
        fName = 'Flat'
        beamLine.cylinder = roe.OE(beamLine,
                                   'FlatP', [0, 1000, -0.01],
                                   pitch=3e-3,
                                   material=mGold,
                                   isParametric=isParametric)
    else:
        fName = 'Cylinder'
        limPhysX = [-5, 5]
        limPhysY = [0, L]
        if isParametric:
            CylinderClass = CylinderP
        else:
            CylinderClass = Cylinder
        beamLine.cylinder = CylinderClass(beamLine,
                                          fName, [0, 1000, -0.05],
                                          pitch=3e-3,
                                          material=mGold,
                                          limPhysX=limPhysX,
                                          limPhysY=limPhysY,
                                          Rm=Rm,
                                          isParametric=isParametric)

    beamLine.fsm2 = rsc.Screen(beamLine, 'DiamondFSM2', (0, 2000, 0))
    return beamLine, fName
예제 #26
0
def build_beamline():
    beamLine = raycing.BeamLine()

    beamLine.source = rsources.GeometricSource(
        beamLine,
        center=[0, 0, 0],
        dx=2,
        dz=1,
        dxprime=25e-06,
        dzprime=25e-06,
        # distE=r"normal", energies=[Ec, 1],
        energies=[Ec],
        nrays=nrays)

    beamLine.screenSource = rscreens.Screen(beamLine, center=[0, 2000, 0])

    bragg = crystalSi.get_Bragg_angle(Ec) - crystalSi.get_dtheta(Ec, alpha)
    b = -np.sin(bragg + alpha) / np.sin(bragg - alpha)
    print('bragg={0:.3f}deg; alpha={1:.3f}deg, b={2:.3f}'.format(
        np.degrees(bragg), np.degrees(alpha), b))
    beamLine.bragg = bragg
    beamLine.xtal = roes.OE(bl=beamLine,
                            center=[0, 2000, 0],
                            material=crystalSi,
                            pitch=bragg + alpha,
                            alpha=alpha)

    p = 0
    beamLine.screenXtal = rscreens.Screen(
        beamLine,
        center=[0, 2000 + p, p * np.tan(2 * bragg)],
        x=[1, 0, 0],
        z=[0, -np.sin(2 * bragg), np.cos(2 * bragg)])

    beamLine.dbragg = crystalSi.get_refractive_correction(Ec,
                                                          alpha=alpha) * 1e6
    print(u'refractive shift = {0} µrad'.format(beamLine.dbragg))

    return beamLine
예제 #27
0
def build_beamline():
    HOMS = raycing.BeamLine()

    HOMS.Source = rsources.GeometricSource(bl=HOMS,
                                           name=None,
                                           center=[0, 0, 0],
                                           dx=0.1,
                                           dz=0.1,
                                           dxprime=0.0000005,
                                           dzprime=0.0000005)

    HOMS.P1H = rscreens.Screen(bl=HOMS, name=None, center=[0, 89894, 0])

    HOMS.M1H = roes.OE(bl=HOMS,
                       name=None,
                       center=[0, 90510, 0],
                       pitch=0.0014,
                       positionRoll=-np.pi / 2)

    HOMS.P2H = rscreens.Screen(bl=HOMS,
                               name=None,
                               center=[-28.8904, 100828, 0])

    HOMS.M2H = roes.OE(bl=HOMS,
                       name=None,
                       center=[-31.7324, 101843, 0],
                       yaw=0.0014,
                       positionRoll=np.pi / 2)

    HOMS.P3H = rscreens.Screen(bl=HOMS,
                               name=None,
                               center=[-31.7324, 101843, 0])

    HOMS.DG3 = rscreens.Screen(bl=HOMS,
                               name=None,
                               center=[-31.7324, 101843, 0])

    return HOMS
예제 #28
0
def build_beamline(nrays=mynrays):
    beamLine = raycing.BeamLine()
    beamLine.source = rs.Undulator(beamLine, nrays=nrays, **kwargs)
    beamLine.fsm0 = rsc.Screen(beamLine, 'FSM0', (0, R0, 0))
#    beamLine.slit = ra.RectangularAperture(
#        beamLine, 'squareSlit', [0, R0, 0], ('left', 'right', 'bottom', 'top'),
#        [-slitDx, slitDx, -slitDz, slitDz])

    star = np.linspace(0, 2*np.pi, 6)
    starX = slitDx*np.sin(star)
    starY = slitDx*np.cos(star)
    
    beamLine.slit = ra.PolygonalAperture(
        bl=beamLine,
        name=None,
        center=[0, R0, 0],
        opening=[(starX[0], starY[0]), (starX[2], starY[2]), 
                 (starX[4], starY[4]), (starX[1], starY[1]),
                 (starX[3], starY[3]), (starX[0], starY[0])])
#        opening=list(zip(starX, starY)))

    beamLine.fsm1 = rsc.Screen(beamLine, 'FSM1', [0, R0, 0])
    return beamLine
예제 #29
0
파일: MontelMirror.py 프로젝트: wholden/xrt
def build_beamline(nrays=raycing.nrays):
    beamLine = raycing.BeamLine(height=0)
    rs.GeometricSource(beamLine,
                       'GeometricSource', (0, 0, 0),
                       nrays=nrays,
                       dx=0.,
                       dz=0.,
                       dxprime=2e-4,
                       dzprime=1e-4,
                       distE='lines',
                       energies=(E0, ),
                       polarization='horizontal')

    if case == 'parabolic':
        mirrorVFM = roe.BentFlatMirror
        mirrorHFM = roe.BentFlatMirror
        RVFM = 2 * p / np.sin(pitchVFM)
        kwargsVFM = {'R': RVFM}
        RHFM = 2 * p / np.sin(pitchHFM)
        kwargsHFM = {'R': RHFM}
    elif case == 'elliptical':
        mirrorVFM = roe.EllipticalMirrorParam
        mirrorHFM = roe.EllipticalMirrorParam
        kwargsVFM = {'p': pVFM, 'q': qVFM, 'isCylindrical': True}
        kwargsHFM = {'p': pHFM, 'q': qHFM, 'isCylindrical': True}
    else:
        raise

    beamLine.VFM = mirrorVFM(beamLine,
                             'VFM', [0, p, 0],
                             material=mGold,
                             limPhysX=[gap / 2, W],
                             limPhysY=[-L / 2, L / 2],
                             rotationSequence='RxRyRz',
                             pitch=pitchVFM,
                             yaw=-pitchHFM,
                             **kwargsVFM)
    beamLine.HFM = mirrorHFM(beamLine,
                             'HFM', [0, p, 0],
                             material=mGold,
                             limPhysX=[-W, -gap / 2],
                             limPhysY=[-L / 2, L / 2],
                             rotationSequence='RyRzRx',
                             positionRoll=np.pi / 2,
                             pitch=pitchHFM,
                             yaw=pitchVFM,
                             **kwargsHFM)
    beamLine.fsmMontel = rsc.Screen(beamLine, 'FSM-Montel', (0, p + q, 0))
    return beamLine
예제 #30
0
def build_beamline():
    beamLine = raycing.BeamLine(height=0)
    beamLine.source = rs.LaguerreGaussianBeam(beamLine,
                                              'Laguerre-Gaussian',
                                              w0=w0,
                                              vortex=(lVortex, pVortex),
                                              energies=(E0, ))
    beamLine.slit = ra.SiemensStar(bl=beamLine,
                                   center=[0, 0.1, 0],
                                   nSpokes=nSpokes,
                                   rX=w0,
                                   rZ=w0,
                                   phi0=0.5 * np.pi / nSpokes,
                                   vortex=0)
    beamLine.fsmFar = rsc.Screen(beamLine, 'FSM', [0, 0, 0])
    return beamLine