FDTD Quick Start Lumerical Script Language Pickup (1) Preface


Preface

As a powerful optical simulation software, FDTD has been widely used in nano-optics and metamaterial simulation fields. But as far as the software itself is concerned, it will take some time to get started. And, given that many simulations in the field of micro-nano optics are more suitable for scripting, I wrote this scripting language series of articles to help friends in need to quickly get started with FDTD.
It should be noted here that although the purpose of this series of articles is to help friends in need to get started quickly with FDTD, our focus is to use scripting language to implement the simulation process, and does not involve the introduction of FDTD software window functions, so read this series of articles It is best for readers to have certain prerequisite knowledge. FDTD-related introduction videos can be easily searched on Baidu, so they will not be listed at the end of this article.

A simple simulation model

First of all, it should be noted that as one of Lumerical's mainstream products, FDTD actually uses a command language called Lumerical Script Language. This language is very similar to matlab. Many grammars in matlab can be implemented directly in the Lumerical scripting language. The Lumerical script is saved in a file with the extension .lsf, and the script editor is in the right column of the figure below.
Insert picture description here
Let's start with a simple example to introduce the main components of the FDTD simulation script. First, the previous example:

switchtolayout;

selectall;delete;

nm=1e-9;#纳米单位
um=1e-6;#微米单位

#添加矩形
addrect;
set("name","SiO2");#名称为SiO2                   
set("material","SiO2 (Glass) - Palik");#材料为二氧化硅(玻璃)
set("x",0);#设置x中心点坐标   
set("y",0);#设置y中心点坐标
set("x span",1*um);#设置x方向宽度
set("y span",1*um);#设置y方向宽度
set("z max",100*nm);#设置z方向最大值
set("z min",-1*um);#设置z方向最小值

#添加FDTD仿真区域
addfdtd;
set("dimension",2);#仿真区域为三维区域
set("x",0);
set("y",0);
set("z min",-10*nm);
set("z max",2*um);
set("x span",0.2*um);
set("y span",0.22*um);
set("x min bc","periodic");#设置x方向周期边界条件
set("y min bc","periodic");#设置y方向周期边界条件
set("Mesh type","uniform");#仿真网格为自定义方式
Mesh_size=10*nm;#网格精度10nm
setnamed("FDTD","dx",Mesh_size);
setnamed("FDTD","dy",Mesh_size);

#添加平面波
addplane;
set("injection axis","z");#入射轴与z轴平行
set("direction","backward");#朝向后方入射
set("x",0);
set("x span",0.4*um);
set("y",0);
set("y span",0.4*um);
set("z",1*um);
set("wavelength start",1.5*um);#波长(最小)
set("wavelength stop",1.5*um);#波长(最大)

#添加点监视器
addprofile;
set("name","R");
set("monitor type",1);#点监视器
set("x",0);
set("y",0);
set("z",1.5*um);

#添加时间监视器
addtime;
set("name","time");

run;#运行仿真

#获取结果并分析
select("SiO2");
surface_z=get("z max");
select("source");
source_z=get("z");
select("R");
monitor_z=get("z");
ex=getdata("R","Ex");
R_z=getdata("R","z");
f=getdata("R","f");
f=pinch(f);
lambda=c/f*1e6;
phase=pinch(angle(ex));
phai=phase-2*pi*(source_z+monitor_z-2*surface_z)*f/c;
phai=mod(phai*180/pi,360);
plot(lambda,phai,"lambda um","phase");

This is a complete simulation code for verifying that there is a half-wave loss in the reflected wave when light is incident on the optically dense medium from the optically thin medium. It contains the following parts:

  • Simulation structure (structure)
  • Simulation area (FDTD)
  • Source
  • Monitor
  • Simulation result analysis (Analysis)

The approximate simulation results are as follows:
Figure: Simulation model
Figure: Phase mutation value obtained by simulation

I have made some comments on the key parts of the simulation code (except for the analysis module). You can modify the code according to your needs in combination with comments. Regarding the detailed writing and use of the above several simulation modules, we will introduce them in subsequent articles.

Reference link

As this series of articles is mainly used as an introduction to the entry level, for more detailed script commands and related settings, please refer to the following link:
Model: Simulation objects .
Script commands: Lumerical scripting language-By category .
PS: Other technical-related specific issues are also available It can be found on Lumerical's official website and kx forum.

Guess you like

Origin blog.csdn.net/weixin_44224652/article/details/112677982