예제 #1
0
파일: srw_6.py 프로젝트: ahebnl/Sirepo
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)
예제 #2
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)
예제 #3
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)
예제 #4
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)
예제 #5
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)
예제 #6
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)
예제 #7
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)
예제 #8
0
def set_optics(v=None):
    el = []
    # S0: aperture 31.5m
    el.append(srwlib.SRWLOptA("r", "a", 0.001, 0.00042, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(1.5))
    # VCM: sphericalMirror 33.0m
    el.append(
        srwlib.SRWLOptMirSph(_r=19000.0,
                             _size_tang=0.5,
                             _size_sag=0.01,
                             _nvx=0.0,
                             _nvy=0.99999846875,
                             _nvz=-0.00174999910677,
                             _tvx=0.0,
                             _tvy=0.00174999910677,
                             _x=0.0,
                             _y=0.0))
    ifnSphMirror1 = "LCLS_SOMS_height_prof_1d_3x_ns.dat"
    if ifnSphMirror1:
        assert os.path.isfile(
            ifnSphMirror1
        ), "Missing input file LCLS_SOMS_height_prof_1d_3x_ns.dat, required by VCM beamline element"
        hProfDataSphMirror1 = srwlib.srwl_uti_read_data_cols(
            ifnSphMirror1, "\t", 0, 1)
        el.append(
            srwlib.srwl_opt_setup_surf_height_1d(hProfDataSphMirror1,
                                                 _dim="y",
                                                 _ang=0.00175,
                                                 _amp_coef=0.9999))
    el.append(srwlib.SRWLOptD(21.0))
    # S0H: aperture 54.0m
    el.append(srwlib.SRWLOptA("r", "a", 6e-05, 0.001, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(1.0))
    # Watchpoint: watch 55.0m

    # HCM: sphericalMirror 55.0m
    el.append(
        srwlib.SRWLOptMirSph(_r=14000.0,
                             _size_tang=0.5,
                             _size_sag=0.01,
                             _nvx=0.99999846875,
                             _nvy=0.0,
                             _nvz=-0.00174999910677,
                             _tvx=0.00174999910677,
                             _tvy=0.0,
                             _x=0.0,
                             _y=0.0))
    ifnSphMirror2 = "LCLS_SOMS_height_prof_1d_3x_ns.dat"
    if ifnSphMirror2:
        assert os.path.isfile(
            ifnSphMirror2
        ), "Missing input file LCLS_SOMS_height_prof_1d_3x_ns.dat, required by HCM 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.00175,
                                                 _amp_coef=1.0))
    el.append(srwlib.SRWLOptD(40.0))
    # Ap. KB: aperture 95.0m
    el.append(srwlib.SRWLOptA("r", "a", 0.001, 0.001, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(2.4))
    # VKB: ellipsoidMirror 97.4m
    el.append(
        srwlib.SRWLOptMirEl(_p=32.0,
                            _q=2.6,
                            _ang_graz=0.003,
                            _size_tang=0.4,
                            _size_sag=0.01,
                            _nvx=0.0,
                            _nvy=0.999995500003,
                            _nvz=-0.0029999955,
                            _tvx=0.0,
                            _tvy=0.0029999955,
                            _x=0.0,
                            _y=0.0))
    ifnElMirror3 = "LCLS_SOMS_height_prof_1d_3x_ns.dat"
    if ifnElMirror3:
        assert os.path.isfile(
            ifnElMirror3
        ), "Missing input file LCLS_SOMS_height_prof_1d_3x_ns.dat, required by VKB beamline element"
        hProfDataElMirror3 = srwlib.srwl_uti_read_data_cols(
            ifnElMirror3, "\t", 0, 1)
        el.append(
            srwlib.srwl_opt_setup_surf_height_1d(hProfDataElMirror3,
                                                 _dim="y",
                                                 _ang=0.003,
                                                 _amp_coef=1.0))
    el.append(srwlib.SRWLOptD(0.6))
    # Watchpoint: watch 98.0m

    # HKB: ellipsoidMirror 98.0m
    el.append(
        srwlib.SRWLOptMirEl(_p=38.0,
                            _q=2.0,
                            _ang_graz=0.003,
                            _size_tang=0.3,
                            _size_sag=0.01,
                            _nvx=0.999995500003,
                            _nvy=0.0,
                            _nvz=-0.0029999955,
                            _tvx=-0.0029999955,
                            _tvy=0.0,
                            _x=0.0,
                            _y=0.0))
    ifnElMirror4 = "LCLS_SOMS_height_prof_1d_3x_ns.dat"
    if ifnElMirror4:
        assert os.path.isfile(
            ifnElMirror4
        ), "Missing input file LCLS_SOMS_height_prof_1d_3x_ns.dat, required by HKB beamline element"
        hProfDataElMirror4 = srwlib.srwl_uti_read_data_cols(
            ifnElMirror4, "\t", 0, 1)
        el.append(
            srwlib.srwl_opt_setup_surf_height_1d(hProfDataElMirror4,
                                                 _dim="x",
                                                 _ang=0.003,
                                                 _amp_coef=1.0))
    el.append(srwlib.SRWLOptD(2.0))
    # Sample: watch 100.0m

    pp = []
    # S0
    pp.append([
        0, 0, 1.0, 0, 0, 4.0, 30.0, 1.3, 8.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
    ])
    # VCM
    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 ifnSphMirror1:
        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
    ])
    # S0H
    pp.append([
        0, 0, 1.0, 0, 0, 0.5, 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
    # HCM
    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
    ])
    # Ap. KB
    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
    ])
    # VKB
    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 ifnElMirror3:
        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
    ])
    # Watchpoint
    # HKB
    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 ifnElMirror4:
        pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([
        0, 0, 1.0, 1, 0, 0.2, 6.0, 1.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    # Sample
    # final post-propagation
    pp.append([
        0, 0, 1.0, 0, 0, 0.1, 1.0, 0.15, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0, 0.0
    ])
    return srwlib.SRWLOptC(el, pp)