-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy path1d_dielectric_array_spectrum.py
55 lines (44 loc) · 1.14 KB
/
1d_dielectric_array_spectrum.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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
Dielectric array, with permittivity 12.
Period is 1
Each rod has side length 0.55.
→ x
↓z ___ ___
... | | | | ... (side view)
¯¯¯ ¯¯¯
"""
from inkstone import Inkstone
import numpy as np
s = Inkstone()
s.lattice = 1
s.num_g = 30
s.AddMaterial(name='di', epsilon=12)
s.AddLayer(name='in', thickness=0, material_background='vacuum')
d = 0.55
s.AddLayer(name='slab', thickness=d, material_background='di')
s.AddLayerCopy(name='out', original_layer='in', thickness=0)
s.AddPattern1D(layer='slab', pattern_name='box', material='vacuum', width=0.45, center=0.5)
s.SetExcitation(theta=0, phi=0, s_amplitude=1, p_amplitude=0)
I = []
R = []
T = []
freq = np.linspace(0.2, 0.9, 201)
for f in freq:
s.frequency = f
i, r = s.GetPowerFlux('in')
I.append(i)
R.append(-r / i)
T.append(s.GetPowerFlux('out')[0] / i)
print("frequency: {:g}".format(f))
#%% plotting
from matplotlib import pyplot as plt
plt.figure()
plt.plot(freq, R)
plt.xlabel('frequency')
plt.ylabel('reflection')
plt.figure()
plt.plot(freq, T)
plt.xlabel('frequency')
plt.ylabel('transmission')