Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ced685b

Browse files
committed
GDD calculation algorithm rewritten, but still can't achieve the given example. The differentiation has be tested both with prebuilt procedure and with code written form scratch.
R is calculated correctly
1 parent 0e41f1b commit ced685b

File tree

2 files changed

+193
-45
lines changed

2 files changed

+193
-45
lines changed

‎dbr.py

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,71 @@
1-
from numpy import*
2-
from pylab import*
1+
import numpy asnp
2+
import pylab aspl
33
import timeit
44
import dbrprop
55

6+
67
class DBRMirror:
7-
def __init__(self, data):
8+
def __init__(self, data, incidentwavelength):
89
if isinstance(data, str):
9-
data = loadtxt(data)
10+
data = np.loadtxt(data)
1011
self.n = data[:, 0]
11-
self.d = array(concatenate(([0], data[1:-1, 1], [0])))
12+
self.d = np.array(np.concatenate(([0], data[1:-1, 1], [0])))
13+
self.r = self.reflection_coeff(incidentwavelength)
14+
self.R = np.abs(self.r)**2
15+
self.GD = (self.r.imag * self.diff_omega(self.r.real, incidentwavelength) - self.r.real * self.diff_omega(self.r.imag, incidentwavelength))/self.R
16+
self.GDD = self.diff_omega(self.GD, incidentwavelength)
1217

1318
def reflection_coeff(self, incidentwavelength):
1419
nm = (self.n[:-1] / self.n[1:])
15-
R = array([])
20+
r = np.empty(incidentwavelength.size) + 0j
21+
i = 0
1622
for wavelength in incidentwavelength:
17-
phi = 2j * pi * self.n[:-1] * self.d[:-1] / wavelength
18-
transition_matrix = array([[0.5 * (1 + nm) * exp(-phi), 0.5 * (1 - nm) * exp(phi)],
19-
[0.5 * (1 - nm) * exp(-phi), 0.5 * (1 + nm) * exp(phi)]])
23+
phi = 2j * np.pi * self.n[:-1] * self.d[:-1] / wavelength
24+
transition_matrix = np.array([[0.5 * (1 + nm) * np.exp(-phi), 0.5 * (1 - nm) * np.exp(phi)],
25+
[0.5 * (1 - nm) * np.exp(-phi), 0.5 * (1 + nm) * np.exp(phi)]])
2026

2127
general_transition_matrix = 1
2228
for k in range(self.n.size - 2, -1, -1):
23-
general_transition_matrix = dot(general_transition_matrix, transition_matrix[:, :, k])
29+
general_transition_matrix = np.dot(general_transition_matrix, transition_matrix[:, :, k])
2430

25-
r = - general_transition_matrix.item(2) / general_transition_matrix.item(3)
26-
# R = append(R, abs(r)**2)
27-
R=append(R, r)
31+
r[i] = - general_transition_matrix.item(2) / general_transition_matrix.item(3)
32+
i+=1
33+
returnr
2834

29-
phi=arctan(imag(R) /real(R))
35+
defdiff_omega(self, y, incidentwavelength):
3036
c = 29.9792458 # in nm/fs
31-
GDD = incidentwavelength ** 2 / (2 * pi * c) * gradient(incidentwavelength ** 2 / (2 * pi * c) * gradient(phi))
32-
return GDD
37+
return (-incidentwavelength ** 2 / (2 * np.pi * c)) * np.gradient(y, incidentwavelength)
3338

39+
# def diff_omega(self, y, incidentwavelength):
40+
# res = np.zeros_like(y)
41+
# res[1] = ((y[2] - y[1])/(incidentwavelength[2] - incidentwavelength[1]))
42+
# res[-1] = ((y[-1] - y[-2])/(incidentwavelength[-1] - incidentwavelength[-2]))
43+
# for n in range (2, y.__len__()-1):
44+
# res[n] = (((y[n] - y[n-1]) / (incidentwavelength[n] - incidentwavelength[n-1]))
45+
# + ((y[n+1] - y[n]) / (incidentwavelength[n+1] - incidentwavelength[n])))
46+
# c = 29.9792458 # in nm/fs
47+
# return - incidentwavelength ** 2 / (2 * np.pi * c) * res
3448

35-
start = timeit.default_timer()
3649

37-
# data = array([
38-
# [1.0, inf],
39-
# [3.5, 74.0],
40-
# [3.0, 92.5],
41-
# [3.5, 74.0],
42-
# [3.0, 92.5],
43-
# [3.5, 74.0],
44-
# [3.0, 92.5],
45-
# [3.5, inf]
46-
# ])
50+
start = timeit.default_timer()
51+
wavelength = np.linspace(800, 1200, 1000)
52+
NewMirror = DBRMirror("dbr.txt", wavelength)
4753

48-
New = dbrprop.DBRprop()
49-
NewMirror=DBRMirror(New.data)
54+
stop = timeit.default_timer()
55+
print(stop-start)
5056

51-
wavelength = array(linspace(400, 4000, 1000))
57+
pl.figure()
58+
pl.plot(wavelength, NewMirror.R)
59+
pl.xlabel("$\lambda$")
60+
pl.ylabel("R")
61+
pl.xlim((950,1150))
62+
pl.show(block=False)
5263

53-
gdd = NewMirror.reflection_coeff(wavelength)
64+
pl.figure()
65+
pl.plot(wavelength, NewMirror.GDD)
66+
pl.xlabel("$\lambda$")
67+
pl.ylabel("GDD [fs**2]")
68+
pl.xlim((1000,1080))
69+
pl.show()
5470

55-
stop = timeit.default_timer()
56-
print(stop - start)
5771

58-
plot(wavelength, gdd)
59-
xlabel("$\lambda$")
60-
ylabel("GDD [fs**2]")
61-
show()

‎dbr.txt

Lines changed: 146 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,146 @@
1-
1.0 inf
2-
3.5 74.0
3-
3.0 92.5
4-
3.5 74.0
5-
3.0 92.5
6-
3.5 74.0
7-
3.0 92.5
8-
3.5 inf
1+
3.489 0
2+
2.956 81.1
3+
3.489 58.3
4+
2.956 73.8
5+
3.489 112.5
6+
2.956 68.0
7+
3.489 69.9
8+
2.956 47.0
9+
3.489 135.4
10+
2.956 76.0
11+
3.489 91.8
12+
2.956 61.2
13+
3.489 87.0
14+
2.956 102.2
15+
3.489 88.3
16+
2.956 125.0
17+
3.489 68.7
18+
2.956 124.1
19+
3.489 22.6
20+
2.956 108.3
21+
3.489 83.0
22+
2.956 119.8
23+
3.489 33.1
24+
2.956 135.0
25+
3.489 13.6
26+
2.956 121.8
27+
3.489 40.3
28+
2.956 94.5
29+
3.489 84.8
30+
2.956 101.7
31+
3.489 75.8
32+
2.956 85.8
33+
3.489 71.3
34+
2.956 137.3
35+
3.489 42.4
36+
2.956 124.3
37+
3.489 69.4
38+
2.956 101.3
39+
3.489 89.0
40+
2.956 85.7
41+
3.489 57.6
42+
2.956 109.6
43+
3.489 56.5
44+
2.956 95.3
45+
3.489 80.9
46+
2.956 91.8
47+
3.489 81.6
48+
2.956 79.8
49+
3.489 59.4
50+
2.956 109.9
51+
3.489 81.7
52+
2.956 115.1
53+
3.489 33.3
54+
2.956 69.1
55+
3.489 68.3
56+
2.956 128.9
57+
3.489 44.4
58+
2.956 111.9
59+
3.489 73.2
60+
2.956 69.8
61+
3.489 106.2
62+
2.956 42.9
63+
3.489 90.1
64+
2.956 57.1
65+
3.489 88.3
66+
2.956 69.8
67+
3.489 82.3
68+
2.956 109.5
69+
3.489 60.2
70+
2.956 108.2
71+
3.489 66.5
72+
2.956 95.9
73+
3.489 93.6
74+
2.956 60.7
75+
3.489 92.3
76+
2.956 71.2
77+
3.489 66.6
78+
2.956 106.7
79+
3.489 84.4
80+
2.956 92.7
81+
3.489 65.2
82+
2.956 102.2
83+
3.489 51.5
84+
2.956 112.9
85+
3.489 32.0
86+
2.956 129.3
87+
3.489 65.1
88+
2.956 105.6
89+
3.489 43.4
90+
2.956 112.4
91+
3.489 32.4
92+
2.956 154.3
93+
3.489 43.3
94+
2.956 146.7
95+
3.489 3.9
96+
2.956 124.1
97+
3.489 35.6
98+
2.956 106.3
99+
3.489 37.4
100+
2.956 136.5
101+
3.489 58.9
102+
2.956 115.6
103+
3.489 29.7
104+
2.956 139.7
105+
3.489 9.7
106+
2.956 174.9
107+
3.489 4.0
108+
2.956 177.2
109+
3.489 11.9
110+
2.956 147.2
111+
3.489 40.1
112+
2.956 78.5
113+
3.489 60.6
114+
2.956 107.3
115+
3.489 36.6
116+
2.956 188.9
117+
3.489 4.1
118+
2.956 127.8
119+
3.489 19.6
120+
2.956 127.4
121+
3.489 19.9
122+
2.956 112.3
123+
3.489 45.5
124+
2.956 130.7
125+
3.489 17.2
126+
2.956 175.6
127+
3.489 4.0
128+
2.956 132.9
129+
3.489 15.4
130+
2.956 146.7
131+
3.489 3.9
132+
2.956 154.1
133+
3.489 3.9
134+
2.956 178.1
135+
3.489 4.0
136+
2.956 161.3
137+
3.489 5.8
138+
2.956 146.7
139+
3.489 3.9
140+
2.956 146.3
141+
3.489 4.3
142+
2.640 99.9
143+
2.485 212.3
144+
1.534 171.9
145+
1.000 0
146+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /