PLaSK library

Loading...
Searching...
No Matches
slab3d.py
Go to the documentation of this file.
1#!/home/maciek/Dokumenty/PLaSK/plask/build/bin/plask
2# This file is part of PLaSK (https://plask.app) by Photonics Group at TUL
3# Copyright (c) 2022 Lodz University of Technology
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, version 3.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13
14
15config.axes = 'xyz'
16
17 import optical
18
19depth = 1.0
20
21w = 0.20
22wa = 0.10
23h = 0.10
24
25d = 0.
26
27# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
28
29axis = 0
30
31symmetric = True
32periodic = False
33
34size = 12
35refine = 1
36
37smooth = 0.005
38
39dct = 1
40
41# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
42
43
44@plask.material.simple()
45 class Glass(plask.material.Material):
46 def nr(self, w, T=300., n=0.):
47 return 1.3
48
49@plask.material.simple()
50 class Asym(plask.material.Material):
51 def nr(self, w, T=300., n=0.):
52 return 1.1
53
54
55 def dims(w, h):
56 if axis == 0: return vec(w, depth, h)
57 elif axis == 1: return vec(depth, w, h)
58 raise ValueError("wrong axis")
59
60 def pos(w, z=0):
61 if axis == 0: return vec(w, 0, z)
62 elif axis == 1: return vec(0, w, z)
63 raise ValueError("wrong axis")
64
65
66shelf = geometry.Align3D()
67
68 if symmetric:
69 stack = geometry.Stack3D(left=0, back=0)
70 else:
71 stack = geometry.Stack3D(xcenter=0, ycenter=0)
72
73core = geometry.Block3D(dims(w, h), Glass())
74asym = geometry.Block3D(dims(wa, h), material.air)
75air = geometry.Block3D(dims(w, h), material.air)
76
77air1 = geometry.Block3D(dims(w-d, h), material.air)
78air2 = geometry.Block3D(dims(w+d, h), material.air)
79
80 if not symmetric:
81 shelf.append(air1, pos(-2*w-d))
82 shelf.append(core, pos(-w))
83 shelf.append(core, pos(0))
84 shelf.append(air2, pos(w))
85 else:
86 shelf.append(core, pos(0))
87 shelf.append(air, pos(w))
88
89stack.append(shelf)
90p = stack.append(shelf)
91
92
93edges = dict(left='periodic', right='periodic', back='periodic', front='periodic')
94b0, b1 = (('back', 'front'), ('left', 'right'))[axis]
95 if not periodic: edges[b0] = edges[b1] = None
96 if symmetric: edges[b0] = 'mirror'
97
98main = geometry.Cartesian3D(stack, **edges)
99
100opt = optical.Fourier3D("opt")
101opt.geometry = main
102opt.wavelength = 980.
103opt.smooth = 0.00025
104opt.size = 0
105opt.size[axis] = size
106opt.smooth = smooth
107opt.refine = refine
108
109opt.dct = dct
110
111opt.set_interface(shelf, p)
112
113opt.pmls.tran.dist = 0.5
114opt.pmls.tran.size = 0.5
115opt.pmls.tran.order = 1
116opt.pmls.tran.factor = 1-2j
117
118opt.pmls.long = opt.pmls.tran
119
120 if symmetric:
121 sym = [None, None]
122 sym[axis] = 'Ex'
123 opt.symmetry = sym
124
125right = 2.0
126left = -2.0
127
128#AX = linspace(left, right, 10)
129AX = linspace(left, right, 4000)
130
131 if axis == 0:
132 msh = mesh.Rectangular3D(AX, [0], [0.5*h])
133 elif axis == 1:
134 msh = mesh.Rectangular3D([0], AX, [0.5*h])
135 else:
136 raise ValueError("wrong axis")
137
138eps = [main.get_material(pos(ax, 0.5*h)).nr(opt.wavelength.real).real**2 for ax in AX]
139plot(AX, eps, '--k')
140
141eps = opt.outEpsilon(msh, 'fourier')
142plot(AX, eps.array[:,:,0,2,2].ravel().real, 'r', label='Fourier')
143
144 if axis == 0:
145 msh = mesh.Rectangular3D(AX, [0], [0.5*h])
146 elif axis == 1:
147 msh = mesh.Rectangular3D([0], AX, [0.5*h])
148
149xlim(AX[0], AX[-1])
150#ylim(0.95, 1.35)
151
152#legend(loc='best')
153
154tight_layout()
155
156#import os
157#if os.getcwd().split(os.sep)[-2] == 'plask':
158 #title = "Old symmetric method"
159#else:
160 #title = "New symmetric method"
161#gcf().canvas.set_window_title(title)
162gcf().canvas.set_window_title("%s %s" % ('Symmetric' if symmetric else 'Asymmetric', 'periodic' if periodic else ''))
163
164del opt
165
166show()