'freq_chirp': 0, #dw/dt=[1/fs**2] - requency chirp of the beam around power_center[2] 'en_pulse': None, #total energy or max power of the pulse, use only one 'power': 1e6, } dfl = generate_dfl(**kwargs) #Gaussian beam defenition #plot_dfl(dfl, fig_name='before', phase=0) ### #RectApp = RectMask(dfl.shape()) #RectApp.lx = 0.0005 #RectApp.ly = 0.0005 #RectApp.apply(dfl) ### #EllipsApp = EllipsMask(shape = dfl.shape()) #EllipsApp.ax = 0.0005 #EllipsApp.ay = 0.0005 #dfl=EllipsApp.apply(dfl) ### RectApp = ApertureRect(lx=0.0005, ly=0.0005, cx=0, cy=0) EllipsApp = ApertureEllips(ax=0.0006, ay=0.0006, cx=0, cy=0) line = (RectApp, EllipsApp) lat = OpticsLine(line) # dfl = propagate(lat, dfl) plot_dfl(dfl, fig_name='after', phase=0)
'dgrid': (400e-5, 400e-5, 35e-6), #(x,y,z) [m] - size of field matrix 'power_rms': (25e-5, 25e-5, 4e-6), #(x,y,z) [m] - rms size of the radiation distribution (gaussian) 'power_center': (0, 0, None), #(x,y,z) [m] - position of the radiation distribution 'power_angle': (0, 0), #(x,y) [rad] - angle of further radiation propagation 'power_waistpos': (0, 0), #(Z_x,Z_y) [m] downstrean location of the waist of the beam 'wavelength': None, #central frequency of the radiation, if different from xlamds 'zsep': None, #distance between slices in z as zsep*xlamds 'freq_chirp': 0, #dw/dt=[1/fs**2] - requency chirp of the beam around power_center[2] 'en_pulse': None, #total energy or max power of the pulse, use only one 'power': 1e6, } #dfl = RadiationField() dfl = generate_gaussian_dfl(**kwargs) #Gaussian beam defenition appRect = ApertureRectMask(lx=9e-4, ly=9e-4, cx=0, cy=0) prop = PropMask(z0=30) appRect.apply(dfl) prop.apply(dfl) plot_dfl(dfl, phase=True, fig_name='after', domain='sf')
'zsep': None, #distance between slices in z as zsep*xlamds 'freq_chirp': 0, #dw/dt=[1/fs**2] - requency chirp of the beam around power_center[2] 'en_pulse': None, #total energy or max power of the pulse, use only one 'power': 1e6, } dfl1 = generate_dfl(**kwargs) #Gaussian beam defenition dfl2 = generate_dfl(**kwargs) #Gaussian beam defenition #plot_dfl(dfl, fig_name='before', phase=0) #QuadCurvMask(r = 0, plane='x').apply(dfl1) #H1 = QuadCurvMask(r = 25, plane='x').get_mask(dfl1) #H2 = QuadCurvMask(r = 25, plane='y').get_mask(dfl1) #print(H1) #print('aaaaaaaaaaaaaa') #print(H2) l = ThinLens(fx=15, fy=10) ## line = (l) lat = OpticsLine(line) ### dfl2 = propagate(lat, dfl2) #plot_dfl(dfl1, fig_name='after_dfl1', phase=0) plot_dfl(dfl2, fig_name='after_dfl2', phase=0)
##generating RadiationField() objects #help(generate_dfl) dfl = generate_gaussian_dfl(**kwargs) #Gaussian #dfl = imitate_sase_dfl(**kwargs); help(imitate_sase_dfl) #SASE-like (same as Gaussian, but modulated in time by amplitude and phase to model Gaussian random process) #help(plot_dfl) plot_dfl( dfl, domains=None, z_lim=[], xy_lim=[], figsize=4, cmap='viridis', #jet phase=False, fig_name='default_dfl_plot', auto_zoom=False, column_3d=True, savefig=False, showfig=True, return_proj=False, line_off_xy=True, log_scale=0, debug=1, cmap_cutoff=0) plot_dfl(dfl, fig_name='dfl_xy', column_3d=0, phase=1) plot_dfl(dfl, fig_name='dfl', domains='kt') plot_dfl(dfl, fig_name='dfl', domains='sf') plot_dfl(dfl, fig_name='dfl', domains='kf') plot_dfl(dfl, fig_name='dfl', log_scale=1)
hprofile = generate_1d_profile(hrms=1e-9, # [m] height errors root mean square length=0.03, # [m] length of the mirror surface points_number=1111, # number of points (pixels) at the mirror surface wavevector_cutoff=0, # [1/m] point on k axis for cut off large wave lengths in the PSD (with default value 0 effects on nothing) k=None, # [1/m] one dimension numpy.ndarray of wave vectors; if specified, psd will be calculated using this values as arguments psd=None, # [m^3] 1d array; power spectral density of surface (if not specified, will be generated) seed=666) # seed for np.random.seed() to allow reproducibility # plotting 1d height profile plot_1d_hprofile(hprofile, fig_name='mirror1 height profile and PSD') # generating gaussian RadiationField dfl = generate_gaussian_dfl(1e-9, (1000, 1000, 1)) # plotting generated RadiationField plot_dfl(dfl, phase=1, fig_name='radiation before mirror1') # reflecting generated RadiationField from the imperfect mirror dfl_reflect_surface(dfl, # ocelot.optics.wave.RadiationField, which will be reflected from imperfect mirror surface (hprofile2) angle=np.pi * 2 / 180, # [radians] angle of incidence with respect to the surface hrms=None, # [m] height errors root mean square height_profile=hprofile, # HeightProfile object of the reflecting surface (if not specified, will be generated using hrms) axis='x') # direction along which reflection takes place # plotting RadiationField after reflection plot_dfl(dfl, phase=1, fig_name='radiation after reflection from mirror1') # propagating RadiationField for 10 meters dfl.prop(z=10) # plotting RadiationField after propagation
dfl_SERVAL.xlamds = xlamds # SVEA carrieer frequency dfl_SERVAL.fld = np.random.randn(dfl_SERVAL.Nz(), dfl_SERVAL.Ny(), dfl_SERVAL.Nx()) + 1j * np.random.randn(dfl_SERVAL.Nz(), dfl_SERVAL.Ny(), dfl_SERVAL.Nx()) # Gaussian noise # dfl_SERVAL.fld = np.random.randn(dfl_SERVAL.Nz(), dfl_SERVAL.Ny(), dfl_SERVAL.Nx()) + 1j * np.random.randn(dfl_SERVAL.Nz(), dfl_SERVAL.Ny(), dfl_SERVAL.Nx()) # Gaussian noise dfl_SERVAL.filePath = filePath+'.dfl' # dfl_omega_0 = 2*np.pi * speed_of_light / dfl.xlamds # set undulator resonance to SVEA carrier frequency (to the middle of the photon energy domain mesh) # radiation_omega_resonance = dfl_omega_0 * 1.01 # shift undulator resonance to the right fieldname_SERVAL = '0-source_SERVAL' dfl_SERVAL = undulator_field_dfl_SERVAL(dfl_SERVAL, L_w=L_w, sig_x=ebeam_sigma_x, sig_y=ebeam_sigma_y, sig_xp=ebeam_sigma_xp, sig_yp=ebeam_sigma_yp, k_support = 'intensity', s_support='conv_intensities', showfig=False) plot_dfl(dfl_SERVAL, domains='sf', phase=True, fig_name = fieldname_SERVAL) plot_dfl(dfl_SERVAL, domains='kf', phase=True, fig_name = fieldname_SERVAL) #%% dfl_prop_SERVAL = deepcopy(dfl_SERVAL) fieldname_SERVAL = '1-far_zone_25_m_SERVAL' dfl_prop_SERVAL.prop_m(25, m=[12, 12]) dfl_prop_SERVAL.to_domain(domains='sf') plot_dfl(dfl_prop_SERVAL, domains='sf', phase=True, fig_name = fieldname_SERVAL) plot_dfl(dfl_prop_SERVAL, domains='kf', phase=True, fig_name = fieldname_SERVAL) corr_SERVAL = dfl_xy_corr(dfl_prop_SERVAL, norm=1) plot_dfl(corr_SERVAL, domains='sf', phase=True, fig_name = 'corr') #%%
power_center=power_center, power=(1e6), phase_chirp_lin=0) dflL = generate_gaussian_dfl(xlamds=lamds, wavelength=lamds + dlamds, dgrid=(grid_xy, grid_xy, grid_z), shape=(shape_xy, shape_xy, shape_z), power_rms=(rms_xy, rms_xy, rms_z), power_center=power_center, power=(1e6), phase_chirp_lin=0) dflR.prop_m(5, m=1) dflL.prop_m(-10, m=1) plot_dfl(dflR, cmap='Greys') S = calc_stokes_dfl(dflR, dflL, basis='rl') #%% fix #plot_stokes_values(S[25, np.newaxis, 125, np.newaxis, :], direction='x', fig=plt.figure('Stokes_x_vals')) #plot_stokes_angles(S[25, np.newaxis, 125, np.newaxis, :], direction='x', fig=plt.figure('Stokes_x_ang')) #%% fix #plot_stokes_values(S[:, 125, np.newaxis, 125, np.newaxis], direction='z', fig=plt.figure('Stokes_z_vals')) #plot_stokes_angles(S[:, 125, np.newaxis, 125, np.newaxis], direction='z', fig=plt.figure('Stokes_z_ang')) #%% #normalization = 's0' #normalize to s0 (degree of polarization is depicted, without hint of radiation intensity) normalization = 's0_max' #normalize to the maximum value of s0 (shall be rewritten in terms of power) plot_stokes_3d(S, cmap_lin='brightwheel', x_plane='max_slice',
screen_2d.ny = 200 screen_2d.nx = 200 screen_2d.start_energy = 7762 # [eV], starting photon energy screen_2d.end_energy = 7762 # [eV], ending photon energy screen_2d.num_energy = 1 # number of energy points[eV] # calculate radiation screen_2d = calculate_radiation(lat, screen_2d, beam) # %% # converting Screen to RadiationField (function generates new RadiationField() without changing Screen) dfl_2d = screen2dfl( screen_2d, # Screen object, electric field of which will be used to generate RadiationField polarization='x' ) # polarization for conversion to RadiationField ('x' or 'y') plot_dfl(dfl_2d, domains='fs', fig_name='dfl_2d generated from screen_2d') # scanning for waist position wfs = dfl_waistscan(dfl_2d, np.linspace(-80, -20, 200)) plot_dfl_waistscan(wfs, fig_name='waist scan of dfl_2d') # half analytical propagation to waist point dfl_2d.prop_m(-48.25, m=0.05) plot_dfl(dfl_2d, domains='fs', fig_name='dfl_2d at waist position') # %% # generating 3D synchrotron radiation (it will take up to 5 minute) # LOOK TUTORIAL ABOUT GENERATING SYNCHROTRON RADIATION IN demos/ipython_tutorials/9_synchrotron_radiation.ipynb screen_3d = Screen() screen_3d.z = 50.0 # distance from the begining of lattice to the screen screen_3d.size_x = 0.0015 # half of screen size in [m] in horizontal plane