使用脚本语言实现Lumerical官方案例——闪耀光栅(Blazed grating)(纯代码)(2)

接《使用脚本语言实现Lumerical官方案例——闪耀光栅(Blazed grating)(纯代码)(1)》

一、添加分析组

1.1 代码实现

#添加分析组
addanalysisgroup();
set("name", "grating_R");
set("x", 0);
set("y", 2.5*um);
addanalysisgroup();
set("name", "grating_T");
set("x", 0);
set("y", -1.5*um);

#添加功率监视器
addpower();
set("name", "transmission_grating");
set("monitor type", "2D Z-normal");
set("x min", -2*um);
set("x max", 2*um);
set("y min", 0);
set("y max", 0);
set("z", 0);
addtogroup("grating_R");

addpower();
set("name", "transmission_grating");
set("monitor type", "2D Z-normal");
set("x min", -2*um);
set("x max", 2*um);
set("y min", 0);
set("y max", 0);
set("z", 0);
addtogroup("grating_T");

1.2 分析组的设置

 1.2.1 grating_R

(1)setup

#grating_R_setup_script.lsf
#这段if语句用于检查名为normal的输入参数值是否合法。如果normal的值既不是"x"也不是"y",则认为是无效的表面法线方向输入,会输出相应的错误提示信息(通过message函数)
#告知用户输入有误,并将normal默认设置为"y",以保证后续代码能按合理的默认情况继续执行
if ((normal != "x") and (normal != "y")) { 
  message("Surface normal '" + normal + "' is invalid.  Must be 'x', 'y'.  Using y normal.");
  normal ="y";  # if normal is not specified properly, default to y normal
} 
#这两个if语句根据normal的值来对x_span或y_span进行调整。如果normal的值为"x",意味着在x方向是表面法线方向,此时将x_span设置为 0,因为对于这个特定的监视器(用于计算光栅透射率且必须是 1D 的情况下)
#在法线方向的跨度需要忽略;同理,当normal为"y"时,将y_span设置为 0。
if (normal=="x") { x_span = 0; }  # set span in normal direction to zero
if (normal=="y") { y_span = 0; }

(2) analysis

##############################################
# Grating transmission
# This object calculates the fraction of power transmitted to each 
# grating order at all frequency points recorded by the monitor. 
# It also calculates the number of propagating grating orders 
#
# Input properties
# make plots: 1 to make plots, 0 otherwise
# n target: grating order to plot
# lambda target: wavelength to plot
#
# Output properties
# f: frequency vector
# n: grating order number vector
# T(f): total transmitted power vs frequency
# T_grating(n,f): transmitted power to each grating order
# num_orders(f): number of propagating grating orders 
# theta(n,f): grating order angles          
#          
# Tags: far field grating order transmission
#
# Copyright 2012 Lumerical Solutions Inc
##############################################     
    
#grating_R_analys
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

薰衣草2333

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值