-
Notifications
You must be signed in to change notification settings - Fork 0
/
manip_pilier.py
152 lines (127 loc) · 4.36 KB
/
manip_pilier.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
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
from pylab import *
import os.path as osp
from matplotlib.widgets import Slider, Button, RadioButtons
from omr import OmR
current_dir = osp.join(osp.dirname(__file__))
if current_dir=='':
current_dir = '.'
#close("pilier")
#figure("pilier")
ax=gca()
N_DET = 3
ax.set_color_cycle([cm.jet(k) for k in linspace(0,1,N_DET)])
pilier = OmR()#0.304)
pilier.set_params(m=25.e-9,
f_mech=4.e6,
q=2e6,
lambda_nm = 1064.,
losses=15.e-6,
transmission_input=30e-6,
transmission_output=1.e-6,
length=150e-6,
i_incident=1000e-6,
temp=1.,
delta_hz=10,
detection_losses=0.0)
pilier.freq = linspace(3.99e6,4.01e6, 1000)
"""
DETS = linspace(0,200e3, N_DET)
extent = [-90, 90, min(pilier.freq), max(pilier.freq)]
for index, delta_hz in enumerate(DETS):
subplot(N_DET,1,index+1)
pilier.delta_hz = delta_hz
img = array([10*log10(abs(pilier.left.output.spectrum_sym(phi))) for phi in linspace(-pi/2,pi/2)])
img = img.T
imshow(img, aspect='auto',origin='lower', extent=extent)
cb = colorbar()
contour(img, levels=[0.], linewidths=3, colors='w', extent=extent)
ylabel('$\Delta/2 \pi$')
cb.set_label('Noise (dB)')
#plot(pilier.freq, len(pilier.freq)*[1.], ':k')
show()
"""
figure('Optimize input coupler', figsize=(14, 10))
ax = gca()
input_transmissions = linspace(1e-6,150e-6, 100)
intra_powers = linspace(0.05, 500, 100)
#pilier.freq = linspace(3.99e6, 4.01e6, 100)
pilier.freq = array([4e6])
pilier.delta_hz = 0
plt.subplots_adjust(left=0.05, bottom=0.4)
axcolor = 'lightgoldenrodyellow'
axfreq = plt.axes([0.25, 0.1, 0.65, 0.03], axisbg=axcolor)
axamp = plt.axes([0.25, 0.15, 0.65, 0.03], axisbg=axcolor)
axtemp = plt.axes([0.25, 0.2, 0.65, 0.03], axisbg=axcolor)
axlength = plt.axes([0.25, 0.25, 0.65, 0.03], axisbg=axcolor)
temp = Slider(axtemp,
'Temp.',
0.,
10.,
valinit=1.,
valfmt='%1.1f K')
slosses = Slider(axfreq,
'losses (ppm)',
1.,
100.0,
valinit=30.,
valfmt='%1.0f ppm')
sdl = Slider(axamp,
'det. losses %',
0.0,
100.0,
valinit=0.,
valfmt='%1.0f')
length = Slider(axlength,
'length',
0.0,
1000.0,
valinit=150.,
valfmt='%1.f $\mum')
for i in (temp, slosses, sdl, length):
i.on_changed(lambda event:button.label.set_text('calculate'))
calcax = plt.axes([0.8, 0.025, 0.1, 0.04])
button = Button(calcax, 'save', color=axcolor, hovercolor='0.975')
#save_ax = plt.axes([0.4, 0.025, 0.1, 0.04])
#button_save = Button(save_ax, 'Save', color=axcolor, hovercolor='0.975')
plt.axes(ax)
save_id = 0
calc_id = 0
def save():
pname = "length=" + str(pilier.length)+ "opt_losses="+str(pilier.losses)+", det_loss=" + str(pilier.detection_losses) + ", temp=" + str(pilier.temp)
savefig(current_dir + '/figures/pilier/' + pname + '.png')
savefig(current_dir + '/figures/pilier/' + pname + '.pdf')
def calc():
ax.clear()
pilier.detection_losses = float(sdl.valtext.get_text().rstrip(''))*1e-2
pilier.losses = float(slosses.valtext.get_text().rstrip(' ppm'))*1e-6
pilier.temp = float(temp.valtext.get_text().rstrip(' K'))
pilier.length = float(length.valtext.get_text().rstrip(' $\mu$m'))*1e-6
img = []
extent = [input_transmissions.min()*1e6, input_transmissions.max()*1e6,intra_powers.min(), intra_powers.max()]
for p in intra_powers:
pilier.i_intra = p
line = []
for t in input_transmissions:
pilier.transmission_input = t
line.append(pilier.left.output.squeezing.min())
#print "argmin", pilier.left.output.squeezing.argmin()
img.append(line)
img = abs(array(img))
label = ax.contour(img, origin='lower', extent=extent)
xlabel("Coupler transmission (ppm)")
ylabel("Intracavity Power (W)")
#title("Optimum squeezing, " + pname)
ax.clabel(label)
show()
#imshow()
## http://matplotlib.org/examples/widgets/slider_demo.html
def clicked(event):
if button.label.get_text()=='calculate':
calc()
button.label.set_text('save')
else:
if button.label.get_text()=='save':
save()
button.label.set_text('calculate')
calc_id = button.on_clicked(clicked)
calc()