-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathanalysis_multiple_simul.py
More file actions
191 lines (146 loc) · 5.92 KB
/
Copy pathanalysis_multiple_simul.py
File metadata and controls
191 lines (146 loc) · 5.92 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
"""
analysis_multiple_simul.py
Post-processing of multiple cold atom simulations.
Generates plots of capture fraction vs. time and
radial density distributions at the fiber tip,
for different MOT temperatures and displacements.
Author: [Leonardo Razzai]
"""
from analysis import *
from matplotlib import colormaps
import numpy as np
import matplotlib.pyplot as plt
import os
from Beams import beams
from sys import argv
# Select Beam
if len(argv) > 1:
beam_name = argv[1]
else:
print('\nSpecify a valid beam name:\nGauss : Gaussian beam\nLG : Laguerre-Gauss beam\n\n')
exit()
if beam_name not in ['Gauss', 'LG']:
print('\nSpecify a valid beam name:\nGauss : Gaussian beam\nLG : Laguerre-Gauss beam\n\n')
exit()
beam = beams[beam_name]
# Output folder for figures
img_folder = './img/'
os.makedirs(img_folder, exist_ok=True)
os.makedirs(img_folder + f'/{beam_name}/', exist_ok=True)
# Parameter ranges
T_range = np.arange(start=5, stop=50, step=5) # MOT temperature in μK
dMOT_range = np.arange(start=2, stop=18, step=2) # MOT displacement in mm
out_folder = img_folder + beam_name +'/'
os.makedirs(out_folder, exist_ok=True)
# --- 1. Capture fraction vs. time at fixed dMOT, varying T ---
cmap = colormaps.get_cmap('inferno')
colors = [cmap(x) for x in np.linspace(0.1, 0.8, 2)]
def plot_3d_TdMOTconc():
# Create meshgrid
T_array, dMOT_array = np.meshgrid(T_range, dMOT_range)
# Allocate Z with same shape
Z = np.zeros_like(T_array, dtype=float)
# Fill Z with function values
for i in range(T_array.shape[0]):
for j in range(T_array.shape[1]):
Z[i, j] = get_frac(T_array[i, j], dMOT_array[i, j], steps=np.array([-1]), beam=beam)
Z = Z * 100 # in %
# Plot
fig = plt.figure(figsize=(8,6))
ax = fig.add_subplot(111, projection='3d')
surf = ax.plot_surface(T_array, dMOT_array, Z, cmap='viridis', edgecolor='none')
ax.set_xlabel("Temperature (µK)")
ax.set_ylabel("MOT distance (mm)")
ax.set_zlabel("Captured atoms (%)")
ax.set_title(f"Atom Capture Efficiency vs T and dMOT ({beam.name})")
#fig.colorbar(surf, shrink=0.5, aspect=10, label="Captured atoms (%)")
plt.tight_layout()
plt.savefig(out_folder + f'conc_vs_T-dMOT.jpg')
plt.clf()
def plot_cap_frac_vs_T(T_range, dMOT_range):
"""
Plot capture fraction vs. time for fixed dMOT and varying T.
Saves one plot per dMOT.
"""
cmap = colormaps.get_cmap('inferno')
colors = [cmap(x) for x in np.linspace(0.1, 0.8, 2)]
small_T_range = [T_range.min(), T_range.max()]
small_dMOT_range = [dMOT_range.min(), dMOT_range.max()]
for dMOT in small_dMOT_range:
for i, T in enumerate(small_T_range):
label = f'T = {T} μK, dMOT = {dMOT} mm'
print(label)
ts, f_cap = capt_frac_vs_t(T, dMOT, beam=beam)
plot_cap_frac(ts, f_cap, label=label, color=colors[i])
plt.legend()
plt.title(f'Captured Faction vs T ({beam.name})')
plt.tight_layout()
plt.savefig(out_folder + f'cap_frac_dMOT={dMOT}mm.jpg')
plt.clf()
def plot_density_vs_T(T_range, dMOT_range):
"""
Plot radial density distribution at fiber for fixed dMOT and varying T.
Saves one plot per dMOT.
"""
cmap = colormaps.get_cmap('inferno')
colors = [cmap(x) for x in np.linspace(0.1, 0.8, 2)]
small_T_range = [T_range.min(), T_range.max()]
small_dMOT_range = [dMOT_range.min(), dMOT_range.max()]
for dMOT in small_dMOT_range:
for i, T in enumerate(small_T_range):
label = f'T = {T} μK, dMOT = {dMOT} mm'
print(label)
hist_rho_step, _ = density_at_fib(step=-1, T=T, dMOT=dMOT, beam=beam)
plot_density_at_fib(hist_rho_step=hist_rho_step, label=label, color=colors[i])
plt.legend()
plt.title(f'Radial density vs T ({beam.name})')
plt.tight_layout()
plt.savefig(out_folder + f'density_at_fib_dMOT={dMOT}mm.jpg')
plt.clf()
def plot_cap_frac_vs_dMOT(T_range, dMOT_range):
"""
Plot capture fraction vs. time for fixed T and varying dMOT.
Saves one plot per T.
"""
cmap = colormaps.get_cmap('YlGnBu')
colors = [cmap(x) for x in np.linspace(0.3, 0.7, 2)]
small_T_range = [T_range.min(), T_range.max()]
small_dMOT_range = [dMOT_range.min(), dMOT_range.max()]
for T in small_T_range:
for i, dMOT in enumerate(small_dMOT_range):
label = f'T = {T} μK, dMOT = {dMOT} mm'
print(label)
ts, f_cap = capt_frac_vs_t(T, dMOT, beam=beam)
plot_cap_frac(ts, f_cap, label=label, color=colors[i])
plt.legend()
plt.title(f'Captured Faction vs dMOT ({beam.name})')
plt.tight_layout()
plt.savefig(out_folder + f'cap_frac_T={T}uK.jpg')
plt.clf()
def plot_density_vs_dMOT(T_range, dMOT_range):
"""
Plot radial density distribution at fiber for fixed T and varying dMOT.
Saves one plot per T.
"""
cmap = colormaps.get_cmap('YlGnBu')
colors = [cmap(x) for x in np.linspace(0.3, 0.7, 2)]
small_T_range = [T_range.min(), T_range.max()]
small_dMOT_range = [dMOT_range.min(), dMOT_range.max()]
for T in small_T_range:
for i, dMOT in enumerate(small_dMOT_range):
label = f'T = {T} μK, dMOT = {dMOT} mm'
print(label)
hist_rho_step, _ = density_at_fib(step=-1, T=T, dMOT=dMOT, beam=beam)
plot_density_at_fib(hist_rho_step=hist_rho_step, label=label, color=colors[i])
plt.legend()
plt.title(f'Radial density vs dMOT ({beam.name})')
plt.tight_layout()
plt.savefig(out_folder + f'density_at_fib_T={T}uK.jpg')
plt.clf()
if __name__ == "__main__":
print(f'Analysis {beam.name} Beam.\nSaving imgs to {out_folder}\n\n')
plot_cap_frac_vs_T(T_range, dMOT_range)
plot_density_vs_T(T_range, dMOT_range)
plot_cap_frac_vs_dMOT(T_range, dMOT_range)
plot_density_vs_dMOT(T_range, dMOT_range)
plot_3d_TdMOTconc()