forked from alexysong/inkstone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphc_slab_circ_hole_fields.py
50 lines (38 loc) · 1.22 KB
/
phc_slab_circ_hole_fields.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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
A photonic-crystal slab in vacuum. Permittivity 12.
Square lattice with period 1 in both x and y.
thickness 0.5
A circular hole of radius 0.2 in each unit cell.
→ y
↓x ⋮
◯ ◯ ◯
... ◯ ◯ ◯ ... (top view)
◯ ◯ ◯
⋮
"""
import numpy as np
from inkstone import Inkstone
s = Inkstone()
s.lattice = ((1, 0), (0, 1))
s.num_g = 100
s.AddMaterial(name='di', epsilon=12)
s.AddLayer(name='in', thickness=0, material_background='vacuum')
s.AddLayer(name='slab', thickness=0.5, material_background='di')
s.AddLayerCopy(name='out', original_layer='in', thickness=0)
s.AddPatternDisk(layer='slab', pattern_name='disk', material='vacuum', radius=0.2)
# Incident wave
s.SetExcitation(theta=0, phi=0, s_amplitude=0, p_amplitude=1)
s.frequency = 0.38
Ex, Ey, Ez, Hx, Hy, Hz = s.GetFields(xmin=-0.5, xmax=0.5, nx=101,
y=0,
zmin=-0.2, zmax=0.7, nz=91)
#%% plotting
from matplotlib import pyplot as plt
plt.pcolormesh(np.linspace(-0.5, 0.5, 101),
np.linspace(-0.2, 0.7, 91),
np.abs(Ex[0, :, :]).T, shading='gouraud')
plt.xlabel('x')
plt.ylabel('z')
plt.colorbar()