Last modified by rangeadm on 2025/04/23 16:13

From version 8.1
edited by sndueste
on 2020/07/06 16:59
Change comment: There is no comment for this version
To version 11.1
edited by cpassow
on 2020/09/22 14:03
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.sndueste
1 +XWiki.cpassow
Content
... ... @@ -1,91 +1,41 @@
1 -In order to simulate the temporal and spectral distribution of SASE pulses there is an easy way based random fluctuations filtered spectraly and temporally.
1 +In order to simulate the temporal and spectral distribution of SASE pulses there is an easy way based random fluctuations filtered spectrally and temporally.
2 2  
3 -The only input parameters are the spectral bandwidth and the pulse duration.
3 +The only input parameters are the center wavelength, spectral bandwidth and the pulse duration.
4 4  
5 -Here you can find a small python script (by (% class="twikiNewLink" %)MartinB(%%)) implementing the partial coherence methode as described in Thomas Pfeifer et al. //Partial-coherence method to model experimental free-electron laser pulse statistics,// Opt. Lett. 35, 3441-3443 (2010); [[link to the paper>>url:http://dx.doi.org/10.1364/OL.35.003441||shape="rect"]]
5 +Below you can find a python implementation (by (% class="twikiNewLink" %)MartinB(%%)) of the partial coherence method as described in:
6 6  
7 -The pulse shapes in time AND corresponding spectral dstribution can be easily created with:
7 +(% style="margin-left: 60.0px;" %)
8 +**Thomas Pfeifer et al. //Partial-coherence method to model experimental free-electron laser pulse statistics,// Opt. Lett. 35, 3441-3443 (2010);** [[link to the paper>>url:http://dx.doi.org/10.1364/OL.35.003441||shape="rect"]]
8 8  
9 -* (((
10 -a python script
10 +==
11 +Examples: ==
11 11  
12 -{{expand title="Click here to expand the script ..."}}
13 -import numpy as np
14 -import matplotlib.pyplot as plt
13 +[![Binder]([[https:~~/~~/mybinder.org/badge_logo.svg>>url:https://mybinder.org/badge_logo.svg||shape="rect"]])]([[https:~~/~~/mybinder.org/v2/git/https%3A%2F%2Fgitlab.desy.de%2Fchristopher.passow%2Fsase-pulses/master?filepath=simulating_SASE_pulses.ipynb>>url:https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.desy.de%2Fchristopher.passow%2Fsase-pulses/master?filepath=simulating_SASE_pulses.ipynb||shape="rect"]])
15 15  
16 -def GetSASE(CentralEnergy, dE_FWHM, dt_FWHM, samples=0, Axis=True):
17 -h=4.135667662 #in eV*fs
18 -dE=dE_FWHM/2.355 #in eV, converts to sigma
19 -dt=dt_FWHM/2.355 #in fs, converts to sigma
20 -if samples == 0:
21 -samples=int(400.*dt*CentralEnergy/h)
22 -else:
23 -if (samples < 400.*dt*CentralEnergy/h):
24 -print("Number of samples is a little small, proceeding anyway. Got", samples, "prefer more than",400.*dt*CentralEnergy/h)
15 +//CentralEnergy=80 # in eV//
25 25  
26 -EnAxis=np.linspace(0.,20.*CentralEnergy,num=samples)
27 -EnInput=np.zeros(samples, dtype=np.complex64)
28 -EnInput=np.exp(-(EnAxis-CentralEnergy)~*~*2/2./dE~*~*2+2*np.pi*1j*np.random.random(size=samples))
29 -En_FFT=np.fft.fft(EnInput)
30 -TAxis=np.fft.fftfreq(samples,d=(20.*CentralEnergy)/samples)*h
31 -TOutput=np.exp(-TAxis~*~*2/2./dt~*~*2)*En_FFT
32 -EnOutput=np.fft.ifft(TOutput)
33 -if (Axis):
34 -return EnAxis, EnOutput, TAxis, TOutput
35 -else:
36 -return EnOutput, TOutput
17 +//bandwidth=0.5 # bandwidth in %//
37 37  
38 -\\
19 +//dt_FWHM=10, 30., 70  # FWHM of the temporal duration on average//
39 39  
40 -# set the main parameters here:
41 -CentralEnergy=80. # in eV
42 -bandwidth=0.5 # bandwidth in %
43 -dt_FWHM=30. # FWHM of the temporal duration on average
44 44  
45 -dE_FWHM=CentralEnergy/100 *bandwidth # calculate bandwidth of the spectrum in eV
22 +
46 46  
47 -# calculate 3 SASE pulses
48 -EnAxis, EnOutput, TAxis, TOutput = GetSASE(CentralEnergy=CentralEnergy, dE_FWHM=dE_FWHM, dt_FWHM=dt_FWHM)
49 -EnAxis2, EnOutput2, TAxis2, TOutput2 = GetSASE(CentralEnergy=CentralEnergy, dE_FWHM=dE_FWHM, dt_FWHM=dt_FWHM)
50 -EnAxis3, EnOutput3, TAxis3, TOutput3 = GetSASE(CentralEnergy=CentralEnergy, dE_FWHM=dE_FWHM, dt_FWHM=dt_FWHM)
24 + [[image:attach:2020-07-07 16_51_14-Window.png||height="250"]]
51 51  
52 -
53 -# plot spectrum
54 -ax1 = plt.subplot(1, 2, 1)
55 -plt.plot(EnAxis,np.absolute(EnOutput),EnAxis2,np.absolute(EnOutput2),EnAxis3,np.absolute(EnOutput3) )
56 -plt.xlim(CentralEnergy-2.*dE_FWHM,CentralEnergy+2.*dE_FWHM)
57 -plt.title('Average pulse duration: %.1f fs' % dt_FWHM )
58 -ax1.set_xlabel('Photon energy in eV')
59 -ax1.set_ylabel('spectral intensity')
60 -
61 -# plot time structure
62 -ax1 =plt.subplot(1, 2, 2)
63 -plt.plot(TAxis,np.absolute(TOutput),TAxis2,np.absolute(TOutput2), TAxis3,np.absolute(TOutput3))
64 -plt.xlim(-2.*dt_FWHM,+2.*dt_FWHM)
65 -ax1.set_xlabel('time in fs')
66 -ax1.set_ylabel('pulse amplitude')
67 -
68 -plt.show()
69 -{{/expand}}
70 -)))
71 -* a Jupyter Notebook** [[attach:GenerateSASE.ipynb]] **
72 -
73 -
74 -Some examples of results:
75 -
76 76  \\
77 77  
78 -[[image:attach:partia__coherence2.png]] or: [[image:attach:image2020-2-5_15-14-4.png||width="480"]]
28 +[[image:attach:2020-07-07 16_53_22-Window.png||height="250"]]
79 79  
80 -\\
30 +[[image:attach:2020-07-07 16_52_27-Window.png||height="250"]]
81 81  
82 82  \\
83 83  
84 84  \\
85 85  
86 -\\
36 +[[attach:GenerateSASE.ipynb]]
87 87  
88 -\\
38 +[[attach:GenerateSASE.py]]
89 89  
90 90  \\
91 91