Пример #1
0
def srw_end_bl_call():
    el2 = []
    el2.append(srwlib.SRWLOptA("r", "a", 50000.0, 50000.0, 0.0, 0.0))
    opMask = setup_mask()
    el2.append(srwlib.SRWLOptD(1e-32))
    el2.append(opMask)
    el2.append(srwlib.SRWLOptD(0.2))
    pp2 = []
    pp2.append([0, 0, 1.0, 1, 0, 1, 1, 1, 1])
    pp2.append([0, 0, 1.0, 1, 0, xRatio, 1 / xRatio, xRatio, 1 / yRatio])
    pp2.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])  #mask
    pp2.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    pp2.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
    op2 = deepcopy(srwlib.SRWLOptC(el2, pp2))

    int_ws2 = propogation(op2)
    mesh_ws2 = deepcopy(wfr2.mesh)
    print('.....', mesh_ws2.xStart, mesh_ws2.ny, '......')

    up.uti_plot2d1d(
        int_ws2, [mesh_ws2.xStart, mesh_ws2.xFin, mesh_ws2.nx],
        [mesh_ws2.yStart, mesh_ws2.yFin, mesh_ws2.ny], 0, 0,
        ['Horizontal Position', 'Vertical Position', ' After Propagation'],
        ['m', 'm', 'ph/s/.1%bw/mm^2'], True)
    up.uti_plot_show()
Пример #2
0
def set_optics(v=None):
    el = []
    pp = []
    names = [
        'CRL', 'CRL_Watchpoint', 'Watchpoint', 'Fiber', 'Fiber_Watchpoint2',
        'Watchpoint2'
    ]
    for el_name in names:
        if el_name == 'CRL':
            # CRL: crl 36.0m
            el.append(
                srwlib.srwl_opt_setup_CRL(
                    _foc_plane=v.op_CRL_foc_plane,
                    _delta=v.op_CRL_delta,
                    _atten_len=v.op_CRL_atten_len,
                    _shape=v.op_CRL_shape,
                    _apert_h=v.op_CRL_apert_h,
                    _apert_v=v.op_CRL_apert_v,
                    _r_min=v.op_CRL_r_min,
                    _n=v.op_CRL_n,
                    _wall_thick=v.op_CRL_wall_thick,
                    _xc=v.op_CRL_x,
                    _yc=v.op_CRL_y,
                ))
            pp.append(v.op_CRL_pp)
        elif el_name == 'CRL_Watchpoint':
            # CRL_Watchpoint: drift 36.0m
            el.append(srwlib.SRWLOptD(_L=v.op_CRL_Watchpoint_L, ))
            pp.append(v.op_CRL_Watchpoint_pp)
        elif el_name == 'Watchpoint':
            # Watchpoint: watch 70.1915m
            pass
        elif el_name == 'Fiber':
            # Fiber: fiber 70.1915m
            el.append(
                srwlib.srwl_opt_setup_cyl_fiber(
                    _foc_plane=v.op_Fiber_foc_plane,
                    _delta_ext=v.op_Fiber_delta_ext,
                    _delta_core=v.op_Fiber_delta_core,
                    _atten_len_ext=v.op_Fiber_atten_len_ext,
                    _atten_len_core=v.op_Fiber_atten_len_core,
                    _diam_ext=v.op_Fiber_externalDiameter,
                    _diam_core=v.op_Fiber_diam_core,
                    _xc=v.op_Fiber_xc,
                    _yc=v.op_Fiber_yc,
                ))
            pp.append(v.op_Fiber_pp)
        elif el_name == 'Fiber_Watchpoint2':
            # Fiber_Watchpoint2: drift 70.1915m
            el.append(srwlib.SRWLOptD(_L=v.op_Fiber_Watchpoint2_L, ))
            pp.append(v.op_Fiber_Watchpoint2_pp)
        elif el_name == 'Watchpoint2':
            # Watchpoint2: watch 70.85m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Пример #3
0
def set_optics(v=None):
    el = []
    pp = []
    names = ['M1', 'M1_M2', 'M2', 'M2_Watchpoint', 'Watchpoint']
    for el_name in names:
        if el_name == 'M1':
            # M1: ellipsoidMirror 28.5m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_M1_p,
                    _q=v.op_M1_q,
                    _ang_graz=v.op_M1_ang,
                    _size_tang=v.op_M1_size_tang,
                    _size_sag=v.op_M1_size_sag,
                    _nvx=v.op_M1_nvx,
                    _nvy=v.op_M1_nvy,
                    _nvz=v.op_M1_nvz,
                    _tvx=v.op_M1_tvx,
                    _tvy=v.op_M1_tvy,
                    _x=v.op_M1_x,
                    _y=v.op_M1_y,
                ))
            pp.append(v.op_M1_pp)

        elif el_name == 'M1_M2':
            # M1_M2: drift 28.5m
            el.append(srwlib.SRWLOptD(_L=v.op_M1_M2_L, ))
            pp.append(v.op_M1_M2_pp)
        elif el_name == 'M2':
            # M2: ellipsoidMirror 29.5m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_M2_p,
                    _q=v.op_M2_q,
                    _ang_graz=v.op_M2_ang,
                    _size_tang=v.op_M2_size_tang,
                    _size_sag=v.op_M2_size_sag,
                    _nvx=v.op_M2_nvx,
                    _nvy=v.op_M2_nvy,
                    _nvz=v.op_M2_nvz,
                    _tvx=v.op_M2_tvx,
                    _tvy=v.op_M2_tvy,
                    _x=v.op_M2_x,
                    _y=v.op_M2_y,
                ))
            pp.append(v.op_M2_pp)

        elif el_name == 'M2_Watchpoint':
            # M2_Watchpoint: drift 29.5m
            el.append(srwlib.SRWLOptD(_L=v.op_M2_Watchpoint_L, ))
            pp.append(v.op_M2_Watchpoint_pp)
        elif el_name == 'Watchpoint':
            # Watchpoint: watch 37.5m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Пример #4
0
def set_optics(v=None):
    el = []
    # CRL: crl 36.0m
    el.append(
        srwlib.srwl_opt_setup_CRL(2, 4.716943e-06, 0.006257, 1, 0.001, 0.001,
                                  0.0005, 3, 8e-05, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(34.1915))
    # Watchpoint: watch 70.1915m

    # Fiber: fiber 70.1915m
    el.append(
        srwlib.srwl_opt_setup_cyl_fiber(_foc_plane=2,
                                        _delta_ext=6.228746e-06,
                                        _delta_core=4.129923e-05,
                                        _atten_len_ext=0.002412,
                                        _atten_len_core=3.63751e-06,
                                        _diam_ext=0.0001,
                                        _diam_core=1e-05,
                                        _xc=0.0,
                                        _yc=0.0))
    el.append(srwlib.SRWLOptD(0.6585))
    # Watchpoint: watch 70.85m

    pp = []
    # CRL
    pp.append([
        0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    pp.append([
        0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    # Watchpoint
    # Fiber
    pp.append([
        0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    pp.append([
        0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    # Watchpoint
    # final post-propagation
    pp.append([
        0, 0, 1.0, 0, 0, 0.7, 2.0, 0.2, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0, 0.0
    ])
    return srwlib.SRWLOptC(el, pp)
Пример #5
0
def set_optics(v=None):
    el = []
    el.append(srwlib.SRWLOptD(1e-16))

    el.append(srwlib.SRWLOptD(6.866))

    ifnMirror1 = "mirror_1d.dat"
    if ifnMirror1:
        hProfDataMirror1 = srwlib.srwl_uti_read_data_cols(ifnMirror1, "\t", 0, 1)
        el.append(srwlib.srwl_opt_setup_surf_height_1d(hProfDataMirror1, _dim="x", _ang=0.0436332, _amp_coef=1.0, _size_x=0.001, _size_y=0.001))
    el.append(srwlib.SRWLOptD(20.634))
    el.append(srwlib.SRWLOptG(_mirSub=srwlib.SRWLOptMirPl(_size_tang=0.2, _size_sag=0.015, _nvx=0.0, _nvy=0.99991607766, _nvz=-0.0129552165771, _tvx=0.0, _tvy=0.0129552165771), _m=1.0, _grDen=1800.0, _grDen1=0.08997, _grDen2=3.004e-06, _grDen3=9.73e-11, _grDen4=0.0))
    el.append(srwlib.SRWLOptA("r", "a", 0.015, 0.00259104331543, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(34.63))
    el.append(srwlib.SRWLOptA("r", "a", 0.01832012956, 0.02, 0.0, 0.0))
    el.append(srwlib.SRWLOptMirEl(_p=89.63, _q=8.006, _ang_graz=0.0436332, _size_tang=0.42, _size_sag=0.02, _nvx=0.999048222947, _nvy=0.0, _nvz=-0.0436193560953, _tvx=-0.0436193560953, _tvy=0.0))
    el.append(srwlib.SRWLOptD(8.006))
    el.append(srwlib.SRWLOptA("r", "a", 0.0015, 0.0015, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(6.01))
    el.append(srwlib.SRWLOptA("r", "a", 0.0130858068286, 0.003, 0.0, 0.0))
    el.append(srwlib.SRWLOptMirEl(_p=6.01, _q=0.911, _ang_graz=0.0872665, _size_tang=0.3, _size_sag=0.05, _nvx=0.996194694832, _nvy=0.0, _nvz=-0.0871557800056, _tvx=-0.0871557800056, _tvy=0.0))
    el.append(srwlib.SRWLOptD(0.5))
    el.append(srwlib.SRWLOptMirEl(_p=6.51, _q=0.411, _ang_graz=0.0872665, _size_tang=0.3, _size_sag=0.05, _nvx=0.0, _nvy=0.996194694832, _nvz=-0.0871557800056, _tvx=0.0, _tvy=-0.0871557800056))
    el.append(srwlib.SRWLOptD(0.411))

    pp = []
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    if ifnMirror1:
        pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.2, 3.5, 1.2, 3.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 3.0, 1.0, 3.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 0.4, 1.0, 0.4, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 2.0, 1.0, 2.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 1, 0.07, 1.5, 0.07, 6.0])

    return srwlib.SRWLOptC(el, pp)
Пример #6
0
def set_optics(v=None):
    el = []
    pp = []
    names = ['Aperture', 'Aperture_Watchpoint', 'Watchpoint']
    for el_name in names:
        if el_name == 'Aperture':
            # Aperture: aperture 33.1798m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_Aperture_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_Aperture_Dx,
                    _Dy=v.op_Aperture_Dy,
                    _x=v.op_Aperture_x,
                    _y=v.op_Aperture_y,
                ))
            pp.append(v.op_Aperture_pp)
        elif el_name == 'Aperture_Watchpoint':
            # Aperture_Watchpoint: drift 33.1798m
            el.append(srwlib.SRWLOptD(_L=v.op_Aperture_Watchpoint_L, ))
            pp.append(v.op_Aperture_Watchpoint_pp)
        elif el_name == 'Watchpoint':
            # Watchpoint: watch 45.0m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Пример #7
0
def set_optics(v=None):
    el = []
    el.append(srwlib.SRWLOptD(0.6))
    opMask = setup_mask()
    el.append(opMask)
    el.append(srwlib.SRWLOptD(0.2))

    pp = []

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])  #drift

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])  #mask
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])  #drift

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])  #final

    return srwlib.SRWLOptC(el, pp)
Пример #8
0
def set_optics(v=None):
    el = []
    el.append(srwlib.SRWLOptA("r", "a", 0.001, 0.001, 0.0, 0.0))

    el.append(srwlib.SRWLOptD(0.02))

    el.append(srwlib.SRWLOptD(3.48))

    pp = []
    pp.append([0, 0, 1.0, 0, 0, 0.3, 5.0, 0.3, 5.0])

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 3, 0, 4.0, 1.0, 4.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 0.075, 1.0, 0.075, 1.0])
    return srwlib.SRWLOptC(el, pp)
Пример #9
0
def set_optics(v=None):
    el = []    
    el.append(srwlib.SRWLOptD(0.6))
    
    pp = []
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])#drift    
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])#final

    return srwlib.SRWLOptC(el, pp)
Пример #10
0
def set_optics(v=None):
    el = []
    el.append(
        srwlib.SRWLOptMirEl(_p=50.0,
                            _q=0.4,
                            _ang_graz=0.003,
                            _size_tang=0.2,
                            _size_sag=0.01,
                            _nvx=0.0,
                            _nvy=0.999995500003,
                            _nvz=-0.0029999955,
                            _tvx=0.0,
                            _tvy=-0.0029999955))
    el.append(srwlib.SRWLOptD(0.2))
    el.append(
        srwlib.SRWLOptMirEl(_p=50.0,
                            _q=0.2,
                            _ang_graz=0.003,
                            _size_tang=0.2,
                            _size_sag=0.01,
                            _nvx=0.999995500003,
                            _nvy=0.0,
                            _nvz=-0.0029999955,
                            _tvx=-0.0029999955,
                            _tvy=0.0))
    el.append(srwlib.SRWLOptD(0.4))
    opMask = setup_mask()
    el.append(opMask)
    el.append(srwlib.SRWLOptD(0.2))

    pp = []
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])  #mirror
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])  #drift

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])  #mirror
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])  #drift

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])  #mask
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])  #drift

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])  #final

    return srwlib.SRWLOptC(el, pp)
Пример #11
0
 def setup(self):
     super(BC11Section, self).setup()
     aperature = srwlib.SRWLOptA('c', 'a', self.detector_edge_length, 0, 0,
                                 0)
     aperature_params = [0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0]
     lens = srwlib.SRWLOptL(self.focal_length, self.focal_length)
     lens_params = [0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0]
     drift = srwlib.SRWLOptD(self.focal_length)
     drift_params = [0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0]
     self.__optics = srwlib.SRWLOptC(
         [aperature, lens, drift],
         [aperature_params, lens_params, drift_params])
Пример #12
0
def set_optics(v=None):
    el = []
    el.append(srwlib.SRWLOptA("r", "a", 0.0002, 0.001, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(6.9))
    ifnMirror1 = "mirror_1d.dat"
    if ifnMirror1:
        hProfDataMirror1 = srwlib.srwl_uti_read_data_cols(ifnMirror1, "\t", 0, 1)
        el.append(srwlib.srwl_opt_setup_surf_height_1d(hProfDataMirror1, _dim="x", _ang=0.0031415926, _amp_coef=1.0, _size_x=0.00094, _size_y=0.001))
    el.append(srwlib.SRWLOptD(2.5))
    el.append(srwlib.SRWLOptA("r", "a", 0.0002, 0.001, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(4.4))
    el.append(srwlib.SRWLOptA("r", "a", 5e-05, 0.001, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(1.1))
    el.append(srwlib.srwl_opt_setup_CRL(2, 4.20756805e-06, 0.00731294, 1, 0.001, 0.0024, 0.0015, 1, 8e-05, 0, 0))
    el.append(srwlib.srwl_opt_setup_CRL(2, 4.20756805e-06, 0.00731294, 1, 0.001, 0.0014, 0.0005, 6, 8e-05, 0, 0))
    el.append(srwlib.SRWLOptD(9.1))
    el.append(srwlib.SRWLOptA("r", "a", 0.0014, 0.0002, 0.0, 0.0))
    el.append(srwlib.SRWLOptL(3.24479, 1e+23, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(3.5))
    el.append(srwlib.SRWLOptA("r", "a", 1e-05, 1e-05, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(0.7))

    pp = []
    pp.append([0, 0, 1.0, 0, 0, 2.5, 5.0, 1.5, 2.5])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    if ifnMirror1:
        pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 0.3, 2.0, 0.5, 1.0])

    return srwlib.SRWLOptC(el, pp)
Пример #13
0
        def _createABCDbeamline(A, B, C, D):
            """
            #Use decomposition of ABCD matrix into kick-drift-kick Pei-Huang 2017 (https://arxiv.org/abs/1709.06222)
            #Construct corresponding SRW beamline container object
            #A,B,C,D are 2x2 matrix components.
            """

            f1 = B / (1 - A)
            L = B
            f2 = B / (1 - D)

            optLens1 = srwlib.SRWLOptL(f1, f1)
            optDrift = srwlib.SRWLOptD(L)
            optLens2 = srwlib.SRWLOptL(f2, f2)

            propagParLens1 = [0, 0, 1., 0, 0, 1, 1, 1, 1, 0, 0, 0]
            propagParDrift = [0, 0, 1., 0, 0, 1, 1, 1, 1, 0, 0, 0]
            propagParLens2 = [0, 0, 1., 0, 0, 1, 1, 1, 1, 0, 0, 0]

            return srwlib.SRWLOptC(
                [optLens1, optDrift, optLens2],
                [propagParLens1, propagParDrift, propagParLens2])
Пример #14
0
def set_optics(v=None):
    el = []
    # Aperture: aperture 33.1798m
    el.append(srwlib.SRWLOptA("r", "a", 0.00025, 0.00025, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(11.8202))
    # Watchpoint: watch 45.0m

    pp = []
    # Aperture
    pp.append([
        0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    pp.append([
        0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    # Watchpoint
    # final post-propagation
    pp.append([
        0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    return srwlib.SRWLOptC(el, pp)
Пример #15
0
 def __init__(self, length):
     self.length = length
     self._srwc = srwlib.SRWLOptC(
         [srwlib.SRWLOptD(length)],
         [[0, 0, 1., 0, 0, 1., 1., 1., 1., 0, 0, 0]],
     )
Пример #16
0
 def _createDriftBL(Lc):
     optDrift = srwlib.SRWLOptD(Lc)
     propagParDrift = [0, 0, 1., 0, 0, 1., 1., 1., 1., 0, 0, 0]
     #propagParDrift = [0, 0, 1., 0, 0, 1.1, 1.2, 1.1, 1.2, 0, 0, 0]
     return srwlib.SRWLOptC([optDrift], [propagParDrift])
Пример #17
0
    def __init__(self,
                 slice_index,
                 nslice,
                 sigrW=0.00043698412731784714,
                 propLen=15,
                 sig_s=0.1,
                 pulseE=0.001,
                 poltype=1,
                 phE=1.55,
                 sampFact=5,
                 mx=0,
                 my=0,
                 **_ignore_kwargs):
        """
        #nslice: number of slices of laser pulse
        #slice_index: index of slice
        #sigrW: beam size at waist [m]
        #propLen: propagation length [m] required by SRW to create numerical Gaussian
        #propLen=15,
        #sig_s RMS pulse length [m]
        #pulseE: energy per pulse [J]
        #poltype: polarization type (0=linear horizontal, 1=linear vertical, 2=linear 45 deg, 3=linear 135 deg, 4=circular right, 5=circular left, 6=total)
        #phE: photon energy [eV]
        #sampFact: sampling factor to increase mesh density
        """
        #print([sigrW,propLen,pulseE,poltype])
        self.slice_index = slice_index
        self.phE = phE
        constConvRad = 1.23984186e-06 / (
            4 * 3.1415926536)  ##conversion from energy to 1/wavelength
        rmsAngDiv = constConvRad / (phE * sigrW
                                    )  ##RMS angular divergence [rad]
        sigrL = math.sqrt(
            sigrW**2 + (propLen * rmsAngDiv)**2
        )  ##required RMS size to produce requested RMS beam size after propagation by propLen

        #***********Gaussian Beam Source
        GsnBm = srwlib.SRWLGsnBm()  #Gaussian Beam structure (just parameters)
        GsnBm.x = 0  #Transverse Positions of Gaussian Beam Center at Waist [m]
        GsnBm.y = 0
        numsig = 5.  #Number of sigma values to track. Total range is 2*numsig*sig_s
        ds = 2 * numsig * sig_s / (nslice - 1)
        self._pulse_pos = -numsig * sig_s + slice_index * ds
        GsnBm.z = propLen + self._pulse_pos  #Longitudinal Position of Waist [m]
        GsnBm.xp = 0  #Average Angles of Gaussian Beam at Waist [rad]
        GsnBm.yp = 0
        GsnBm.avgPhotEn = phE  #Photon Energy [eV]
        GsnBm.pulseEn = pulseE * np.exp(
            -self._pulse_pos**2 /
            (2 * sig_s**2))  #Energy per Pulse [J] - to be corrected
        GsnBm.repRate = 1  #Rep. Rate [Hz] - to be corrected
        GsnBm.polar = poltype  #1- linear horizontal?
        GsnBm.sigX = sigrW  #Horiz. RMS size at Waist [m]
        GsnBm.sigY = GsnBm.sigX  #Vert. RMS size at Waist [m]

        GsnBm.sigT = 10e-15  #Pulse duration [s] (not used?)
        GsnBm.mx = mx  #Transverse Gauss-Hermite Mode Orders
        GsnBm.my = my

        #***********Initial Wavefront
        wfr = srwlib.SRWLWfr()  #Initial Electric Field Wavefront
        wfr.allocate(
            1, 1000, 1000
        )  #Numbers of points vs Photon Energy (1), Horizontal and Vertical Positions (dummy)
        wfr.mesh.zStart = 0.0  #Longitudinal Position [m] at which initial Electric Field has to be calculated, i.e. the position of the first optical element
        wfr.mesh.eStart = GsnBm.avgPhotEn  #Initial Photon Energy [eV]
        wfr.mesh.eFin = GsnBm.avgPhotEn  #Final Photon Energy [eV]

        wfr.unitElFld = 1  #Electric field units: 0- arbitrary, 1- sqrt(Phot/s/0.1%bw/mm^2), 2- sqrt(J/eV/mm^2) or sqrt(W/mm^2), depending on representation (freq. or time)

        distSrc = wfr.mesh.zStart - GsnBm.z
        #Horizontal and Vertical Position Range for the Initial Wavefront calculation
        #can be used to simulate the First Aperture (of M1)
        #firstHorAp = 8.*rmsAngDiv*distSrc #[m]
        xAp = 8. * sigrL
        yAp = xAp  #[m]

        wfr.mesh.xStart = -0.5 * xAp  #Initial Horizontal Position [m]
        wfr.mesh.xFin = 0.5 * xAp  #Final Horizontal Position [m]
        wfr.mesh.yStart = -0.5 * yAp  #Initial Vertical Position [m]
        wfr.mesh.yFin = 0.5 * yAp  #Final Vertical Position [m]

        sampFactNxNyForProp = sampFact  #sampling factor for adjusting nx, ny (effective if > 0)
        arPrecPar = [sampFactNxNyForProp]

        srwlib.srwl.CalcElecFieldGaussian(wfr, GsnBm, arPrecPar)

        ##Beamline to propagate to waist

        optDriftW = srwlib.SRWLOptD(propLen)
        propagParDrift = [0, 0, 1., 0, 0, 1.1, 1.2, 1.1, 1.2, 0, 0, 0]
        optBLW = srwlib.SRWLOptC([optDriftW], [propagParDrift])
        #wfrW=deepcopy(wfr)
        srwlib.srwl.PropagElecField(wfr, optBLW)
        self._wfr = wfr
Пример #18
0
def set_optics(v=None):
    el = []
    pp = []
    for el_name in names:
        if el_name == 'Aperture':
            # Aperture: aperture 20.0m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_Aperture_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_Aperture_Dx,
                    _Dy=v.op_Aperture_Dy,
                    _x=v.op_Aperture_x,
                    _y=v.op_Aperture_y,
                ))
            pp.append(v.op_Aperture_pp)
        elif el_name == 'Aperture_HFM':
            # Aperture_HFM: drift 20.0m
            el.append(srwlib.SRWLOptD(_L=v.op_Aperture_HFM_L, ))
            pp.append(v.op_Aperture_HFM_pp)
        elif el_name == 'HFM':
            # HFM: sphericalMirror 42.0m
            el.append(
                srwlib.SRWLOptMirSph(
                    _r=v.op_HFM_r,
                    _size_tang=v.op_HFM_size_tang,
                    _size_sag=v.op_HFM_size_sag,
                    _nvx=v.op_HFM_nvx,
                    _nvy=v.op_HFM_nvy,
                    _nvz=v.op_HFM_nvz,
                    _tvx=v.op_HFM_tvx,
                    _tvy=v.op_HFM_tvy,
                    _x=v.op_HFM_x,
                    _y=v.op_HFM_y,
                ))
            pp.append(v.op_HFM_pp)

        elif el_name == 'Watchpoint':
            # Watchpoint: watch 42.0m
            pass
        elif el_name == 'Watchpoint_Watchpoint2':
            # Watchpoint_Watchpoint2: drift 42.0m
            el.append(srwlib.SRWLOptD(_L=v.op_Watchpoint_Watchpoint2_L, ))
            pp.append(v.op_Watchpoint_Watchpoint2_pp)
        elif el_name == 'Watchpoint2':
            # Watchpoint2: watch 55.0m
            pass
        elif el_name == 'SSA':
            # SSA: aperture 55.0m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_SSA_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_SSA_Dx,
                    _Dy=v.op_SSA_Dy,
                    _x=v.op_SSA_x,
                    _y=v.op_SSA_y,
                ))
            pp.append(v.op_SSA_pp)
        elif el_name == 'SSA_Watchpoint3':
            # SSA_Watchpoint3: drift 55.0m
            el.append(srwlib.SRWLOptD(_L=v.op_SSA_Watchpoint3_L, ))
            pp.append(v.op_SSA_Watchpoint3_pp)
        elif el_name == 'Watchpoint3':
            # Watchpoint3: watch 66.0m
            pass
        elif el_name == 'KB_Aperture':
            # KB_Aperture: aperture 66.0m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_KB_Aperture_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_KB_Aperture_Dx,
                    _Dy=v.op_KB_Aperture_Dy,
                    _x=v.op_KB_Aperture_x,
                    _y=v.op_KB_Aperture_y,
                ))
            pp.append(v.op_KB_Aperture_pp)
        elif el_name == 'KB_Aperture_KBh':
            # KB_Aperture_KBh: drift 66.0m
            el.append(srwlib.SRWLOptD(_L=v.op_KB_Aperture_KBh_L, ))
            pp.append(v.op_KB_Aperture_KBh_pp)
        elif el_name == 'KBh':
            # KBh: ellipsoidMirror 66.5m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_KBh_p,
                    _q=v.op_KBh_q,
                    _ang_graz=v.op_KBh_ang,
                    _size_tang=v.op_KBh_size_tang,
                    _size_sag=v.op_KBh_size_sag,
                    _nvx=v.op_KBh_nvx,
                    _nvy=v.op_KBh_nvy,
                    _nvz=v.op_KBh_nvz,
                    _tvx=v.op_KBh_tvx,
                    _tvy=v.op_KBh_tvy,
                    _x=v.op_KBh_x,
                    _y=v.op_KBh_y,
                ))
            pp.append(v.op_KBh_pp)

        elif el_name == 'KBh_Sample':
            # KBh_Sample: drift 66.5m
            el.append(srwlib.SRWLOptD(_L=v.op_KBh_Sample_L, ))
            pp.append(v.op_KBh_Sample_pp)
        elif el_name == 'Sample':
            # Sample: watch 67.0m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Пример #19
0
def set_optics(v=None):
    el = []
    pp = []
    names = [
        'M1', 'M1_Grating', 'Grating', 'GA', 'GA_M3A', 'M3A', 'M3', 'M3_SSA',
        'SSA', 'SSA_KBAperture', 'KBAperture', 'KBh', 'KBh_KBv', 'KBv',
        'KBv_Sample', 'Sample'
    ]
    for el_name in names:
        if el_name == 'M1':
            # M1: mirror 34.366m
            mirror_file = v.op_M1_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by M1 beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_M1_dim,
                    _ang=abs(v.op_M1_ang),
                    _amp_coef=v.op_M1_amp_coef,
                    _size_x=v.op_M1_size_x,
                    _size_y=v.op_M1_size_y,
                ))
            pp.append(v.op_M1_pp)
        elif el_name == 'M1_Grating':
            # M1_Grating: drift 34.366m
            el.append(srwlib.SRWLOptD(_L=v.op_M1_Grating_L, ))
            pp.append(v.op_M1_Grating_pp)
        elif el_name == 'Grating':
            # Grating: grating 55.0m
            mirror = srwlib.SRWLOptMirPl(
                _size_tang=v.op_Grating_size_tang,
                _size_sag=v.op_Grating_size_sag,
                _nvx=v.op_Grating_nvx,
                _nvy=v.op_Grating_nvy,
                _nvz=v.op_Grating_nvz,
                _tvx=v.op_Grating_tvx,
                _tvy=v.op_Grating_tvy,
                _x=v.op_Grating_x,
                _y=v.op_Grating_y,
            )
            el.append(
                srwlib.SRWLOptG(
                    _mirSub=mirror,
                    _m=v.op_Grating_m,
                    _grDen=v.op_Grating_grDen,
                    _grDen1=v.op_Grating_grDen1,
                    _grDen2=v.op_Grating_grDen2,
                    _grDen3=v.op_Grating_grDen3,
                    _grDen4=v.op_Grating_grDen4,
                ))
            pp.append(v.op_Grating_pp)
        elif el_name == 'GA':
            # GA: aperture 55.0m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_GA_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_GA_Dx,
                    _Dy=v.op_GA_Dy,
                    _x=v.op_GA_x,
                    _y=v.op_GA_y,
                ))
            pp.append(v.op_GA_pp)
        elif el_name == 'GA_M3A':
            # GA_M3A: drift 55.0m
            el.append(srwlib.SRWLOptD(_L=v.op_GA_M3A_L, ))
            pp.append(v.op_GA_M3A_pp)
        elif el_name == 'M3A':
            # M3A: aperture 89.63m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_M3A_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_M3A_Dx,
                    _Dy=v.op_M3A_Dy,
                    _x=v.op_M3A_x,
                    _y=v.op_M3A_y,
                ))
            pp.append(v.op_M3A_pp)
        elif el_name == 'M3':
            # M3: ellipsoidMirror 89.63m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_M3_p,
                    _q=v.op_M3_q,
                    _ang_graz=v.op_M3_ang,
                    _size_tang=v.op_M3_size_tang,
                    _size_sag=v.op_M3_size_sag,
                    _nvx=v.op_M3_nvx,
                    _nvy=v.op_M3_nvy,
                    _nvz=v.op_M3_nvz,
                    _tvx=v.op_M3_tvx,
                    _tvy=v.op_M3_tvy,
                    _x=v.op_M3_x,
                    _y=v.op_M3_y,
                ))
            pp.append(v.op_M3_pp)

        elif el_name == 'M3_SSA':
            # M3_SSA: drift 89.63m
            el.append(srwlib.SRWLOptD(_L=v.op_M3_SSA_L, ))
            pp.append(v.op_M3_SSA_pp)
        elif el_name == 'SSA':
            # SSA: aperture 97.636m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_SSA_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_SSA_Dx,
                    _Dy=v.op_SSA_Dy,
                    _x=v.op_SSA_x,
                    _y=v.op_SSA_y,
                ))
            pp.append(v.op_SSA_pp)
        elif el_name == 'SSA_KBAperture':
            # SSA_KBAperture: drift 97.636m
            el.append(srwlib.SRWLOptD(_L=v.op_SSA_KBAperture_L, ))
            pp.append(v.op_SSA_KBAperture_pp)
        elif el_name == 'KBAperture':
            # KBAperture: aperture 103.646m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_KBAperture_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_KBAperture_Dx,
                    _Dy=v.op_KBAperture_Dy,
                    _x=v.op_KBAperture_x,
                    _y=v.op_KBAperture_y,
                ))
            pp.append(v.op_KBAperture_pp)
        elif el_name == 'KBh':
            # KBh: ellipsoidMirror 103.646m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_KBh_p,
                    _q=v.op_KBh_q,
                    _ang_graz=v.op_KBh_ang,
                    _size_tang=v.op_KBh_size_tang,
                    _size_sag=v.op_KBh_size_sag,
                    _nvx=v.op_KBh_nvx,
                    _nvy=v.op_KBh_nvy,
                    _nvz=v.op_KBh_nvz,
                    _tvx=v.op_KBh_tvx,
                    _tvy=v.op_KBh_tvy,
                    _x=v.op_KBh_x,
                    _y=v.op_KBh_y,
                ))
            pp.append(v.op_KBh_pp)

        elif el_name == 'KBh_KBv':
            # KBh_KBv: drift 103.646m
            el.append(srwlib.SRWLOptD(_L=v.op_KBh_KBv_L, ))
            pp.append(v.op_KBh_KBv_pp)
        elif el_name == 'KBv':
            # KBv: ellipsoidMirror 104.146m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_KBv_p,
                    _q=v.op_KBv_q,
                    _ang_graz=v.op_KBv_ang,
                    _size_tang=v.op_KBv_size_tang,
                    _size_sag=v.op_KBv_size_sag,
                    _nvx=v.op_KBv_nvx,
                    _nvy=v.op_KBv_nvy,
                    _nvz=v.op_KBv_nvz,
                    _tvx=v.op_KBv_tvx,
                    _tvy=v.op_KBv_tvy,
                    _x=v.op_KBv_x,
                    _y=v.op_KBv_y,
                ))
            pp.append(v.op_KBv_pp)

        elif el_name == 'KBv_Sample':
            # KBv_Sample: drift 104.146m
            el.append(srwlib.SRWLOptD(_L=v.op_KBv_Sample_L, ))
            pp.append(v.op_KBv_Sample_pp)
        elif el_name == 'Sample':
            # Sample: watch 104.557m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Пример #20
0
def set_optics(v=None):
    el = []
    pp = []
    names = [
        'MOAT_1', 'MOAT_1_MOAT_2', 'MOAT_2', 'MOAT_2_HFM', 'HFM', 'HFM_VFM',
        'VFM', 'VFM_VDM', 'VDM', 'VDM_SSA', 'SSA', 'SSA_ES1', 'ES1', 'ES1_CRL',
        'CRL', 'CRL_ES2', 'ES2'
    ]
    for el_name in names:
        if el_name == 'MOAT_1':
            # MOAT_1: crystal 31.94m
            crystal = srwlib.SRWLOptCryst(
                _d_sp=v.op_MOAT_1_d_sp,
                _psi0r=v.op_MOAT_1_psi0r,
                _psi0i=v.op_MOAT_1_psi0i,
                _psi_hr=v.op_MOAT_1_psiHr,
                _psi_hi=v.op_MOAT_1_psiHi,
                _psi_hbr=v.op_MOAT_1_psiHBr,
                _psi_hbi=v.op_MOAT_1_psiHBi,
                _tc=v.op_MOAT_1_tc,
                _ang_as=v.op_MOAT_1_ang_as,
            )
            crystal.set_orient(
                _nvx=v.op_MOAT_1_nvx,
                _nvy=v.op_MOAT_1_nvy,
                _nvz=v.op_MOAT_1_nvz,
                _tvx=v.op_MOAT_1_tvx,
                _tvy=v.op_MOAT_1_tvy,
            )
            el.append(crystal)
            pp.append(v.op_MOAT_1_pp)
            mirror_file = v.op_MOAT_1_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by MOAT_1 beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_MOAT_1_dim,
                    _ang=abs(v.op_MOAT_1_ang),
                    _amp_coef=v.op_MOAT_1_amp_coef,
                ))
            pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
        elif el_name == 'MOAT_1_MOAT_2':
            # MOAT_1_MOAT_2: drift 31.94m
            el.append(srwlib.SRWLOptD(_L=v.op_MOAT_1_MOAT_2_L, ))
            pp.append(v.op_MOAT_1_MOAT_2_pp)
        elif el_name == 'MOAT_2':
            # MOAT_2: crystal 31.99m
            crystal = srwlib.SRWLOptCryst(
                _d_sp=v.op_MOAT_2_d_sp,
                _psi0r=v.op_MOAT_2_psi0r,
                _psi0i=v.op_MOAT_2_psi0i,
                _psi_hr=v.op_MOAT_2_psiHr,
                _psi_hi=v.op_MOAT_2_psiHi,
                _psi_hbr=v.op_MOAT_2_psiHBr,
                _psi_hbi=v.op_MOAT_2_psiHBi,
                _tc=v.op_MOAT_2_tc,
                _ang_as=v.op_MOAT_2_ang_as,
            )
            crystal.set_orient(
                _nvx=v.op_MOAT_2_nvx,
                _nvy=v.op_MOAT_2_nvy,
                _nvz=v.op_MOAT_2_nvz,
                _tvx=v.op_MOAT_2_tvx,
                _tvy=v.op_MOAT_2_tvy,
            )
            el.append(crystal)
            pp.append(v.op_MOAT_2_pp)

        elif el_name == 'MOAT_2_HFM':
            # MOAT_2_HFM: drift 31.99m
            el.append(srwlib.SRWLOptD(_L=v.op_MOAT_2_HFM_L, ))
            pp.append(v.op_MOAT_2_HFM_pp)
        elif el_name == 'HFM':
            # HFM: sphericalMirror 34.88244m
            el.append(
                srwlib.SRWLOptMirSph(
                    _r=v.op_HFM_r,
                    _size_tang=v.op_HFM_size_tang,
                    _size_sag=v.op_HFM_size_sag,
                    _nvx=v.op_HFM_nvx,
                    _nvy=v.op_HFM_nvy,
                    _nvz=v.op_HFM_nvz,
                    _tvx=v.op_HFM_tvx,
                    _tvy=v.op_HFM_tvy,
                    _x=v.op_HFM_x,
                    _y=v.op_HFM_y,
                ))
            pp.append(v.op_HFM_pp)
            mirror_file = v.op_HFM_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by HFM beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_HFM_dim,
                    _ang=abs(v.op_HFM_ang),
                    _amp_coef=v.op_HFM_amp_coef,
                ))
            pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
        elif el_name == 'HFM_VFM':
            # HFM_VFM: drift 34.88244m
            el.append(srwlib.SRWLOptD(_L=v.op_HFM_VFM_L, ))
            pp.append(v.op_HFM_VFM_pp)
        elif el_name == 'VFM':
            # VFM: sphericalMirror 38.30244m
            el.append(
                srwlib.SRWLOptMirSph(
                    _r=v.op_VFM_r,
                    _size_tang=v.op_VFM_size_tang,
                    _size_sag=v.op_VFM_size_sag,
                    _nvx=v.op_VFM_nvx,
                    _nvy=v.op_VFM_nvy,
                    _nvz=v.op_VFM_nvz,
                    _tvx=v.op_VFM_tvx,
                    _tvy=v.op_VFM_tvy,
                    _x=v.op_VFM_x,
                    _y=v.op_VFM_y,
                ))
            pp.append(v.op_VFM_pp)
            mirror_file = v.op_VFM_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by VFM beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_VFM_dim,
                    _ang=abs(v.op_VFM_ang),
                    _amp_coef=v.op_VFM_amp_coef,
                ))
            pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
        elif el_name == 'VFM_VDM':
            # VFM_VDM: drift 38.30244m
            el.append(srwlib.SRWLOptD(_L=v.op_VFM_VDM_L, ))
            pp.append(v.op_VFM_VDM_pp)
        elif el_name == 'VDM':
            # VDM: sphericalMirror 39.0m
            el.append(
                srwlib.SRWLOptMirSph(
                    _r=v.op_VDM_r,
                    _size_tang=v.op_VDM_size_tang,
                    _size_sag=v.op_VDM_size_sag,
                    _nvx=v.op_VDM_nvx,
                    _nvy=v.op_VDM_nvy,
                    _nvz=v.op_VDM_nvz,
                    _tvx=v.op_VDM_tvx,
                    _tvy=v.op_VDM_tvy,
                    _x=v.op_VDM_x,
                    _y=v.op_VDM_y,
                ))
            pp.append(v.op_VDM_pp)
            mirror_file = v.op_VDM_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by VDM beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_VDM_dim,
                    _ang=abs(v.op_VDM_ang),
                    _amp_coef=v.op_VDM_amp_coef,
                ))
            pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
        elif el_name == 'VDM_SSA':
            # VDM_SSA: drift 39.0m
            el.append(srwlib.SRWLOptD(_L=v.op_VDM_SSA_L, ))
            pp.append(v.op_VDM_SSA_pp)
        elif el_name == 'SSA':
            # SSA: aperture 47.00244m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_SSA_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_SSA_Dx,
                    _Dy=v.op_SSA_Dy,
                    _x=v.op_SSA_x,
                    _y=v.op_SSA_y,
                ))
            pp.append(v.op_SSA_pp)
        elif el_name == 'SSA_ES1':
            # SSA_ES1: drift 47.00244m
            el.append(srwlib.SRWLOptD(_L=v.op_SSA_ES1_L, ))
            pp.append(v.op_SSA_ES1_pp)
        elif el_name == 'ES1':
            # ES1: watch 50.9m
            pass
        elif el_name == 'ES1_CRL':
            # ES1_CRL: drift 50.9m
            el.append(srwlib.SRWLOptD(_L=v.op_ES1_CRL_L, ))
            pp.append(v.op_ES1_CRL_pp)
        elif el_name == 'CRL':
            # CRL: crl 57.335m
            el.append(
                srwlib.srwl_opt_setup_CRL(
                    _foc_plane=v.op_CRL_foc_plane,
                    _delta=v.op_CRL_delta,
                    _atten_len=v.op_CRL_atten_len,
                    _shape=v.op_CRL_shape,
                    _apert_h=v.op_CRL_apert_h,
                    _apert_v=v.op_CRL_apert_v,
                    _r_min=v.op_CRL_r_min,
                    _n=v.op_CRL_n,
                    _wall_thick=v.op_CRL_wall_thick,
                    _xc=v.op_CRL_x,
                    _yc=v.op_CRL_y,
                ))
            pp.append(v.op_CRL_pp)
        elif el_name == 'CRL_ES2':
            # CRL_ES2: drift 57.335m
            el.append(srwlib.SRWLOptD(_L=v.op_CRL_ES2_L, ))
            pp.append(v.op_CRL_ES2_pp)
        elif el_name == 'ES2':
            # ES2: watch 59.0m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Пример #21
0
def set_optics(v=None):
    el = []
    pp = []
    for el_name in names:
        if el_name == 'S1':
            # S1: aperture 26.62m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_S1_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_S1_Dx,
                    _Dy=v.op_S1_Dy,
                    _x=v.op_S1_x,
                    _y=v.op_S1_y,
                ))
            pp.append(v.op_S1_pp)
        elif el_name == 'S1_HCM':
            # S1_HCM: drift 26.62m
            el.append(srwlib.SRWLOptD(_L=v.op_S1_HCM_L, ))
            pp.append(v.op_S1_HCM_pp)
        elif el_name == 'HCM':
            # HCM: sphericalMirror 28.35m
            el.append(
                srwlib.SRWLOptMirSph(
                    _r=v.op_HCM_r,
                    _size_tang=v.op_HCM_size_tang,
                    _size_sag=v.op_HCM_size_sag,
                    _nvx=v.op_HCM_nvx,
                    _nvy=v.op_HCM_nvy,
                    _nvz=v.op_HCM_nvz,
                    _tvx=v.op_HCM_tvx,
                    _tvy=v.op_HCM_tvy,
                    _x=v.op_HCM_x,
                    _y=v.op_HCM_y,
                ))
            pp.append(v.op_HCM_pp)

        elif el_name == 'HCM_DCM_C1':
            # HCM_DCM_C1: drift 28.35m
            el.append(srwlib.SRWLOptD(_L=v.op_HCM_DCM_C1_L, ))
            pp.append(v.op_HCM_DCM_C1_pp)
        elif el_name == 'DCM_C1':
            # DCM_C1: crystal 30.42m
            crystal = srwlib.SRWLOptCryst(
                _d_sp=v.op_DCM_C1_d_sp,
                _psi0r=v.op_DCM_C1_psi0r,
                _psi0i=v.op_DCM_C1_psi0i,
                _psi_hr=v.op_DCM_C1_psiHr,
                _psi_hi=v.op_DCM_C1_psiHi,
                _psi_hbr=v.op_DCM_C1_psiHBr,
                _psi_hbi=v.op_DCM_C1_psiHBi,
                _tc=v.op_DCM_C1_tc,
                _ang_as=v.op_DCM_C1_ang_as,
            )
            crystal.set_orient(
                _nvx=v.op_DCM_C1_nvx,
                _nvy=v.op_DCM_C1_nvy,
                _nvz=v.op_DCM_C1_nvz,
                _tvx=v.op_DCM_C1_tvx,
                _tvy=v.op_DCM_C1_tvy,
            )
            el.append(crystal)
            pp.append(v.op_DCM_C1_pp)

        elif el_name == 'DCM_C2':
            # DCM_C2: crystal 30.42m
            crystal = srwlib.SRWLOptCryst(
                _d_sp=v.op_DCM_C2_d_sp,
                _psi0r=v.op_DCM_C2_psi0r,
                _psi0i=v.op_DCM_C2_psi0i,
                _psi_hr=v.op_DCM_C2_psiHr,
                _psi_hi=v.op_DCM_C2_psiHi,
                _psi_hbr=v.op_DCM_C2_psiHBr,
                _psi_hbi=v.op_DCM_C2_psiHBi,
                _tc=v.op_DCM_C2_tc,
                _ang_as=v.op_DCM_C2_ang_as,
            )
            crystal.set_orient(
                _nvx=v.op_DCM_C2_nvx,
                _nvy=v.op_DCM_C2_nvy,
                _nvz=v.op_DCM_C2_nvz,
                _tvx=v.op_DCM_C2_tvx,
                _tvy=v.op_DCM_C2_tvy,
            )
            el.append(crystal)
            pp.append(v.op_DCM_C2_pp)

        elif el_name == 'DCM_C2_HFM':
            # DCM_C2_HFM: drift 30.42m
            el.append(srwlib.SRWLOptD(_L=v.op_DCM_C2_HFM_L, ))
            pp.append(v.op_DCM_C2_HFM_pp)
        elif el_name == 'HFM':
            # HFM: sphericalMirror 32.64m
            el.append(
                srwlib.SRWLOptMirSph(
                    _r=v.op_HFM_r,
                    _size_tang=v.op_HFM_size_tang,
                    _size_sag=v.op_HFM_size_sag,
                    _nvx=v.op_HFM_nvx,
                    _nvy=v.op_HFM_nvy,
                    _nvz=v.op_HFM_nvz,
                    _tvx=v.op_HFM_tvx,
                    _tvy=v.op_HFM_tvy,
                    _x=v.op_HFM_x,
                    _y=v.op_HFM_y,
                ))
            pp.append(v.op_HFM_pp)

        elif el_name == 'After_HFM':
            # After_HFM: watch 32.64m
            pass
        elif el_name == 'After_HFM_CRL1':
            # After_HFM_CRL1: drift 32.64m
            el.append(srwlib.SRWLOptD(_L=v.op_After_HFM_CRL1_L, ))
            pp.append(v.op_After_HFM_CRL1_pp)
        elif el_name == 'CRL1':
            # CRL1: crl 34.15m
            el.append(
                srwlib.srwl_opt_setup_CRL(
                    _foc_plane=v.op_CRL1_foc_plane,
                    _delta=v.op_CRL1_delta,
                    _atten_len=v.op_CRL1_atten_len,
                    _shape=v.op_CRL1_shape,
                    _apert_h=v.op_CRL1_apert_h,
                    _apert_v=v.op_CRL1_apert_v,
                    _r_min=v.op_CRL1_r_min,
                    _n=v.op_CRL1_n,
                    _wall_thick=v.op_CRL1_wall_thick,
                    _xc=v.op_CRL1_x,
                    _yc=v.op_CRL1_y,
                ))
            pp.append(v.op_CRL1_pp)
        elif el_name == 'CRL2':
            # CRL2: crl 34.15m
            el.append(
                srwlib.srwl_opt_setup_CRL(
                    _foc_plane=v.op_CRL2_foc_plane,
                    _delta=v.op_CRL2_delta,
                    _atten_len=v.op_CRL2_atten_len,
                    _shape=v.op_CRL2_shape,
                    _apert_h=v.op_CRL2_apert_h,
                    _apert_v=v.op_CRL2_apert_v,
                    _r_min=v.op_CRL2_r_min,
                    _n=v.op_CRL2_n,
                    _wall_thick=v.op_CRL2_wall_thick,
                    _xc=v.op_CRL2_x,
                    _yc=v.op_CRL2_y,
                ))
            pp.append(v.op_CRL2_pp)
        elif el_name == 'CRL2_Before_SSA':
            # CRL2_Before_SSA: drift 34.15m
            el.append(srwlib.SRWLOptD(_L=v.op_CRL2_Before_SSA_L, ))
            pp.append(v.op_CRL2_Before_SSA_pp)
        elif el_name == 'Before_SSA':
            # Before_SSA: watch 94.5m
            pass
        elif el_name == 'SSA':
            # SSA: aperture 94.5m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_SSA_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_SSA_Dx,
                    _Dy=v.op_SSA_Dy,
                    _x=v.op_SSA_x,
                    _y=v.op_SSA_y,
                ))
            pp.append(v.op_SSA_pp)
        elif el_name == 'SSA_Before_FFO':
            # SSA_Before_FFO: drift 94.5m
            el.append(srwlib.SRWLOptD(_L=v.op_SSA_Before_FFO_L, ))
            pp.append(v.op_SSA_Before_FFO_pp)
        elif el_name == 'Before_FFO':
            # Before_FFO: watch 109.0m
            pass
        elif el_name == 'AFFO':
            # AFFO: aperture 109.0m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_AFFO_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_AFFO_Dx,
                    _Dy=v.op_AFFO_Dy,
                    _x=v.op_AFFO_x,
                    _y=v.op_AFFO_y,
                ))
            pp.append(v.op_AFFO_pp)
        elif el_name == 'FFO':
            # FFO: lens 109.0m
            el.append(
                srwlib.SRWLOptL(
                    _Fx=v.op_FFO_Fx,
                    _Fy=v.op_FFO_Fy,
                    _x=v.op_FFO_x,
                    _y=v.op_FFO_y,
                ))
            pp.append(v.op_FFO_pp)
        elif el_name == 'FFO_At_Sample':
            # FFO_At_Sample: drift 109.0m
            el.append(srwlib.SRWLOptD(_L=v.op_FFO_At_Sample_L, ))
            pp.append(v.op_FFO_At_Sample_pp)
        elif el_name == 'At_Sample':
            # At_Sample: watch 109.018163m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Пример #22
0
def propagator2d_srw(p_x,p_y,amplitude,propagation_distance=1.0,wavelength=1e-10):
    #
    # convolving with the Fresnel kernel via SRW package
    #
    import srwlib
    from NumpyToSRW import numpyArrayToSRWArray, SRWWavefrontFromElectricField, SRWEFieldAsNumpy

    # srw_amplituder = numpyArrayToSRWArray(amplitude)
    # print(type(srw_amplituder))



    srw_wfr = SRWWavefrontFromElectricField(p_x[0], p_x[-1], amplitude,
                                  p_y[0], p_y[-1], np.zeros_like(amplitude),
                                  12396.0/(wavelength*1e10), 1.0, 1.0, 1e-3, 1.0, 1e-3)

    print(type(srw_wfr))


    #
    # propagation
    #
    optDrift = srwlib.SRWLOptD(propagation_distance) #Drift space

    #                 0  1  2   3  4  5   6   7   8   9 10 11
    # propagParDrift = [1, 1, 1., 0, 0, 1., 1., 1., 1., 0, 0, 0]
    propagParDrift = [0, 0, 1., 0, 0, 1., 1., 1., 1., 0, 0, 0]
    #Wavefront Propagation Parameters:
    #[0]: Auto-Resize (1) or not (0) Before propagation
    #[1]: Auto-Resize (1) or not (0) After propagation
    #[2]: Relative Precision for propagation with Auto-Resizing (1. is nominal)
    #[3]: Allow (1) or not (0) for semi-analytical treatment of the quadratic (leading) phase terms at the propagation
    #[4]: Do any Resizing on Fourier side, using FFT, (1) or not (0)
    #[5]: Horizontal Range modification factor at Resizing (1. means no modification)
    #[6]: Horizontal Resolution modification factor at Resizing
    #[7]: Vertical Range modification factor at Resizing
    #[8]: Vertical Resolution modification factor at Resizing
    #[9]: Type of wavefront Shift before Resizing (not yet implemented)
    #[10]: New Horizontal wavefront Center position after Shift (not yet implemented)
    #[11]: New Vertical wavefront Center position after Shift (not yet implemented)
    optBL = srwlib.SRWLOptC([optDrift], [propagParDrift]) #"Beamline" - Container of Optical Elements (together with the corresponding wavefront propagation instructions)

    print('   Simulating Electric Field Wavefront Propagation bu SRW ... ', end='\n')
    srwlib.srwl.PropagElecField(srw_wfr, optBL)


    amplitude2 = SRWEFieldAsNumpy(srw_wfr)
    amplitude2 = amplitude2[0,:,:,0]
    print("Amplitude shape before:",amplitude.shape,"; after: ",amplitude2.shape)



    # fft = np.fft.fft2(amplitude)
    #
    # # frequency for axis 1
    # pixelsize = p_x[1] - p_x[0]
    # npixels = p_x.size
    # freq_nyquist = 0.5/pixelsize
    # freq_n = np.linspace(-1.0,1.0,npixels)
    # freq_x = freq_n * freq_nyquist
    # # freq = freq * wavelength
    #
    # # frequency for axis 2
    # pixelsize = p_y[1] - p_y[0]
    # npixels = p_y.size
    # freq_nyquist = 0.5/pixelsize
    # freq_n = np.linspace(-1.0,1.0,npixels)
    # freq_y = freq_n * freq_nyquist
    # # freq_y = freq_y * wavelength
    #
    # freq_xy = np.array(np.meshgrid(freq_y,freq_x))
    #
    # fft *= np.exp((-1.0j) * np.pi * wavelength * propagation_distance *
    #               np.fft.fftshift(freq_xy[0]*freq_xy[0] + freq_xy[1]*freq_xy[1]) )
    # ifft = np.fft.ifft2(fft)

    p_x2 = np.linspace(srw_wfr.mesh.xStart, srw_wfr.mesh.xFin, srw_wfr.mesh.nx)
    p_y2 = np.linspace(srw_wfr.mesh.yStart, srw_wfr.mesh.yFin, srw_wfr.mesh.ny)

    return p_x2,p_y2,amplitude2
Пример #23
0
def set_optics(v=None):
    el = []
    pp = []
    names = ['S0', 'S0_HDM', 'HDM', 'HDM_S1', 'S1', 'S1_S2', 'S2', 'S2_CRL1', 'CRL1', 'CRL2', 'CRL2_KLA', 'KLA', 'KL', 'KL_S3', 'S3', 'S3_Sample', 'Sample']
    for el_name in names:
        if el_name == 'S0':
            # S0: aperture 20.5m
            el.append(srwlib.SRWLOptA(
                _shape=v.op_S0_shape,
                _ap_or_ob='a',
                _Dx=v.op_S0_Dx,
                _Dy=v.op_S0_Dy,
                _x=v.op_S0_x,
                _y=v.op_S0_y,
            ))
            pp.append(v.op_S0_pp)
        elif el_name == 'S0_HDM':
            # S0_HDM: drift 20.5m
            el.append(srwlib.SRWLOptD(
                _L=v.op_S0_HDM_L,
            ))
            pp.append(v.op_S0_HDM_pp)
        elif el_name == 'HDM':
            # HDM: mirror 27.4m
            mirror_file = v.op_HDM_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by HDM beamline element'.format(mirror_file)
            el.append(srwlib.srwl_opt_setup_surf_height_1d(
                srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                _dim=v.op_HDM_dim,
                _ang=v.op_HDM_ang,
                _amp_coef=v.op_HDM_amp_coef,
                _size_x=v.op_HDM_size_x,
                _size_y=v.op_HDM_size_y,
            ))
            pp.append(v.op_HDM_pp)
        elif el_name == 'HDM_S1':
            # HDM_S1: drift 27.4m
            el.append(srwlib.SRWLOptD(
                _L=v.op_HDM_S1_L,
            ))
            pp.append(v.op_HDM_S1_pp)
        elif el_name == 'S1':
            # S1: aperture 29.9m
            el.append(srwlib.SRWLOptA(
                _shape=v.op_S1_shape,
                _ap_or_ob='a',
                _Dx=v.op_S1_Dx,
                _Dy=v.op_S1_Dy,
                _x=v.op_S1_x,
                _y=v.op_S1_y,
            ))
            pp.append(v.op_S1_pp)
        elif el_name == 'S1_S2':
            # S1_S2: drift 29.9m
            el.append(srwlib.SRWLOptD(
                _L=v.op_S1_S2_L,
            ))
            pp.append(v.op_S1_S2_pp)
        elif el_name == 'S2':
            # S2: aperture 34.3m
            el.append(srwlib.SRWLOptA(
                _shape=v.op_S2_shape,
                _ap_or_ob='a',
                _Dx=v.op_S2_Dx,
                _Dy=v.op_S2_Dy,
                _x=v.op_S2_x,
                _y=v.op_S2_y,
            ))
            pp.append(v.op_S2_pp)
        elif el_name == 'S2_CRL1':
            # S2_CRL1: drift 34.3m
            el.append(srwlib.SRWLOptD(
                _L=v.op_S2_CRL1_L,
            ))
            pp.append(v.op_S2_CRL1_pp)
        elif el_name == 'CRL1':
            # CRL1: crl 35.4m
            el.append(srwlib.srwl_opt_setup_CRL(
                _foc_plane=v.op_CRL1_foc_plane,
                _delta=v.op_CRL1_delta,
                _atten_len=v.op_CRL1_atten_len,
                _shape=v.op_CRL1_shape,
                _apert_h=v.op_CRL1_apert_h,
                _apert_v=v.op_CRL1_apert_v,
                _r_min=v.op_CRL1_r_min,
                _n=v.op_CRL1_n,
                _wall_thick=v.op_CRL1_wall_thick,
                _xc=v.op_CRL1_x,
                _yc=v.op_CRL1_y,
            ))
            pp.append(v.op_CRL1_pp)
        elif el_name == 'CRL2':
            # CRL2: crl 35.4m
            el.append(srwlib.srwl_opt_setup_CRL(
                _foc_plane=v.op_CRL2_foc_plane,
                _delta=v.op_CRL2_delta,
                _atten_len=v.op_CRL2_atten_len,
                _shape=v.op_CRL2_shape,
                _apert_h=v.op_CRL2_apert_h,
                _apert_v=v.op_CRL2_apert_v,
                _r_min=v.op_CRL2_r_min,
                _n=v.op_CRL2_n,
                _wall_thick=v.op_CRL2_wall_thick,
                _xc=v.op_CRL2_x,
                _yc=v.op_CRL2_y,
            ))
            pp.append(v.op_CRL2_pp)
        elif el_name == 'CRL2_KLA':
            # CRL2_KLA: drift 35.4m
            el.append(srwlib.SRWLOptD(
                _L=v.op_CRL2_KLA_L,
            ))
            pp.append(v.op_CRL2_KLA_pp)
        elif el_name == 'KLA':
            # KLA: aperture 44.5m
            el.append(srwlib.SRWLOptA(
                _shape=v.op_KLA_shape,
                _ap_or_ob='a',
                _Dx=v.op_KLA_Dx,
                _Dy=v.op_KLA_Dy,
                _x=v.op_KLA_x,
                _y=v.op_KLA_y,
            ))
            pp.append(v.op_KLA_pp)
        elif el_name == 'KL':
            # KL: lens 44.5m
            el.append(srwlib.SRWLOptL(
                _Fx=v.op_KL_Fx,
                _Fy=v.op_KL_Fy,
                _x=v.op_KL_x,
                _y=v.op_KL_y,
            ))
            pp.append(v.op_KL_pp)
        elif el_name == 'KL_S3':
            # KL_S3: drift 44.5m
            el.append(srwlib.SRWLOptD(
                _L=v.op_KL_S3_L,
            ))
            pp.append(v.op_KL_S3_pp)
        elif el_name == 'S3':
            # S3: aperture 48.0m
            el.append(srwlib.SRWLOptA(
                _shape=v.op_S3_shape,
                _ap_or_ob='a',
                _Dx=v.op_S3_Dx,
                _Dy=v.op_S3_Dy,
                _x=v.op_S3_x,
                _y=v.op_S3_y,
            ))
            pp.append(v.op_S3_pp)
        elif el_name == 'S3_Sample':
            # S3_Sample: drift 48.0m
            el.append(srwlib.SRWLOptD(
                _L=v.op_S3_Sample_L,
            ))
            pp.append(v.op_S3_Sample_pp)
        elif el_name == 'Sample':
            # Sample: watch 48.7m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Пример #24
0
def set_optics(v=None):
    el = []
    # S0: aperture 33.1798m
    el.append(srwlib.SRWLOptA("r", "a", 0.002, 0.001, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(1.081))
    # HFM: sphericalMirror 34.2608m
    el.append(srwlib.SRWLOptMirSph(_r=8871.45, _size_tang=0.95, _size_sag=0.005, _nvx=0.999996875002, _nvy=0.0, _nvz=-0.00249999739583, _tvx=0.00249999739583, _tvy=0.0, _x=0.0, _y=0.0))

    el.append(srwlib.SRWLOptD(1.407))
    # S1: aperture 35.6678m
    el.append(srwlib.SRWLOptA("r", "a", 0.0024, 0.0015, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(0.781))
    # DCM: C1: crystal 36.4488m
    opCr = srwlib.SRWLOptCryst(_d_sp=3.13557135638, _psi0r=-1.53227839905e-05, _psi0i=3.59410775406e-07, _psi_hr=-8.10706354484e-06, _psi_hi=2.50931132347e-07, _psi_hbr=-8.10706354484e-06, _psi_hbi=2.50931132347e-07, _tc=0.01, _ang_as=0.0)
    # Set crystal orientation:
    opCr.set_orient(-0.968973817886, 2.59635532439e-08, -0.247163387763, -0.247163387763, 6.62271741473e-09)
    el.append(opCr)

    # DCM: C2: crystal 36.4488m
    opCr = srwlib.SRWLOptCryst(_d_sp=3.13557135638, _psi0r=-1.53227839905e-05, _psi0i=3.59410775406e-07, _psi_hr=-8.10706354484e-06, _psi_hi=2.50931132347e-07, _psi_hbr=-8.10706354484e-06, _psi_hbi=2.50931132347e-07, _tc=0.01, _ang_as=0.0)
    # Set crystal orientation:
    opCr.set_orient(0.968973817886, 0.0, -0.247163387763, 0.247163387763, 0.0)
    el.append(opCr)

    el.append(srwlib.SRWLOptD(2.2416))
    # At BPM1: watch 38.6904m

    el.append(srwlib.SRWLOptD(11.9668))
    # Before SSA: watch 50.6572m

    # SSA: aperture 50.6572m
    el.append(srwlib.SRWLOptA("r", "a", 5e-05, 0.003, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(11.8308))
    # AKB: aperture 62.488m
    el.append(srwlib.SRWLOptA("r", "a", 0.003, 0.000875, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(0.175))
    # KBV: ellipsoidMirror 62.663m
    el.append(srwlib.SRWLOptMirEl(_p=63.913, _q=0.637, _ang_graz=0.0025, _size_tang=0.35, _size_sag=0.003, _nvx=0.0, _nvy=0.999996875002, _nvz=-0.00249999739583, _tvx=0.0, _tvy=-0.00249999739583, _x=0.0, _y=0.0))

    el.append(srwlib.SRWLOptD(0.337))
    # KBH: ellipsoidMirror 63.0m
    el.append(srwlib.SRWLOptMirEl(_p=12.3428, _q=0.3, _ang_graz=0.0025, _size_tang=0.3, _size_sag=0.003, _nvx=0.999996875002, _nvy=0.0, _nvz=-0.00249999739583, _tvx=-0.00249999739583, _tvy=0.0, _x=0.0, _y=0.0))

    el.append(srwlib.SRWLOptD(0.3))
    # At Sample: watch 63.3m

    pp = []
    # S0
    pp.append([0, 0, 1.0, 0, 0, 1.1, 7.0, 1.3, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    # HFM
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    # S1
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    # DCM: C1
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    # DCM: C2
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    # At BPM1
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    # Before SSA
    # SSA
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    # AKB
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    # KBV
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    # KBH
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    pp.append([0, 0, 1.0, 4, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    # At Sample
    # final post-propagation
    pp.append([0, 0, 1.0, 0, 1, 0.5, 1.0, 0.2, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    return srwlib.SRWLOptC(el, pp)
Пример #25
0
def set_optics(v=None):
    el = []
    # MOAT 1: crystal 31.94m
    opCr = srwlib.SRWLOptCryst(_d_sp=3.13557135638,
                               _psi0r=-2.33400050166e-06,
                               _psi0i=8.59790386417e-09,
                               _psi_hr=-1.22944507993e-06,
                               _psi_hi=6.00282990962e-09,
                               _psi_hbr=-1.22944507993e-06,
                               _psi_hbi=6.00282990962e-09,
                               _tc=0.01,
                               _ang_as=0.0)
    # Set crystal orientation:
    opCr.set_orient(-0.0966554453406, 0.990567587399, -0.0971266167475,
                    -0.00943241252825, 0.0966675192333)
    el.append(opCr)
    ifnCryst1 = "Si_heat204.dat"
    if ifnCryst1:
        assert os.path.isfile(
            ifnCryst1
        ), "Missing input file Si_heat204.dat, required by MOAT 1 beamline element"
        hProfDataCryst1 = srwlib.srwl_uti_read_data_cols(ifnCryst1, "\t", 0, 1)
        el.append(
            srwlib.srwl_opt_setup_surf_height_1d(hProfDataCryst1,
                                                 _dim="y",
                                                 _ang=0.0972679033965,
                                                 _amp_coef=1.0))
    el.append(srwlib.SRWLOptD(0.05))
    # MOAT 2: crystal 31.99m
    opCr = srwlib.SRWLOptCryst(_d_sp=3.13557135638,
                               _psi0r=-2.33400050166e-06,
                               _psi0i=8.59790386417e-09,
                               _psi_hr=-1.22944507993e-06,
                               _psi_hi=6.00282990962e-09,
                               _psi_hbr=-1.22944507993e-06,
                               _psi_hbi=6.00282990962e-09,
                               _tc=0.01,
                               _ang_as=0.0)
    # Set crystal orientation:
    opCr.set_orient(0.0966554453406, 0.990567587399, -0.0971266167475,
                    0.00943241252825, 0.0966675192333)
    el.append(opCr)

    el.append(srwlib.SRWLOptD(2.89244))
    # HFM: sphericalMirror 34.88244m
    el.append(
        srwlib.SRWLOptMirSph(_r=7100.0,
                             _size_tang=0.5,
                             _size_sag=0.04,
                             _nvx=0.999995065202,
                             _nvy=0.0,
                             _nvz=-0.00314158748629,
                             _tvx=0.00314158748629,
                             _tvy=0.0,
                             _x=0.0,
                             _y=0.0))
    ifnSphMirror2 = "HFM_Rh7.6km.dat"
    if ifnSphMirror2:
        assert os.path.isfile(
            ifnSphMirror2
        ), "Missing input file HFM_Rh7.6km.dat, required by HFM beamline element"
        hProfDataSphMirror2 = srwlib.srwl_uti_read_data_cols(
            ifnSphMirror2, "\t", 0, 1)
        el.append(
            srwlib.srwl_opt_setup_surf_height_1d(hProfDataSphMirror2,
                                                 _dim="x",
                                                 _ang=0.003141592654,
                                                 _amp_coef=1.0))
    el.append(srwlib.SRWLOptD(3.42))
    # VFM: sphericalMirror 38.30244m
    el.append(
        srwlib.SRWLOptMirSph(_r=6100.0,
                             _size_tang=0.4,
                             _size_sag=0.04,
                             _nvx=0.0,
                             _nvy=0.999995065202,
                             _nvz=-0.00314158748629,
                             _tvx=0.0,
                             _tvy=0.00314158748629,
                             _x=0.0,
                             _y=0.0))
    ifnSphMirror3 = "VFM_Rh5.4km.dat"
    if ifnSphMirror3:
        assert os.path.isfile(
            ifnSphMirror3
        ), "Missing input file VFM_Rh5.4km.dat, required by VFM beamline element"
        hProfDataSphMirror3 = srwlib.srwl_uti_read_data_cols(
            ifnSphMirror3, "\t", 0, 1)
        el.append(
            srwlib.srwl_opt_setup_surf_height_1d(hProfDataSphMirror3,
                                                 _dim="y",
                                                 _ang=0.003141592654,
                                                 _amp_coef=1.0))
    el.append(srwlib.SRWLOptD(0.69756))
    # VDM: sphericalMirror 39.0m
    el.append(
        srwlib.SRWLOptMirSph(_r=300000.0,
                             _size_tang=0.4,
                             _size_sag=0.04,
                             _nvx=0.0,
                             _nvy=0.999995065202,
                             _nvz=-0.00314158743229,
                             _tvx=0.0,
                             _tvy=0.00314158743229,
                             _x=0.0,
                             _y=0.0))
    ifnSphMirror4 = "VDM.dat"
    if ifnSphMirror4:
        assert os.path.isfile(
            ifnSphMirror4
        ), "Missing input file VDM.dat, required by VDM beamline element"
        hProfDataSphMirror4 = srwlib.srwl_uti_read_data_cols(
            ifnSphMirror4, "\t", 0, 1)
        el.append(
            srwlib.srwl_opt_setup_surf_height_1d(hProfDataSphMirror4,
                                                 _dim="y",
                                                 _ang=0.0031415926,
                                                 _amp_coef=1.0))
    el.append(srwlib.SRWLOptD(8.00244))
    # SSA: aperture 47.00244m
    el.append(srwlib.SRWLOptA("r", "a", 0.0004, 0.0004, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(3.89756))
    # ES1: watch 50.9m

    el.append(srwlib.SRWLOptD(6.435))
    # CRL: crl 57.335m
    el.append(
        srwlib.srwl_opt_setup_CRL(3, 8.211821e-07, 0.028541, 1, 0.001, 0.001,
                                  5e-05, 23, 3.24e-05, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(1.665))
    # ES2: watch 59.0m

    pp = []
    # MOAT 1
    pp.append([
        0, 0, 1.0, 0, 0, 3.0, 1.0, 3.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    if ifnCryst1:
        pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([
        0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    # MOAT 2
    pp.append([
        0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    pp.append([
        0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    # HFM
    pp.append([
        0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    if ifnSphMirror2:
        pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([
        0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    # VFM
    pp.append([
        0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    if ifnSphMirror3:
        pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([
        0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    # VDM
    pp.append([
        0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    if ifnSphMirror4:
        pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([
        0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    # SSA
    pp.append([
        0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    pp.append([
        0, 0, 1.0, 1, 0, 0.5, 5.0, 0.5, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    # ES1
    pp.append([
        0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    # CRL
    pp.append([
        0, 0, 1.0, 2, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    pp.append([
        0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    # ES2
    # final post-propagation
    pp.append([
        0, 0, 1.0, 0, 0, 0.4, 3.0, 0.4, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    return srwlib.SRWLOptC(el, pp)
Пример #26
0
def set_optics(v=None):
    """ Function from Sirepo's SRW code """
    el = []
    pp = []
    names = [
        'Elliptical_Cylinder', 'Elliptical_Cylinder_Elliptical_Cylinder2',
        'Elliptical_Cylinder2', 'Elliptical_Cylinder2_Watchpoint', 'Watchpoint'
    ]
    for el_name in names:
        if el_name == 'Elliptical_Cylinder':
            # Elliptical_Cylinder: ellipsoidMirror 28.5m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_Elliptical_Cylinder_p,
                    _q=v.op_Elliptical_Cylinder_q,
                    _ang_graz=v.op_Elliptical_Cylinder_ang,
                    _size_tang=v.op_Elliptical_Cylinder_size_tang,
                    _size_sag=v.op_Elliptical_Cylinder_size_sag,
                    _nvx=v.op_Elliptical_Cylinder_nvx,
                    _nvy=v.op_Elliptical_Cylinder_nvy,
                    _nvz=v.op_Elliptical_Cylinder_nvz,
                    _tvx=v.op_Elliptical_Cylinder_tvx,
                    _tvy=v.op_Elliptical_Cylinder_tvy,
                    _x=v.op_Elliptical_Cylinder_x,
                    _y=v.op_Elliptical_Cylinder_y,
                ))
            pp.append(v.op_Elliptical_Cylinder_pp)

        elif el_name == 'Elliptical_Cylinder_Elliptical_Cylinder2':
            # Elliptical_Cylinder_Elliptical_Cylinder2: drift 28.5m
            el.append(
                srwlib.SRWLOptD(
                    _L=v.op_Elliptical_Cylinder_Elliptical_Cylinder2_L, ))
            pp.append(v.op_Elliptical_Cylinder_Elliptical_Cylinder2_pp)
        elif el_name == 'Elliptical_Cylinder2':
            # Elliptical_Cylinder2: ellipsoidMirror 29.5m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_Elliptical_Cylinder2_p,
                    _q=v.op_Elliptical_Cylinder2_q,
                    _ang_graz=v.op_Elliptical_Cylinder2_ang,
                    _size_tang=v.op_Elliptical_Cylinder2_size_tang,
                    _size_sag=v.op_Elliptical_Cylinder2_size_sag,
                    _nvx=v.op_Elliptical_Cylinder2_nvx,
                    _nvy=v.op_Elliptical_Cylinder2_nvy,
                    _nvz=v.op_Elliptical_Cylinder2_nvz,
                    _tvx=v.op_Elliptical_Cylinder2_tvx,
                    _tvy=v.op_Elliptical_Cylinder2_tvy,
                    _x=v.op_Elliptical_Cylinder2_x,
                    _y=v.op_Elliptical_Cylinder2_y,
                ))
            pp.append(v.op_Elliptical_Cylinder2_pp)

        elif el_name == 'Elliptical_Cylinder2_Watchpoint':
            # Elliptical_Cylinder2_Watchpoint: drift 29.5m
            el.append(
                srwlib.SRWLOptD(_L=v.op_Elliptical_Cylinder2_Watchpoint_L, ))
            pp.append(v.op_Elliptical_Cylinder2_Watchpoint_pp)
        elif el_name == 'Watchpoint':
            # Watchpoint: watch 37.5m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Пример #27
0
def set_optics(v=None):
    el = []
    pp = []
    names = [
        'Fixed_Mask', 'Fixed_Mask_M1A', 'M1A', 'M1A_Watchpoint', 'Watchpoint',
        'M2A_VDM', 'M2A_VDM_Grating', 'Grating', 'Grating_Aperture',
        'Aperture', 'Watchpoint2', 'M3A_HFM', 'M3A_HFM_Watchpoint3',
        'Watchpoint3', 'Pinhole', 'Watchpoint4', 'Watchpoint4_Sample', 'Sample'
    ]
    for el_name in names:
        if el_name == 'Fixed_Mask':
            # Fixed_Mask: aperture 26.2m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_Fixed_Mask_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_Fixed_Mask_Dx,
                    _Dy=v.op_Fixed_Mask_Dy,
                    _x=v.op_Fixed_Mask_x,
                    _y=v.op_Fixed_Mask_y,
                ))
            pp.append(v.op_Fixed_Mask_pp)
        elif el_name == 'Fixed_Mask_M1A':
            # Fixed_Mask_M1A: drift 26.2m
            el.append(srwlib.SRWLOptD(_L=v.op_Fixed_Mask_M1A_L, ))
            pp.append(v.op_Fixed_Mask_M1A_pp)
        elif el_name == 'M1A':
            # M1A: mirror 27.2m
            mirror_file = v.op_M1A_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by M1A beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_M1A_dim,
                    _ang=abs(v.op_M1A_ang),
                    _amp_coef=v.op_M1A_amp_coef,
                    _size_x=v.op_M1A_size_x,
                    _size_y=v.op_M1A_size_y,
                ))
            pp.append(v.op_M1A_pp)
        elif el_name == 'M1A_Watchpoint':
            # M1A_Watchpoint: drift 27.2m
            el.append(srwlib.SRWLOptD(_L=v.op_M1A_Watchpoint_L, ))
            pp.append(v.op_M1A_Watchpoint_pp)
        elif el_name == 'Watchpoint':
            # Watchpoint: watch 40.4m
            pass
        elif el_name == 'M2A_VDM':
            # M2A_VDM: mirror 40.4m
            mirror_file = v.op_M2A_VDM_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by M2A_VDM beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_M2A_VDM_dim,
                    _ang=abs(v.op_M2A_VDM_ang),
                    _amp_coef=v.op_M2A_VDM_amp_coef,
                    _size_x=v.op_M2A_VDM_size_x,
                    _size_y=v.op_M2A_VDM_size_y,
                ))
            pp.append(v.op_M2A_VDM_pp)
        elif el_name == 'M2A_VDM_Grating':
            # M2A_VDM_Grating: drift 40.4m
            el.append(srwlib.SRWLOptD(_L=v.op_M2A_VDM_Grating_L, ))
            pp.append(v.op_M2A_VDM_Grating_pp)
        elif el_name == 'Grating':
            # Grating: grating 40.46m
            mirror = srwlib.SRWLOptMirPl(
                _size_tang=v.op_Grating_size_tang,
                _size_sag=v.op_Grating_size_sag,
                _nvx=v.op_Grating_nvx,
                _nvy=v.op_Grating_nvy,
                _nvz=v.op_Grating_nvz,
                _tvx=v.op_Grating_tvx,
                _tvy=v.op_Grating_tvy,
                _x=v.op_Grating_x,
                _y=v.op_Grating_y,
            )
            el.append(
                srwlib.SRWLOptG(
                    _mirSub=mirror,
                    _m=v.op_Grating_m,
                    _grDen=v.op_Grating_grDen,
                    _grDen1=v.op_Grating_grDen1,
                    _grDen2=v.op_Grating_grDen2,
                    _grDen3=v.op_Grating_grDen3,
                    _grDen4=v.op_Grating_grDen4,
                ))
            pp.append(v.op_Grating_pp)
        elif el_name == 'Grating_Aperture':
            # Grating_Aperture: drift 40.46m
            el.append(srwlib.SRWLOptD(_L=v.op_Grating_Aperture_L, ))
            pp.append(v.op_Grating_Aperture_pp)
        elif el_name == 'Aperture':
            # Aperture: aperture 42.46m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_Aperture_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_Aperture_Dx,
                    _Dy=v.op_Aperture_Dy,
                    _x=v.op_Aperture_x,
                    _y=v.op_Aperture_y,
                ))
            pp.append(v.op_Aperture_pp)
        elif el_name == 'Watchpoint2':
            # Watchpoint2: watch 42.46m
            pass
        elif el_name == 'M3A_HFM':
            # M3A_HFM: sphericalMirror 42.46m
            el.append(
                srwlib.SRWLOptMirSph(
                    _r=v.op_M3A_HFM_r,
                    _size_tang=v.op_M3A_HFM_size_tang,
                    _size_sag=v.op_M3A_HFM_size_sag,
                    _nvx=v.op_M3A_HFM_nvx,
                    _nvy=v.op_M3A_HFM_nvy,
                    _nvz=v.op_M3A_HFM_nvz,
                    _tvx=v.op_M3A_HFM_tvx,
                    _tvy=v.op_M3A_HFM_tvy,
                    _x=v.op_M3A_HFM_x,
                    _y=v.op_M3A_HFM_y,
                ))
            pp.append(v.op_M3A_HFM_pp)

        elif el_name == 'M3A_HFM_Watchpoint3':
            # M3A_HFM_Watchpoint3: drift 42.46m
            el.append(srwlib.SRWLOptD(_L=v.op_M3A_HFM_Watchpoint3_L, ))
            pp.append(v.op_M3A_HFM_Watchpoint3_pp)
        elif el_name == 'Watchpoint3':
            # Watchpoint3: watch 54.36m
            pass
        elif el_name == 'Pinhole':
            # Pinhole: aperture 54.36m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_Pinhole_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_Pinhole_Dx,
                    _Dy=v.op_Pinhole_Dy,
                    _x=v.op_Pinhole_x,
                    _y=v.op_Pinhole_y,
                ))
            pp.append(v.op_Pinhole_pp)
        elif el_name == 'Watchpoint4':
            # Watchpoint4: watch 54.36m
            pass
        elif el_name == 'Watchpoint4_Sample':
            # Watchpoint4_Sample: drift 54.36m
            el.append(srwlib.SRWLOptD(_L=v.op_Watchpoint4_Sample_L, ))
            pp.append(v.op_Watchpoint4_Sample_pp)
        elif el_name == 'Sample':
            # Sample: watch 55.5m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Пример #28
0
def set_optics(v=None):
    el = []
    pp = []
    names = [
        'S0', 'S0_HFM', 'HFM', 'HFM_S1', 'S1', 'S1_DCM_C1', 'DCM_C1', 'DCM_C2',
        'DCM_C2_At_BPM1', 'At_BPM1', 'At_BPM1_Before_SSA', 'Before_SSA', 'SSA',
        'SSA_AKB', 'AKB', 'AKB_KBV', 'KBV', 'KBV_KBH', 'KBH', 'KBH_At_Sample',
        'At_Sample'
    ]
    for el_name in names:
        if el_name == 'S0':
            # S0: aperture 33.1798m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_S0_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_S0_Dx,
                    _Dy=v.op_S0_Dy,
                    _x=v.op_S0_x,
                    _y=v.op_S0_y,
                ))
            pp.append(v.op_S0_pp)
        elif el_name == 'S0_HFM':
            # S0_HFM: drift 33.1798m
            el.append(srwlib.SRWLOptD(_L=v.op_S0_HFM_L, ))
            pp.append(v.op_S0_HFM_pp)
        elif el_name == 'HFM':
            # HFM: sphericalMirror 34.2608m
            el.append(
                srwlib.SRWLOptMirSph(
                    _r=v.op_HFM_r,
                    _size_tang=v.op_HFM_size_tang,
                    _size_sag=v.op_HFM_size_sag,
                    _nvx=v.op_HFM_nvx,
                    _nvy=v.op_HFM_nvy,
                    _nvz=v.op_HFM_nvz,
                    _tvx=v.op_HFM_tvx,
                    _tvy=v.op_HFM_tvy,
                    _x=v.op_HFM_x,
                    _y=v.op_HFM_y,
                ))
            pp.append(v.op_HFM_pp)

        elif el_name == 'HFM_S1':
            # HFM_S1: drift 34.2608m
            el.append(srwlib.SRWLOptD(_L=v.op_HFM_S1_L, ))
            pp.append(v.op_HFM_S1_pp)
        elif el_name == 'S1':
            # S1: aperture 35.6678m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_S1_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_S1_Dx,
                    _Dy=v.op_S1_Dy,
                    _x=v.op_S1_x,
                    _y=v.op_S1_y,
                ))
            pp.append(v.op_S1_pp)
        elif el_name == 'S1_DCM_C1':
            # S1_DCM_C1: drift 35.6678m
            el.append(srwlib.SRWLOptD(_L=v.op_S1_DCM_C1_L, ))
            pp.append(v.op_S1_DCM_C1_pp)
        elif el_name == 'DCM_C1':
            # DCM_C1: crystal 36.4488m
            crystal = srwlib.SRWLOptCryst(
                _d_sp=v.op_DCM_C1_d_sp,
                _psi0r=v.op_DCM_C1_psi0r,
                _psi0i=v.op_DCM_C1_psi0i,
                _psi_hr=v.op_DCM_C1_psiHr,
                _psi_hi=v.op_DCM_C1_psiHi,
                _psi_hbr=v.op_DCM_C1_psiHBr,
                _psi_hbi=v.op_DCM_C1_psiHBi,
                _tc=v.op_DCM_C1_tc,
                _ang_as=v.op_DCM_C1_ang_as,
            )
            crystal.set_orient(
                _nvx=v.op_DCM_C1_nvx,
                _nvy=v.op_DCM_C1_nvy,
                _nvz=v.op_DCM_C1_nvz,
                _tvx=v.op_DCM_C1_tvx,
                _tvy=v.op_DCM_C1_tvy,
            )
            el.append(crystal)
            pp.append(v.op_DCM_C1_pp)

        elif el_name == 'DCM_C2':
            # DCM_C2: crystal 36.4488m
            crystal = srwlib.SRWLOptCryst(
                _d_sp=v.op_DCM_C2_d_sp,
                _psi0r=v.op_DCM_C2_psi0r,
                _psi0i=v.op_DCM_C2_psi0i,
                _psi_hr=v.op_DCM_C2_psiHr,
                _psi_hi=v.op_DCM_C2_psiHi,
                _psi_hbr=v.op_DCM_C2_psiHBr,
                _psi_hbi=v.op_DCM_C2_psiHBi,
                _tc=v.op_DCM_C2_tc,
                _ang_as=v.op_DCM_C2_ang_as,
            )
            crystal.set_orient(
                _nvx=v.op_DCM_C2_nvx,
                _nvy=v.op_DCM_C2_nvy,
                _nvz=v.op_DCM_C2_nvz,
                _tvx=v.op_DCM_C2_tvx,
                _tvy=v.op_DCM_C2_tvy,
            )
            el.append(crystal)
            pp.append(v.op_DCM_C2_pp)

        elif el_name == 'DCM_C2_At_BPM1':
            # DCM_C2_At_BPM1: drift 36.4488m
            el.append(srwlib.SRWLOptD(_L=v.op_DCM_C2_At_BPM1_L, ))
            pp.append(v.op_DCM_C2_At_BPM1_pp)
        elif el_name == 'At_BPM1':
            # At_BPM1: watch 38.6904m
            pass
        elif el_name == 'At_BPM1_Before_SSA':
            # At_BPM1_Before_SSA: drift 38.6904m
            el.append(srwlib.SRWLOptD(_L=v.op_At_BPM1_Before_SSA_L, ))
            pp.append(v.op_At_BPM1_Before_SSA_pp)
        elif el_name == 'Before_SSA':
            # Before_SSA: watch 50.6572m
            pass
        elif el_name == 'SSA':
            # SSA: aperture 50.6572m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_SSA_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_SSA_Dx,
                    _Dy=v.op_SSA_Dy,
                    _x=v.op_SSA_x,
                    _y=v.op_SSA_y,
                ))
            pp.append(v.op_SSA_pp)
        elif el_name == 'SSA_AKB':
            # SSA_AKB: drift 50.6572m
            el.append(srwlib.SRWLOptD(_L=v.op_SSA_AKB_L, ))
            pp.append(v.op_SSA_AKB_pp)
        elif el_name == 'AKB':
            # AKB: aperture 62.488m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_AKB_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_AKB_Dx,
                    _Dy=v.op_AKB_Dy,
                    _x=v.op_AKB_x,
                    _y=v.op_AKB_y,
                ))
            pp.append(v.op_AKB_pp)
        elif el_name == 'AKB_KBV':
            # AKB_KBV: drift 62.488m
            el.append(srwlib.SRWLOptD(_L=v.op_AKB_KBV_L, ))
            pp.append(v.op_AKB_KBV_pp)
        elif el_name == 'KBV':
            # KBV: ellipsoidMirror 62.663m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_KBV_p,
                    _q=v.op_KBV_q,
                    _ang_graz=v.op_KBV_ang,
                    _size_tang=v.op_KBV_size_tang,
                    _size_sag=v.op_KBV_size_sag,
                    _nvx=v.op_KBV_nvx,
                    _nvy=v.op_KBV_nvy,
                    _nvz=v.op_KBV_nvz,
                    _tvx=v.op_KBV_tvx,
                    _tvy=v.op_KBV_tvy,
                    _x=v.op_KBV_x,
                    _y=v.op_KBV_y,
                ))
            pp.append(v.op_KBV_pp)

        elif el_name == 'KBV_KBH':
            # KBV_KBH: drift 62.663m
            el.append(srwlib.SRWLOptD(_L=v.op_KBV_KBH_L, ))
            pp.append(v.op_KBV_KBH_pp)
        elif el_name == 'KBH':
            # KBH: ellipsoidMirror 63.0m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_KBH_p,
                    _q=v.op_KBH_q,
                    _ang_graz=v.op_KBH_ang,
                    _size_tang=v.op_KBH_size_tang,
                    _size_sag=v.op_KBH_size_sag,
                    _nvx=v.op_KBH_nvx,
                    _nvy=v.op_KBH_nvy,
                    _nvz=v.op_KBH_nvz,
                    _tvx=v.op_KBH_tvx,
                    _tvy=v.op_KBH_tvy,
                    _x=v.op_KBH_x,
                    _y=v.op_KBH_y,
                ))
            pp.append(v.op_KBH_pp)

        elif el_name == 'KBH_At_Sample':
            # KBH_At_Sample: drift 63.0m
            el.append(srwlib.SRWLOptD(_L=v.op_KBH_At_Sample_L, ))
            pp.append(v.op_KBH_At_Sample_pp)
        elif el_name == 'At_Sample':
            # At_Sample: watch 63.3m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Пример #29
0
def set_optics(v=None):
    el = []
    pp = []
    names = [
        'VFM', 'VFM_HFM', 'HFM', 'HFM_Watchpoint', 'Watchpoint',
        'Watchpoint_Mask', 'Mask', 'Watchpoint2'
    ]
    for el_name in names:
        if el_name == 'VFM':
            # VFM: ellipsoidMirror 50.0m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_VFM_p,
                    _q=v.op_VFM_q,
                    _ang_graz=v.op_VFM_ang,
                    _size_tang=v.op_VFM_size_tang,
                    _size_sag=v.op_VFM_size_sag,
                    _nvx=v.op_VFM_nvx,
                    _nvy=v.op_VFM_nvy,
                    _nvz=v.op_VFM_nvz,
                    _tvx=v.op_VFM_tvx,
                    _tvy=v.op_VFM_tvy,
                    _x=v.op_VFM_x,
                    _y=v.op_VFM_y,
                ))
            pp.append(v.op_VFM_pp)

        elif el_name == 'VFM_HFM':
            # VFM_HFM: drift 50.0m
            el.append(srwlib.SRWLOptD(_L=v.op_VFM_HFM_L, ))
            pp.append(v.op_VFM_HFM_pp)
        elif el_name == 'HFM':
            # HFM: ellipsoidMirror 50.2m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_HFM_p,
                    _q=v.op_HFM_q,
                    _ang_graz=v.op_HFM_ang,
                    _size_tang=v.op_HFM_size_tang,
                    _size_sag=v.op_HFM_size_sag,
                    _nvx=v.op_HFM_nvx,
                    _nvy=v.op_HFM_nvy,
                    _nvz=v.op_HFM_nvz,
                    _tvx=v.op_HFM_tvx,
                    _tvy=v.op_HFM_tvy,
                    _x=v.op_HFM_x,
                    _y=v.op_HFM_y,
                ))
            pp.append(v.op_HFM_pp)

        elif el_name == 'HFM_Watchpoint':
            # HFM_Watchpoint: drift 50.2m
            el.append(srwlib.SRWLOptD(_L=v.op_HFM_Watchpoint_L, ))
            pp.append(v.op_HFM_Watchpoint_pp)
        elif el_name == 'Watchpoint':
            # Watchpoint: watch 50.4m
            pass
        elif el_name == 'Watchpoint_Mask':
            # Watchpoint_Mask: drift 50.4m
            el.append(srwlib.SRWLOptD(_L=v.op_Watchpoint_Mask_L, ))
            pp.append(v.op_Watchpoint_Mask_pp)
        elif el_name == 'Mask':
            # Mask: mask 50.6m
            el.append(
                srwlib.srwl_opt_setup_mask(
                    _delta=v.op_Mask_delta,
                    _atten_len=v.op_Mask_atten_len,
                    _thick=v.op_Mask_thick,
                    _grid_sh=v.op_Mask_grid_sh,
                    _grid_dx=v.op_Mask_grid_dx,
                    _grid_dy=v.op_Mask_grid_dy,
                    _pitch_x=v.op_Mask_pitch_x,
                    _pitch_y=v.op_Mask_pitch_y,
                    _grid_nx=v.op_Mask_grid_nx,
                    _grid_ny=v.op_Mask_grid_ny,
                    _mask_Nx=v.op_Mask_mask_Nx,
                    _mask_Ny=v.op_Mask_mask_Ny,
                    _grid_angle=v.op_Mask_gridTiltAngle,
                    _hx=v.op_Mask_hx,
                    _hy=v.op_Mask_hy,
                    _mask_x0=v.op_Mask_mask_x0,
                    _mask_y0=v.op_Mask_mask_y0,
                ))
            pp.append(v.op_Mask_pp)
        elif el_name == 'Watchpoint2':
            # Watchpoint2: watch 50.6m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Пример #30
0
def set_optics(v=None):
    el = []
    pp = []
    names = [
        'ApM1', 'M1', 'M1_Watchpoint', 'Watchpoint', 'ApKB', 'VFM', 'VFM_HFM',
        'HFM', 'HFM_Sample', 'Sample'
    ]
    for el_name in names:
        if el_name == 'ApM1':
            # ApM1: aperture 270.0m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_ApM1_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_ApM1_Dx,
                    _Dy=v.op_ApM1_Dy,
                    _x=v.op_ApM1_x,
                    _y=v.op_ApM1_y,
                ))
            pp.append(v.op_ApM1_pp)
        elif el_name == 'M1':
            # M1: mirror 270.0m
            mirror_file = v.op_M1_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by M1 beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_M1_dim,
                    _ang=abs(v.op_M1_ang),
                    _amp_coef=v.op_M1_amp_coef,
                    _size_x=v.op_M1_size_x,
                    _size_y=v.op_M1_size_y,
                ))
            pp.append(v.op_M1_pp)
        elif el_name == 'M1_Watchpoint':
            # M1_Watchpoint: drift 270.0m
            el.append(srwlib.SRWLOptD(_L=v.op_M1_Watchpoint_L, ))
            pp.append(v.op_M1_Watchpoint_pp)
        elif el_name == 'Watchpoint':
            # Watchpoint: watch 928.3m
            pass
        elif el_name == 'ApKB':
            # ApKB: aperture 928.3m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_ApKB_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_ApKB_Dx,
                    _Dy=v.op_ApKB_Dy,
                    _x=v.op_ApKB_x,
                    _y=v.op_ApKB_y,
                ))
            pp.append(v.op_ApKB_pp)
        elif el_name == 'VFM':
            # VFM: ellipsoidMirror 928.3m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_VFM_p,
                    _q=v.op_VFM_q,
                    _ang_graz=v.op_VFM_ang,
                    _size_tang=v.op_VFM_size_tang,
                    _size_sag=v.op_VFM_size_sag,
                    _nvx=v.op_VFM_nvx,
                    _nvy=v.op_VFM_nvy,
                    _nvz=v.op_VFM_nvz,
                    _tvx=v.op_VFM_tvx,
                    _tvy=v.op_VFM_tvy,
                    _x=v.op_VFM_x,
                    _y=v.op_VFM_y,
                ))
            pp.append(v.op_VFM_pp)
            mirror_file = v.op_VFM_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by VFM beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_VFM_dim,
                    _ang=abs(v.op_VFM_ang),
                    _amp_coef=v.op_VFM_amp_coef,
                ))
            pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
        elif el_name == 'VFM_HFM':
            # VFM_HFM: drift 928.3m
            el.append(srwlib.SRWLOptD(_L=v.op_VFM_HFM_L, ))
            pp.append(v.op_VFM_HFM_pp)
        elif el_name == 'HFM':
            # HFM: ellipsoidMirror 928.9m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_HFM_p,
                    _q=v.op_HFM_q,
                    _ang_graz=v.op_HFM_ang,
                    _size_tang=v.op_HFM_size_tang,
                    _size_sag=v.op_HFM_size_sag,
                    _nvx=v.op_HFM_nvx,
                    _nvy=v.op_HFM_nvy,
                    _nvz=v.op_HFM_nvz,
                    _tvx=v.op_HFM_tvx,
                    _tvy=v.op_HFM_tvy,
                    _x=v.op_HFM_x,
                    _y=v.op_HFM_y,
                ))
            pp.append(v.op_HFM_pp)
            mirror_file = v.op_HFM_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by HFM beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_HFM_dim,
                    _ang=abs(v.op_HFM_ang),
                    _amp_coef=v.op_HFM_amp_coef,
                ))
            pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
        elif el_name == 'HFM_Sample':
            # HFM_Sample: drift 928.9m
            el.append(srwlib.SRWLOptD(_L=v.op_HFM_Sample_L, ))
            pp.append(v.op_HFM_Sample_pp)
        elif el_name == 'Sample':
            # Sample: watch 930.0m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)