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 09b389e

Browse files
committed
All working fine. One launch takes approx. 0.65s
1 parent ced685b commit 09b389e

File tree

5 files changed

+3176
-23
lines changed

5 files changed

+3176
-23
lines changed

‎dbr.py‎

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,54 +18,61 @@ def __init__(self, data, incidentwavelength):
1818
def reflection_coeff(self, incidentwavelength):
1919
nm = (self.n[:-1] / self.n[1:])
2020
r = np.empty(incidentwavelength.size) + 0j
21-
i=0
22-
for wavelength in incidentwavelength:
23-
phi = 2j * np.pi * self.n[:-1] * self.d[:-1] / wavelength
21+
22+
for i in range(0, incidentwavelength.shape[0]):
23+
phi = 2j * np.pi * self.n[1:] * self.d[1:] / wavelength[i]
2424
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)]])
25+
[0.5 * (1 - nm) * np.exp(-phi), 0.5 * (1 + nm) * np.exp(phi)]])
2626

27-
general_transition_matrix = 1
28-
for k in range(self.n.size-2, -1, -1):
27+
general_transition_matrix = np.eye(2, dtype=complex)
28+
for k in range(0, transition_matrix.shape[2]):
2929
general_transition_matrix = np.dot(general_transition_matrix, transition_matrix[:, :, k])
3030

3131
r[i] = - general_transition_matrix.item(2) / general_transition_matrix.item(3)
32-
i += 1
3332
return r
3433

3534
def diff_omega(self, y, incidentwavelength):
36-
c = 29.9792458 # in nm/fs
35+
c = 299.792458 # in nm/fs
3736
return (-incidentwavelength ** 2 / (2 * np.pi * c)) * np.gradient(y, incidentwavelength)
3837

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
48-
4938

5039
start = timeit.default_timer()
5140
wavelength = np.linspace(800, 1200, 1000)
5241
NewMirror = DBRMirror("dbr.txt", wavelength)
5342

5443
stop = timeit.default_timer()
5544
print(stop - start)
45+
sR = np.loadtxt("s245-R.txt", unpack=True)
46+
sGD = np.loadtxt("s245-GD.txt", unpack=True)
47+
sGDD = np.loadtxt("s245-GDD.txt", unpack=True)
48+
5649

57-
pl.figure()
50+
f=pl.figure()
5851
pl.plot(wavelength, NewMirror.R)
52+
pl.plot(*sR)
5953
pl.xlabel("$\lambda$")
6054
pl.ylabel("R")
61-
pl.xlim((950,1150))
55+
pl.xlim(950,1150)
6256
pl.show(block=False)
57+
f.canvas.set_window_title("R")
6358

64-
pl.figure()
59+
f = pl.figure()
60+
pl.plot(wavelength, NewMirror.GD)
61+
pl.plot(*sGD)
62+
pl.xlabel("$\lambda$")
63+
pl.ylabel("GD [fs]")
64+
pl.xlim(950, 1150)
65+
f.canvas.set_window_title("GD")
66+
67+
f = pl.figure()
6568
pl.plot(wavelength, NewMirror.GDD)
69+
pl.plot(*sGDD)
6670
pl.xlabel("$\lambda$")
67-
pl.ylabel("GDD [fs**2]")
68-
pl.xlim((1000,1080))
71+
pl.ylabel("GDD [fs$^2$]")
72+
pl.xlim(1000, 1080)
73+
pl.ylim(-1000, 0)
74+
f.canvas.set_window_title("GDD")
75+
6976
pl.show()
7077

7178

0 commit comments

Comments
(0)

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