-
Notifications
You must be signed in to change notification settings - Fork 9
/
model_CKEBars.py
149 lines (130 loc) · 6.72 KB
/
model_CKEBars.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import meep_utils, meep_materials
import numpy as np
from meep_utils import in_sphere, in_xslab, in_yslab, in_zslab
"""
"""
class CKEBars_model(meep_utils.AbstractMeepModel): #{{{
""" Array of dielectric bars along the E-field, proposed by Christelle (June 2013) #{{{
FD 2013-06-03
|PMLPMLPML|
^ +---------+ <-- monitor plane 2
| | |
z | | <-- Bloch-periodic boundaries on X, Y faces
| +---+ |
| |XXX| |<------- bar of TiO2
|--+---+--|<-- mylar substrate
|---------|
| | |
x +---------+ <-- monitor plane 1
--> +=========+ <-- source
|PMLPMLPML| #}}}
"""
def cell_centers(self):#{{{
""" Helper function for stacked multilayered metamaterials """
return np.arange(-self.monzd*(self.cells-1)/2, self.monzd*(self.cells-1)/2+1e-12, self.monzd)
## alternatively: adds surrounding two cells!!
#return np.arange(-self.monzd*(self.cells+1)/2, self.monzd*(self.cells+1)/2+1e-12, self.monzd)#}}}
def __init__(self, comment="", simtime=1000e-12, resolution=5e-6, cells=1, monzc=0e-6,
BarWidth=100e-6, BarThick=100e-6, SubstrThick=50e-6, BarPeriod=200e-6, YCellShift=0,
Kx=0, Ky=0):
meep_utils.AbstractMeepModel.__init__(self) ## Base class initialisation
self.simulation_name = "CKEBars" ##
self.register_locals(locals()) ## Remember the parameters
## Initialization of materials used
self.materials = [meep_materials.material_TiO2_THz(where = self.where_TiO2),
meep_materials.material_dielectric(where = self.where_substr, eps=1.0)] ## XXX
## Dimension constants for the simulation
monzd = BarThick + SubstrThick ## monitor z-distance
self.monzd = monzd
self.size_x, self.size_y, self.size_z = resolution/1.8, BarPeriod, 500e-6 + cells*self.monzd
## constants for the simulation
self.pml_thickness = 100e-6
(self.monitor_z1, self.monitor_z2) = (-(monzd*cells)/2+monzc, (monzd*cells)/2+monzc)
self.simtime = simtime # [s]
self.srcFreq, self.srcWidth = 500e9, 1000e9 # [Hz], note: "Last source time" = 10/srcWidth
self.interesting_frequencies = (0., 1000e9)
self.TestMaterials() ## catches (most) errors in structure syntax, before they crash the callback
#def where_metal(self, r):
#for cellz in self.cell_centers():
#if (in_xslab(r, cx=0e-6, d=self.wtth) or in_yslab(r, cy=0e-6, d=self.wtth)) and \
#in_zslab(r, cz=self.wzofs+cellz, d=self.wlth):
#return self.return_value
#return 0
def where_TiO2(self, r):
# callback used for each polarizability of each material (materials should never overlap)
for cellz in self.cell_centers():
if (in_zslab(r, cz=cellz+self.SubstrThick/2,d=self.BarThick) and
in_yslab(r, cy=0,d=self.BarWidth)):
return self.return_value
return 0
def where_substr(self, r):
for cellz in self.cell_centers():
if in_zslab(r, cz=cellz-self.BarThick/2,d=self.SubstrThick):
return self.return_value
return 0
#}}}
class CKEBars_model_test(meep_utils.AbstractMeepModel): #{{{
""" Array of dielectric bars along the E-field, proposed by Christelle (June 2013) #{{{
Testing version with additional features
FD 2013-06-03
|PMLPMLPML|
^ +---------+ <-- monitor plane 2
| | |
z | | <-- Bloch-periodic boundaries on X, Y faces
| +---+ |
| |XXX| |<------- bar of TiO2
| +---+ | <-- (no substrate in this case)
| |
| |
y +---------+ <-- monitor plane 1
--> +=========+ <-- source
|PMLPMLPML| #}}}
"""
def cell_centers(self):#{{{
""" Helper function for stacked multilayered metamaterials """
return np.arange(-self.monzd*(self.cells-1)/2, self.monzd*(self.cells-1)/2+1e-12, self.monzd)
## alternatively: adds surrounding two cells!!
#return np.arange(-self.monzd*(self.cells+1)/2, self.monzd*(self.cells+1)/2+1e-12, self.monzd)#}}}
def __init__(self, comment="", simtime=200e-12, resolution=5e-6, cells=1, monzc=0e-6,
BarWidth=50e-6, BarThick=50e-6, BarPeriod=100e-6, YCellShift=0, XCut=0,
Kx=0, Ky=0):
meep_utils.AbstractMeepModel.__init__(self) ## Base class initialisation
self.simulation_name = "CKEBars" ##
self.register_locals(locals()) ## Remember the parameters
## Initialization of materials used
#self.materials = [meep_materials.material_TiO2_THz(where = self.where_TiO2)]
self.materials = [meep_materials.material_Sapphire_THz(where = self.where_TiO2),
meep_materials.material_dielectric(where = self.where_substr, eps=4.0)]
## Dimension constants for the simulation
monzd = BarPeriod ## monitor z-distance
self.monzd = monzd
self.size_x, self.size_y, self.size_z = resolution, BarPeriod, 500e-6 + cells*self.monzd
#self.size_x, self.size_y, self.size_z = BarPeriod, BarPeriod, 500e-6 + cells*self.monzd
## constants for the simulation
self.pml_thickness = 100e-6
(self.monitor_z1, self.monitor_z2) = (-(monzd*cells)/2+monzc, (monzd*cells)/2+monzc)
self.simtime = simtime # [s]
self.srcFreq, self.srcWidth = 500e9, 1000e9 # [Hz], note: "Last source time" = 10/srcWidth
self.interesting_frequencies = (0., 1000e9)
self.TestMaterials() ## catches (most) errors in structure syntax, before they crash the callback
def where_TiO2(self, r):
for cellz in self.cell_centers():
#zz = in_zslab(r, cz=cellz + (self.BarPeriod-self.BarThick)/2, d=self.BarThick)
zz = in_zslab(r, cz=cellz, d=self.BarThick)
yy = in_yslab(r, cy=(cellz/self.monzd)*self.YCellShift, d=self.BarWidth)
yy2 = in_yslab(r, cy=(cellz/self.monzd)*self.YCellShift + self.size_y, d=self.BarWidth)
yy3 = in_yslab(r, cy=(cellz/self.monzd)*self.YCellShift - self.size_y, d=self.BarWidth)
#xx = True
#xx = in_xslab(r, cx=self.resolution/4, d=self.size_x - self.XCut)
if (zz and (yy or yy2 or yy3)):
return self.return_value
return 0
def where_substr(self, r):
return 0
for cellz in self.cell_centers():
if in_zslab(r, cz=cellz-self.BarThick/2, d=self.monzd-self.BarThick):
return self.return_value
return 0
#}}}