-
Notifications
You must be signed in to change notification settings - Fork 11
/
full_RT_parallelisetest.py
117 lines (90 loc) · 2.92 KB
/
full_RT_parallelisetest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
from rayflare.ray_tracing import rt_structure
from rayflare.textures import regular_pyramids, planar_surface
from rayflare.options import default_options
from rayflare.transfer_matrix_method import tmm_structure
from solcore.structure import Layer
from solcore import material
from solcore import si
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from cycler import cycler
pal = sns.cubehelix_palette(7, start=0.5, rot=-0.9)
cols = cycler("color", pal)
plt.rcParams["axes.prop_cycle"] = cols
Air = material("Air")()
Si = material("Si")()
GaAs = material("GaAs")()
Ge = material("Ge")()
flat_surf = planar_surface()
triangle_surf = regular_pyramids(30)
options = default_options()
options.wavelengths = np.linspace(700, 1800, 7) * 1e-9
options.theta_in = 45 * np.pi / 180
options.nx = 5
options.ny = 5
options.pol = "p"
options.n_rays = 2000
options.depth_spacing = 1e-6
rtstr = rt_structure(
textures=[triangle_surf, triangle_surf, triangle_surf, triangle_surf],
materials=[GaAs, Si, Ge],
widths=[si("100um"), si("70um"), si("50um")],
incidence=Air,
transmission=Air,
)
result_new = rtstr.calculate(options)
result = result_new
plt.figure()
plt.plot(options["wavelengths"] * 1e9, result["R"])
plt.plot(options["wavelengths"] * 1e9, result["T"])
plt.plot(options["wavelengths"] * 1e9, result["A_per_layer"])
plt.plot(
options["wavelengths"] * 1e9,
result["R"] + result["T"] + np.sum(result["A_per_layer"], 1),
"g",
)
plt.plot(options["wavelengths"] * 1e9, result["R0"], "--")
plt.legend(["R", "T", "L1", "L2", "L3", "tot", "R0"])
plt.show()
plt.figure()
plt.plot(result["profile"].T)
plt.show()
options.parallel = False
rtstr = rt_structure(
textures=[triangle_surf, triangle_surf, triangle_surf, triangle_surf],
materials=[GaAs, Si, Ge],
widths=[si("100um"), si("70um"), si("50um")],
incidence=Air,
transmission=Air,
)
result_old = rtstr.calculate(options)
result = result_old
plt.figure()
plt.plot(options["wavelengths"] * 1e9, result["R"])
plt.plot(options["wavelengths"] * 1e9, result["T"])
plt.plot(options["wavelengths"] * 1e9, result["A_per_layer"])
plt.plot(
options["wavelengths"] * 1e9,
result["R"] + result["T"] + np.sum(result["A_per_layer"], 1),
"g",
)
plt.plot(options["wavelengths"] * 1e9, result["R0"])
plt.legend(["R", "T", "L1", "L2", "L3", "tot", "R0"])
plt.show()
plt.figure()
plt.plot(result["profile"].T)
plt.show()
stack = [Layer(si("100um"), GaAs), Layer(si("70um"), Si), Layer(si("50um"), Ge)]
strt = tmm_structure(stack, incidence=Air, transmission=Air, no_back_reflection=False)
output = strt.calculate(options, profile=True, layers=[1, 2, 3])
plt.figure()
plt.plot(options["wavelengths"] * 1e9, output["R"])
plt.plot(options["wavelengths"] * 1e9, output["T"])
plt.plot(options["wavelengths"] * 1e9, output["A_per_layer"])
plt.legend(["R", "T", "L1", "L2", "L3"])
plt.ylim(0, 1)
plt.show()
plt.figure()
plt.plot(output["profile"].T)
plt.show()