PLaSK library
Loading...
Searching...
No Matches
slab2d.py
Go to the documentation of this file.
1#!/home/maciek/Dokumenty/PLaSK/tests/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 = 'xy'
16
17import optical
18
19wn = 1.2
20wa = 2.0 - wn
21h = 0.10
22
23# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
24
25symmetric = True
26periodic = True
27
28size = 16
29refine = 8
30
31smooth = 0#.01
32
33ft = 'analytic'
34#ft = 'discrete'
35
36dct = 2
37
38# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
39
40
41@plask.material.simple()
42class Glass(plask.material.Material):
43 def nr(self, w, T=300., n=0.):
44 return 1.3
45
46@plask.material.simple()
47class Asym(plask.material.Material):
48 def nr(self, w, T=300., n=0.):
49 return 1.1
50
51shelf = geometry.Shelf2D()
52if symmetric:
53 stack = geometry.Stack2D(left=0)
54else:
55 stack = geometry.Stack2D(xcenter=0)
56
57core = geometry.Block2D(wn, h, Glass())
58air = geometry.Block2D(wa, h, material.air)
59
60if not symmetric:
61 shelf.append(air)
62 shelf.append(core)
63 shelf.append(core)
64 shelf.append(air)
65else:
66 shelf.append(core)
67 shelf.append(air)
68
69stack.append(shelf)
70p = stack.append(shelf)
71
72if periodic:
73 if symmetric:
74 main = geometry.Cartesian2D(stack, left='mirror', right='periodic')
75 else:
76 main = geometry.Cartesian2D(stack, left='periodic', right='periodic')
77else:
78 if symmetric:
79 main = geometry.Cartesian2D(stack, left='mirror', right='extend')
80 else:
81 main = geometry.Cartesian2D(stack, right='extend')
82
83opt = optical.Fourier2D("opt")
84opt.geometry = main
85opt.wavelength = 980.
86opt.smooth = smooth
87opt.size = size
88opt.refine = refine
89
90opt.dct = dct
91opt.ft = ft
92
93opt.set_interface(shelf, p)
94
95opt.pml.dist = 0.
96opt.pml.order = 1
97opt.pml.factor = 1-2j
98
99right = 3.5
100left = -3.5
101
102if symmetric is True:
103 opt.symmetry = 'Ex'
104
105#XX = linspace(left, right, 10)
106XX = linspace(left, right, 24000)
107
108msh = mesh.Rectangular2D(XX, [0.5*h])
109
110for i in range(-4, 5):
111 axvline((wn+wa)*i, color='0.75')
112
113eps = [main.get_material(x, 0.5*h).nr(opt.wavelength.real).real**2 for x in XX]
114plot(XX, eps, '--k')
115
116eps = opt.outEpsilon(msh)
117plot(XX, eps.array[:,0,0,0].real, 'g')
118plot(XX, eps.array[:,0,1,1].real, 'r', label='Fourier')
119
120
121
122xlim(XX[0], XX[-1])
123ylim(0.95, 1.35)
124
125#legend(loc='best')
126
127tight_layout()
128
129#import os
130#if os.getcwd().split(os.sep)[-2] == 'plask':
131 #title = "Old symmetric method"
132#else:
133 #title = "New symmetric method"
134#gcf().canvas.set_window_title(title)
135gcf().canvas.set_window_title("%s %s %s" % ('Symmetric' if symmetric else 'Asymmetric', 'periodic' if periodic else '', ft))
136
137del opt
138
139show()