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

From version 9.1
edited by sndueste
on 2020/07/07 16:55
Change comment: There is no comment for this version
To version 3.1
edited by sendels
on 2019/08/23 08:24
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.sndueste
1 +XWiki.sendels
Content
... ... @@ -1,99 +1,18 @@
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.
1 +Here you can find a small python script (by (% class="twikiNewLink" %)[[MartinB>>url:http://hasfweb.desy.de/bin/edit/Setup/MartinB?topicparent=Setup.PartialCoherenceSimulation;nowysiwyg=0||rel="nofollow" shape="rect"]](%%)) implementing the partial coherence methode as described in Thomas Pfeifer, Yuhai Jiang, Stefan Düsterer, Robert Moshammer, and Joachim Ullrich, 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"]]
2 +\\\\Simulations like this:
2 2  
3 -The only input parameters are the center wavelength, spectral bandwidth and the pulse duration.
4 +[[image:attach:partia__coherence2.png]]
4 4  
5 -Here you can find a small python script (by (% class="twikiNewLink" %)MartinB(%%)) implementing the partial coherence method as described in:
6 -
7 -* **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 -
9 9  \\
10 10  
11 -The pulse shapes in time AND corresponding spectral distribution can be easily created with:
12 -
13 -* (((
14 -a python script
15 -
16 -{{expand title="Click here to expand the script ..."}}
17 -import numpy as np
18 -import matplotlib.pyplot as plt
19 -
20 -def GetSASE(CentralEnergy, dE_FWHM, dt_FWHM, samples=0, Axis=True):
21 -h=4.135667662 #in eV*fs
22 -dE=dE_FWHM/2.355 #in eV, converts to sigma
23 -dt=dt_FWHM/2.355 #in fs, converts to sigma
24 -if samples == 0:
25 -samples=int(400.*dt*CentralEnergy/h)
26 -else:
27 -if (samples < 400.*dt*CentralEnergy/h):
28 -print("Number of samples is a little small, proceeding anyway. Got", samples, "prefer more than",400.*dt*CentralEnergy/h)
29 -
30 -EnAxis=np.linspace(0.,20.*CentralEnergy,num=samples)
31 -EnInput=np.zeros(samples, dtype=np.complex64)
32 -EnInput=np.exp(-(EnAxis-CentralEnergy)~*~*2/2./dE~*~*2+2*np.pi*1j*np.random.random(size=samples))
33 -En_FFT=np.fft.fft(EnInput)
34 -TAxis=np.fft.fftfreq(samples,d=(20.*CentralEnergy)/samples)*h
35 -TOutput=np.exp(-TAxis~*~*2/2./dt~*~*2)*En_FFT
36 -EnOutput=np.fft.ifft(TOutput)
37 -if (Axis):
38 -return EnAxis, EnOutput, TAxis, TOutput
39 -else:
40 -return EnOutput, TOutput
41 -
42 42  \\
43 43  
44 -# set the main parameters here:
45 -CentralEnergy=80. # in eV
46 -bandwidth=0.5 # bandwidth in %
47 -dt_FWHM=30. # FWHM of the temporal duration on average
48 48  
49 -dE_FWHM=CentralEnergy/100 *bandwidth # calculate bandwidth of the spectrum in eV
11 +
12 +\\can be easily created with the script ( the script can be downloaded in the attachment table below):
50 50  
51 -# calculate 3 SASE pulses
52 -EnAxis, EnOutput, TAxis, TOutput = GetSASE(CentralEnergy=CentralEnergy, dE_FWHM=dE_FWHM, dt_FWHM=dt_FWHM)
53 -EnAxis2, EnOutput2, TAxis2, TOutput2 = GetSASE(CentralEnergy=CentralEnergy, dE_FWHM=dE_FWHM, dt_FWHM=dt_FWHM)
54 -EnAxis3, EnOutput3, TAxis3, TOutput3 = GetSASE(CentralEnergy=CentralEnergy, dE_FWHM=dE_FWHM, dt_FWHM=dt_FWHM)
55 -
56 -
57 -# plot spectrum
58 -ax1 = plt.subplot(1, 2, 1)
59 -plt.plot(EnAxis,np.absolute(EnOutput),EnAxis2,np.absolute(EnOutput2),EnAxis3,np.absolute(EnOutput3) )
60 -plt.xlim(CentralEnergy-2.*dE_FWHM,CentralEnergy+2.*dE_FWHM)
61 -plt.title('Average pulse duration: %.1f fs' % dt_FWHM )
62 -ax1.set_xlabel('Photon energy in eV')
63 -ax1.set_ylabel('spectral intensity')
64 -
65 -# plot time structure
66 -ax1 =plt.subplot(1, 2, 2)
67 -plt.plot(TAxis,np.absolute(TOutput),TAxis2,np.absolute(TOutput2), TAxis3,np.absolute(TOutput3))
68 -plt.xlim(-2.*dt_FWHM,+2.*dt_FWHM)
69 -ax1.set_xlabel('time in fs')
70 -ax1.set_ylabel('pulse amplitude')
71 -
72 -plt.show()
73 -{{/expand}}
74 -)))
75 -* or the same as a Jupyter Notebook** [[attach:GenerateSASE.ipynb]] **
76 -
77 -==
78 -Some examples: ==
79 -
80 -//CentralEnergy=80 # in eV//
81 -
82 -//bandwidth=0.5 # bandwidth in %//
83 -
84 -//dt_FWHM=10, 30., 70  # FWHM of the temporal duration on average//
85 -
86 -
87 -
88 -
89 - [[image:attach:2020-07-07 16_51_14-Window.png||height="250"]]
90 -
91 91  \\
92 92  
93 -[[image:attach:2020-07-07 16_53_22-Window.png||height="250"]]
94 -
95 -[[image:attach:2020-07-07 16_52_27-Window.png||height="250"]]
96 -
97 97  \\
98 98  
99 99  \\
... ... @@ -100,12 +100,10 @@
100 100  
101 101  \\
102 102  
103 -\\
22 +[[image:attach:partia__coherence1.png]]
104 104  
105 105  \\
106 106  
107 -\\
26 +[[attach:SASEPulseGenV2.ipynb]]
108 108  
109 -\\
110 -
111 -\\
28 +Jupyter Notebook