-
Notifications
You must be signed in to change notification settings - Fork 2
/
spiral_outcoupler.lsf
121 lines (111 loc) · 4.94 KB
/
spiral_outcoupler.lsf
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
# Copyright 2020 Niccolò Marcucci <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##########################################################################
# This file creates a spiral shaped structure in which it is possible to set
# the number of arms, the internal diameter, the period of the spiral and the
# number of turns the arms do (actually it sets the number of periods seen
# radially, from the center outwards).
# This spiral structure can be used for creating grooves onto a dielectric layer
# (hence the name chosen for the various properties).
addstructuregroup;
set('name','spiral outcoupler');
set('x',0);
set('y',0);
set('z',0);
adduserprop('material groove',5,'<Object defined dielectric>');
adduserprop('index groove',0,1);
adduserprop('N rings',0,10); # high refreactive index layer
adduserprop('topological charge',0,2); # number of arms of the spiral
adduserprop('thickness',2,0.1e-6); # thickness
adduserprop('resolution',0,50); # number of points used for creating the spiral
adduserprop('start radius',2,1.5e-6);
adduserprop('dbr period',2,0.25e-6);
adduserprop('fill factor',0,0.5);
adduserprop('z min',2,0);
myscript= "
deleteall;
material_out = %material groove%;
index_out = %index groove%;
n_rings = %N rings%;
start_radius = %start radius%;
lambda = %dbr period%;
n_arms = %topological charge%;
FF = %fill factor%;
D=start_radius*2;
resolution = 2*resolution*n_rings; # even value required
radius = matrix(resolution/2); # radius, function of theta
theta = matrix(resolution/2);
vertices = matrix(2,resolution);
int_res=15;
r_n=matrix(int_res);
the=matrix(int_res);
vert=matrix(2,int_res);
if (n_arms != 0) {
# Each arm opf the spiral is defined by a polygon
for (j=0:abs(n_arms)-1) {
# define theta
theta= linspace(0,2*pi*n_rings/n_arms,resolution/2);
# parametrize the radius
radius(1:resolution/2) = start_radius+lambda*theta/(2*pi/n_arms);
vertices(1,1:resolution/2) = radius*cos(theta+2*pi*j/n_arms);
vertices(2,1:resolution/2) = radius*sin(theta+2*pi*j/n_arms);
vertices(1,end:-1:resolution/2+1) = (radius+lambda*FF)*cos(theta+2*pi*j/n_arms);
vertices(2,end:-1:resolution/2+1) = (radius+lambda*FF)*sin(theta+2*pi*j/n_arms);
# add polygon object and set properties
addpoly;
set('name','loop_A_'+num2str(j));
set('vertices',vertices);
set('material',material_out);
if(get('material')=='<Object defined dielectric>')
{ set('index',index_out); }
set('z min', %z min%);
set('z max', %z min%+thickness);
if (start_radius == 0) {
# close the spiral on the origin if the initial radius is null
r_n = linspace(start_radius+lambda*FF,0,int_res);
the = linspace(0,-pi/n_arms,int_res);
vert(1,:) = r_n*cos(the+2*pi*j/n_arms);
vert(2,:) = r_n*sin(the+2*pi*j/n_arms);
addpoly;
set('name','start bump'+num2str(j));
set('vertices',vert);
set('material',material_out);
if(get('material')=='<Object defined dielectric>')
{ set('index',index_out); }
set('z min', %z min%);
set('z max', %z min%+thickness);
}
}
} else {
if (n_rings!=0) {
for (n = 1:n_rings){
addring;
set('name','groove' + num2str(n));
set('x',0);
set('y',0);
set('inner radius',D/2+(n-1)*lambda);
set('outer radius',D/2+(n-0.5)*lambda);
set('z min',%z min%);
set('z max',%z min%+thickness);
set('material',material_out);
if(get('material')=='<Object defined dielectric>')
{ set('index',index_out); }
set('theta start',0);
set('theta stop',360);
set('index', index_out);
}}
}
";
set('script',myscript);