[Script][2d_poly_examples][2D Polygon - Simulation Object]

发布时间 2023-11-28 15:15:34作者: 顽石y

来源:官网案例,侵删。

2D Polygon - Simulation Object – Ansys Optics

https://optics.ansys.com/hc/en-us/articles/360034901613-Structures-2D-Polygon

2d_poly_examples.lsf 

###################
# Example 1: circle
###################
R = 1e-6;  # radius
res = 1000; # number of points used for circle
x = R*cos(linspace(0,2*pi,res));
y = R*sin(linspace(0,2*pi,res));
V = [x,y];
add2dpoly;
set("name","2d circle");
set("vertices",V);

#################
# Example2: ring
#################
Rin = 0.5e-6;  # inner radius
Rout = 1e-6;   # inner radius
res = 100;     # number of points used for circle
xin = Rin*cos(linspace(0,2*pi,res));
yin = Rin*sin(linspace(0,2*pi,res));
xout = Rout*cos(linspace(0,2*pi,res));
yout = Rout*sin(linspace(2*pi,0,res));
V = [xin,yin;
     xout,yout];
add2dpoly;
set("name","2d ring");
set("vertices",V);

###########################
# Example 3: circular hole
###########################
x_span = 4e-6;   # x span of structure
y_span = 4e-6;   # y span of structure
R = 0.5e-6;      # radius of hole
x = R*cos(linspace(0,2*pi,res));
y = R*sin(linspace(0,2*pi,res));
V = [x,y;
     x_span/2,0;
     x_span/2,-y_span/2;
    -x_span/2,-y_span/2;
    -x_span/2, y_span/2;
     x_span/2, y_span/2;
     x_span/2,0];
add2dpoly;
set("name","2d circular hole");
set("vertices",V);

########################
# Example 4: cross hole 
########################
x_span = 2e-6;   # x span of structure
y_span = 2e-6;   # y span of structure
W = 1e-6;        # width of arm
L = 0.4e-6;      # length of arm

x = [W/2;L/2;L/2;-L/2;-L/2;-W/2;-W/2;-L/2;-L/2;L/2;L/2;W/2];
y = [L/2;L/2;W/2;W/2;L/2;L/2;-L/2;-L/2;-W/2;-W/2;-L/2;-L/2];

V = [x,y;
     W/2,0;
     x_span/2,0;
     x_span/2,-y_span/2;
    -x_span/2,-y_span/2;
    -x_span/2, y_span/2;
     x_span/2, y_span/2;
     x_span/2,0;
     W/2,0];
add2dpoly;
set("name","2d cross hole");
set("vertices",V);