PLaSK library

Loading...
Searching...
No Matches
reflection2d.py
Go to the documentation of this file.
1#!/usr/bin/env python3
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 import unittest
15
16 from numpy import *
17
18 from plask import *
19 from plask import material, geometry, mesh
20 from optical.modal import Fourier2D
21
22 plask.config.axes = 'xy'
23
24@material.simple()
25 class Core(material.Material):
26 Nr = 3.5
27
28
29 class Reflection2D_Test(unittest.TestCase):
30
31 def setUp(self):
32 self.solver = Fourier2D("fourier2d")
33 rect = geometry.Rectangle(0.5, 0.25, Core())
34 air = geometry.Rectangle(1.5, 0.50, "air")
35 stack = geometry.Stack2D()
36 stack.append(rect)
37 stack.append(rect)
38 shelf = geometry.Shelf()
39 shelf.append(stack)
40 shelf.append(air)
41 space = geometry.Cartesian2D(shelf, left="mirror")
42 self.solver.geometry = space
43 self.solver.set_interface(0.25)
44 self.solver.symmetry = 'Ex'
45 self.solver.size = 32
46 self.solver.smooth = 1e-5
47
48 def testComputations(self):
49 self.solver.wavelength = 1550.
50 #X = linspace(3.00, 3.50, 200)
51 #plot(X, [abs(self.solver.determinant(neff=x)) for x in X])
52 #show()
53 nm = self.solver.find_mode(neff=3.197)
54 if __name__ == '__main__':
55 figure()
56 plot_field(self.solver.outLightMagnitude(nm,
57 mesh.Rectangular2D(mesh.Regular(-0.75, 0.75, 100), mesh.Regular(-0.25, 0.75, 100))))
58 plot_geometry(self.solver.geometry, color='w', mirror=True)
59 show()
60 self.assertAlmostEqual(self.solver.modes[nm].neff, 3.197, 3)
61
62
63 if __name__ == '__main__':
64 unittest.main()