示例#1
0
def build_beamline():
    bl = raycing.BeamLine()

    # Source
    bl.source = GeometricSource(bl=bl,
                                dx=0.02,
                                dz=0.02,
                                dxprime=4E-6,
                                dzprime=4E-6,
                                energies=[E0])
    # bl.source = GeometricSource(
    #     bl=bl, dx=0.02, dz=0.02, dxprime=0, dzprime=0, energies=[E0])

    # Optical elements
    bl.oes = []
    ParabolicalMirrorParam(bl=bl,
                           center=np.array([0, D, 0]),
                           pitch=m_pitch,
                           q=q,
                           material=m_mat,
                           isCylindrical=True,
                           limPhysY=[-200, 200])

    ParabolicalMirrorParam(bl=bl,
                           center=bl.oes[0].center + 2 * q * n,
                           pitch=-m_pitch,
                           positionRoll=np.pi,
                           p=q,
                           material=m_mat,
                           isCylindrical=True,
                           limPhysY=[-200, 200])

    # Screens
    bl.s1 = Screen(bl=bl, name='source', center=np.asarray(bl.source.center))
    bl.s2 = Screen(bl=bl,
                   name='focus',
                   center=bl.oes[0].center + q * n,
                   z=get_perpendicular_vector(n))
    bl.s3 = Screen(
        bl=bl,
        name='detector',
        center=bl.oes[1].center + np.array([0, 300, 0]),
    )

    print('\n\n')
    print('OEs position:')
    print(bl.oes[0].center)
    print(bl.oes[1].center)
    print('\n')
    print('\nScreens position:')
    print(bl.s1.center)
    print(bl.s2.center)
    print(bl.s3.center)
    print('\n\n')
    return bl
示例#2
0
def build_beamline():
    bl = raycing.BeamLine()

    # Source
    bl.source = LCLS_source(bl=bl, instrument=instrument, **source_kwargs)

    # Optical elements
    oes = []
    print('OEs position:')
    for kwargs in oes_kwargs:
        if 'crystal' in kwargs['name']:
            oes.append(OE(bl=bl, **kwargs))
        elif 'parabolic_mirror' in kwargs['name']:
            oes.append(ParabolicalMirrorParam(bl=bl, **kwargs))
        elif 'elliptical_mirror' in kwargs['name']:
            oes.append(EllipticalMirrorParam(bl=bl, **kwargs))
        elif 'flat_mirror' in kwargs['name']:
            oes.append(OE(bl=bl, **kwargs))
        print(oes[-1].center)
    bl.oes = oes

    # Screens
    print('\nScreens position:')
    for kwargs in s_kwargs:
        Screen(bl=bl, **kwargs)
        print(bl.screens[-1].center)
    # manual screens:
    bl.on_focus = Screen(bl=bl, **focus_kwargs)
    print('Focus:' + str(bl.screens[-1].center))
    bl.detector = Screen(bl=bl, **detector_kwargs)
    print('Detector:' + str(bl.screens[-1].center))
    print('\n')
    return bl
示例#3
0
def build_beamline():
    bl = raycing.BeamLine()

    # Source and optical elements
    bl.source = GeometricSource(bl=bl, **oes_kwargs[0])
    oes = []
    print('OEs position:')
    for kwargs in oes_kwargs[1:]:
        if 'crystal' in kwargs['name']:
            oes.append(OE(bl=bl, **kwargs))
        elif 'parabolic_mirror' in kwargs['name']:
            oes.append(ParabolicalMirrorParam(bl=bl, **kwargs))
        elif 'flat_mirror' in kwargs['name']:
            oes.append(OE(bl=bl, **kwargs))
        elif 'crl' in kwargs['name']:
            oes.append(DoubleParaboloidLens(bl=bl, **kwargs))
        elif 'slits' in kwargs['name']:
            oes.append(RectangularAperture(bl=bl, **kwargs))
        else:
            print('OE not implemented (build beamline)')
        print('\t' + oes[-1].name + ': ' + str(oes[-1].center))
    bl.oes = oes

    # Screens
    print('\nScreens position:')
    for kwargs in screens_kwargs:
        Screen(bl=bl, **kwargs)
        print('\t' + kwargs['name'] + ': ' + str(bl.screens[-1].center))
    print('\n')
    return bl
示例#4
0
def build_beamline():
    bl = raycing.BeamLine()

    # Source
    # bl.source = LCLS_source(bl=bl, instrument=instrument, **source_kwargs)
    pop = source_kwargs.pop('d_offset')
    # bl.source = GeometricSource(bl=bl, dx=100e-6, dz=100e-6, dxprime=2e-6, \
    #     dzprime=2e-6, **source_kwargs)
    bl.source = GeometricSource(bl=bl, dx=100e-6, dz=100e-6, dxprime=0, \
        dzprime=0, **source_kwargs)

    # Optical elements
    oes = []
    print('OEs position:')
    for kwargs in oes_kwargs:
        if 'crystal' in kwargs['name']:
            oes.append(OE(bl=bl, **kwargs))
        elif 'parabolic_mirror' in kwargs['name']:
            oes.append(ParabolicalMirrorParam(bl=bl, **kwargs))
        elif 'flat_mirror' in kwargs['name']:
            oes.append(OE(bl=bl, **kwargs))
        elif 'rectangular_aperture' in kwargs['name']:
            oes.append(RectangularAperture(bl=bl, **kwargs))
        else:
            print('OE not implemented (build beamline)')
        print('\t' + oes[-1].name + ': ' + str(oes[-1].center))
    bl.oes = oes

    # Screens
    print('\nScreens position:')
    for kwargs in s_kwargs:
        Screen(bl=bl, **kwargs)
        print('\t' + str(bl.screens[-1].center))
    for kwargs in special_screens_kwargs:
        Screen(bl=bl, **kwargs)
        print('\t' + str(bl.screens[-1].name) + ': ' +
              str(bl.screens[-1].center))

    # bl.on_focus = Screen(bl=bl, **focus_kwargs)
    # print('Focus:' + str(bl.screens[-1].center))
    # bl.detector = Screen(bl=bl, **detector_kwargs)
    # print('Detector:' + str(bl.screens[-1].center))
    print('\n')
    return bl