PLaSK library
Loading...
Searching...
No Matches
loading.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
@material.simple()
17
class
LowContrastMaterial
(material.Material):
18
def
Nr
(self, wl, T):
return
1.3
19
20
class
EffectiveIndex2D_Test
(unittest.TestCase):
21
22
def
setUp
(self):
23
self.
manager
= Manager()
24
self.
manager
.load(
"""
25
<plask>
26
<geometry>
27
<cartesian2d name="Space-1" axes="xy">
28
<stack name="Stack-2">
29
<item path="Path-4"><rectangle name="Block-3" dx="5" dy="2" material="GaN" /></item>
30
<again ref="Block-3"/>
31
</stack>
32
</cartesian2d>
33
</geometry>
34
<grids>
35
<mesh type="rectangular2d" name="lin">
36
<axis0>1, 2, 3</axis0>
37
<axis1>10 20 30</axis1>
38
</mesh>
39
<generator type="rectangular2d" method="divide" name="div">
40
<prediv by="4"/>
41
<postdiv by0="2" by1="3"/>
42
</generator>
43
</grids>
44
<solvers>
45
<optical lib="effective" solver="EffectiveIndex2D" name="eff1">
46
<geometry ref="Space-1"/>
47
<mesh ref="lin"/>
48
<mode polarization="TM"/>
49
<root tolx="0.1"/>
50
</optical>
51
<optical solver="EffectiveIndex2D" name="eff2">
52
<geometry ref="Space-1"/>
53
<mesh ref="div"/>
54
</optical>
55
</solvers>
56
</plask>
57
"""
)
58
self.
solver1
= self.
manager
.solvers.eff1
59
self.
solver2
= self.
manager
.solvers.eff2
60
profile = plask.StepProfile(self.
manager
.geo.Space_1, default=300.)
61
profile[self.
manager
.geo.Block_3] = 320.
62
self.
solver1
.inTemperature = profile.outTemperature
63
64
def
testLoadConfigurations
(self):
65
self.assertEqual(self.
solver1
.id,
"eff1:optical.EffectiveIndex2D"
)
66
67
self.assertEqual(self.
solver1
.geometry, self.
manager
.geo.Space_1)
68
self.assertEqual(self.
solver2
.geometry.item, self.
manager
.geo.Stack_2)
69
70
self.assertEqual(self.
solver1
.mesh, self.
manager
.msh.lin)
71
self.assertEqual(self.
solver2
.mesh, self.
manager
.msg.div(self.
manager
.geo.Space_1.item))
72
73
self.assertEqual(self.
solver1
.polarization,
"TM"
)
74
self.assertEqual(self.
solver1
.root.tolx, 0.1)
75
76
77
def
testProfile
(self):
78
m = plask.mesh.Rectangular2D(plask.mesh.Regular(1.,), plask.mesh.Regular(1., 5., 2))
79
print(list(m))
80
print(self.
manager
.geo.Space_1.get_leafs_bboxes())
81
self.assertEqual(list(self.
solver1
.inTemperature(m)), [320., 300.])
solvers
optical
effective
tests
loading.py
Generated by
1.9.8