repo build
This commit is contained in:
@@ -0,0 +1,205 @@
|
||||
function mx_rect(name,coord,sz,material,mesh_order,refractive_index)
|
||||
{
|
||||
addrect;
|
||||
set('name',name);
|
||||
set('x',coord(1));
|
||||
set('y',coord(2));
|
||||
set('z',coord(3));
|
||||
set('x span',sz(1));
|
||||
set('y span',sz(2));
|
||||
set('z span',sz(3));
|
||||
|
||||
set('material',material);
|
||||
|
||||
set('override mesh order from material database',1);
|
||||
set('mesh order',mesh_order);
|
||||
|
||||
if (refractive_index>0)
|
||||
{
|
||||
set('material','<Object defined dielectric>');
|
||||
set('index',refractive_index);
|
||||
}
|
||||
}
|
||||
|
||||
function mx_concoid(name,coord,height,R0,T0,kR,w0,res,theta,material,mesh_order,refractive_index)
|
||||
{
|
||||
## in polar axis
|
||||
|
||||
dT = linspace(T0,theta+T0,res);
|
||||
R = ((dT-T0)*kR+R0);
|
||||
|
||||
e_theta = -1/((R0/kR)+dT-T0);
|
||||
e_rou = ones(length(dT));
|
||||
e_theta(end) = 0;
|
||||
e_theta(1) = 0 ;
|
||||
|
||||
|
||||
|
||||
ex = cos(dT)*e_rou - sin(dT)*e_theta;
|
||||
ey = sin(dT)*e_rou + cos(dT)*e_theta ;
|
||||
|
||||
Lnorm = sqrt(ex^2+ey^2);
|
||||
|
||||
vtx_x = R*cos(dT);
|
||||
vtx_y = R*sin(dT);
|
||||
|
||||
vtx_out_x = vtx_x + w0/2*ex/Lnorm;
|
||||
vtx_out_y = vtx_y + w0/2*ey/Lnorm;
|
||||
|
||||
vtx_in_x = vtx_x - w0/2*ex/Lnorm;
|
||||
vtx_in_y = vtx_y - w0/2*ey/Lnorm ;
|
||||
|
||||
vtx_in = [flip(vtx_in_x,1),flip(vtx_in_y,1)];
|
||||
vtx_out = [vtx_out_x,vtx_out_y];
|
||||
vtx = [vtx_out;vtx_in];
|
||||
|
||||
|
||||
mx_poly(name,coord,vtx,height,material,mesh_order,refractive_index);
|
||||
|
||||
return vtx;
|
||||
|
||||
}
|
||||
|
||||
function mx_taper(name,coord,height,wa,wb,L,offset,material,mesh_order,refractive_index)
|
||||
{
|
||||
vtx_x = [0,L,L,0];
|
||||
vtx_y = [wa/2,wb/2+offset,-wb/2+offset,-wa/2];
|
||||
|
||||
vtx = [vtx_x;vtx_y];
|
||||
mx_poly(name,coord,vtx,height,material,mesh_order,refractive_index);
|
||||
|
||||
return vtx;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function mx_ring(name,coord,height,radius,theta,material,mesh_order,refractive_index)
|
||||
{
|
||||
addring;
|
||||
set('name',name);
|
||||
set('x',coord(1));
|
||||
set('y',coord(2));
|
||||
set('z',coord(3));
|
||||
set('z span',height);
|
||||
set('outer radius',max(radius));
|
||||
set('inner radius',min(radius));
|
||||
set('theta start',theta(1));
|
||||
set('theta stop',theta(2));
|
||||
|
||||
set('material',material);
|
||||
|
||||
set('override mesh order from material database',1);
|
||||
set('mesh order',mesh_order);
|
||||
|
||||
if (refractive_index>0)
|
||||
{
|
||||
set('material','<Object defined dielectric>');
|
||||
set('index',refractive_index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function mx_ring_coic(name,coord,height,Ra_in,Rb_in,Ra_out,Rb_out,offset,theta,material,mesh_order,refractive_index)
|
||||
{
|
||||
theta = linspace(theta(1),theta(2),1001);
|
||||
xout = Ra_out*cos(theta);
|
||||
yout = Rb_out*sin(theta);
|
||||
|
||||
xin = Ra_in*cos(theta);
|
||||
yin = Rb_in*sin(theta)+offset;
|
||||
|
||||
vtx_outer = [xout,yout];
|
||||
vtx_inner = [xin,yin];
|
||||
|
||||
vtx = [vtx_outer;flip(vtx_inner,1)];
|
||||
mx_poly(name,coord,vtx,height,material,mesh_order,refractive_index);
|
||||
|
||||
return vtx;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function mx_poly(name,coord,vtx,height,material,mesh_order,refractive_index)
|
||||
{
|
||||
addpoly;
|
||||
set('name',name);
|
||||
set('x',coord(1));
|
||||
set('y',coord(2));
|
||||
set('z',coord(3));
|
||||
set('vertices',vtx);
|
||||
set('z span',height);
|
||||
|
||||
set('material',material);
|
||||
|
||||
set('override mesh order from material database',1);
|
||||
set('mesh order',mesh_order);
|
||||
|
||||
if (refractive_index>0)
|
||||
{
|
||||
set('index',refractive_index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function mx_elipse(name,coord,height,La,Lb,wa,wb,theta,offset,material,mesh_order,refractive_index)
|
||||
{
|
||||
theta = linspace(theta(1),theta(2),1001);
|
||||
x = La*cos(theta);
|
||||
y = Lb*sin(theta);
|
||||
|
||||
## norm direction
|
||||
dX = 2*x/La^2;
|
||||
dY = 2*y/Lb^2;
|
||||
|
||||
L_norm = sqrt(dX^2+dY^2);
|
||||
|
||||
offset = (offset(1)-offset(2))*cos(theta)^2 + offset(2);
|
||||
|
||||
w = (wa-wb)*cos(theta)^2 + wb; ## width variation
|
||||
|
||||
vtx_outer_x = x + dX/L_norm*(w/2+offset);
|
||||
vtx_outer_y = y + dY/L_norm*(w/2+offset);
|
||||
|
||||
vtx_inner_x = x + dX/L_norm*(-w/2+offset);
|
||||
vtx_inner_y = y + dY/L_norm*(-w/2+offset);
|
||||
|
||||
vtx_outer = [vtx_outer_x,vtx_outer_y];
|
||||
vtx_inner = [vtx_inner_x,vtx_inner_y];
|
||||
|
||||
vtx = [vtx_outer;flip(vtx_inner,1)];
|
||||
mx_poly(name,coord,vtx,height,material,mesh_order,refractive_index);
|
||||
|
||||
return vtx;
|
||||
}
|
||||
|
||||
function mx_power_monitor(name,coord,sz,diretion)
|
||||
{
|
||||
addpower;
|
||||
set('name',name);
|
||||
set('x',coord(1));
|
||||
set('y',coord(2));
|
||||
set('z',coord(3));
|
||||
|
||||
if (diretion==1)
|
||||
{
|
||||
set('monitor type','2D X-normal');
|
||||
set('y span',sz(2));
|
||||
set('z span',sz(3));
|
||||
}
|
||||
|
||||
if (diretion==2)
|
||||
{
|
||||
set('monitor type','2D Y-normal');
|
||||
set('x span',sz(1));
|
||||
set('z span',sz(3));
|
||||
}
|
||||
|
||||
if (diretion==3)
|
||||
{
|
||||
set('monitor type','2D Z-normal');
|
||||
set('x span',sz(1));
|
||||
set('y span',sz(2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user