-
Notifications
You must be signed in to change notification settings - Fork 0
/
fel_pulse.py
85 lines (74 loc) · 4.45 KB
/
fel_pulse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#fel_pulse.py
#This class uses the random_laser_pulse class from random_pulse.py. The inputs are simplified and there are options to work with atomic units or eVs and fs as input and output.
#inputs:
#units_in - input units, 'si' or 'au'.
#units_out - output units, 'si' or 'au'
#amplitude - height factor of the signal
#freq_spacing_factor - Defines frequency spacing by the formula frequency spacing = freq_spacing_factor*2*pi/pulse_duration. Should be set to at most 0.1. The smaller the more points, but the longer it takes to generate the pulse.
#pulse_duration - width of the FWHM of the average intensity envelope of the time signal. fs in 'si' unit set.
#bandwidth - width of the FWHM of the average intensity envelope of the frequency signal. eV in 'si' unit set.
#central_freq - central frequency of the frequency signal. eV in 'si' unit set
#outputs
#get_time_series (np array) - returns time series of the generated pulse that corresponds with the time domain
#get_time_domain (np array) - returns the time axis
#get_time_spacing (float) - returns spacing between elements of the time domain
#get_time_envelope (np array) - returns the envelope of the time series
#get_freq_series (np array) - returns the frequency series of the generated pulse that corresponds with the frequency domain
#get_freq_domain (np array) - returns the frequency axis
#get_pos_freq_series (np array) - returns the frequency series of the generated pulse that corresponds with the positive frequency domain. The negative frequencies can be ignored during analysis because the negative frequencies are the complex conjugate of the postive frequencies.
#get_pos_freq_domain (np_array) - returns the positive frequency axis
#get_freq_spacing (float) - returns spacing between elements of the frequency domain
import numpy as np
from unitConv import unitConverter
from random_pulse import random_laser_pulse
class fel_pulse():
def __init__(self, units_in = 'si', units_out = 'si', amplitude = 1, freq_spacing_factor = 0.05, pulse_duration = 25, bandwidth = 1, central_freq = 45):
#tu = to use
amp_tu = amplitude
pd_tu = pulse_duration
band_tu = bandwidth
cnfrq_tu = central_freq
self.units_out = units_out
self.unitC = unitConverter()
if units_in == 'au':
pd_tu = self.unitC.au2fs(pd_tu)
amp_tu = amp_tu #units??
band_tu = self.unitC.au2ev(band_tu)
cnfrq_tu = self.unitC.au2ev(cnfrq_tu)
self.rp = random_laser_pulse(amplitude = amp_tu, freq_sample_start = cnfrq_tu - (band_tu*4), freq_sample_end = cnfrq_tu + (band_tu*4), zeros_end = (cnfrq_tu+(band_tu*4)) * 8, freq_spacing_factor = freq_spacing_factor, fel_pulse_duration = pd_tu, envelope_shape = 'gauss', random_mod_function = 'gauss', random_mod_fwhm = band_tu, random_mod_center = cnfrq_tu, normalize = True)
def get_time_series(self):
if self.units_out == 'au':
return self.get_time_series() / np.sqrt(self.unitC.fs2au(1))
return self.rp.get_time_series()
def get_time_envelope(self):
if self.units_out == 'au':
return self.rp.get_time_envelope() / np.sqrt(self.unitC.fs2au(1))
return self.rp.get_time_envelope()
def get_time_domain(self):
if self.units_out == 'au':
return self.unitC.fs2au(self.get_time_domain())
return self.rp.get_time_domain()
def get_freq_series(self):
if self.units_out == 'au':
return self.rp.get_freq_series() / np.sqrt(self.unitC.ev2au(1))
return self.rp.get_freq_series()
def get_freq_domain(self):
if self.units_out == 'au':
return self.unitC.ev2au(self.rp.get_freq_domain())
return self.rp.get_freq_domain()
def get_pos_freq_series(self):
if self.units_out == 'au':
return self.rp.get_pos_freq_series() / np.sqrt(self.unitC.ev2au(1))
return self.rp.get_pos_freq_series()
def get_pos_freq_domain(self):
if self.units_out == 'au':
return self.unitC.ev2au(self.rp.get_pos_freq_domain())
return self.rp.get_pos_freq_domain()
def get_time_spacing(self):
if self.units_out == 'au':
return self.unitC.fs2au(self.rp.get_time_spacing())
return self.rp.get_time_spacing()
def get_freq_spacing(self):
if self.units_out == 'au':
return self.unitC.ev2au(self.rp.get_freq_spacing())
return self.rp.get_freq_spacing()