-
-
April 23, 2022 at 11:10 am
oylllc
Subscriber老师好,我在用stackrt脚本语言做一个多层薄膜,想研究不同厚度下薄膜在固定波长范围内的折射率和反射率,于是我在写扫描的脚本时参数选取的是之前定义的第二层的厚度,扫描的结果也是之前定义的结果,运行没有成功,请问是什么原因呢?是不能这样定义参数吗?这是我的脚本,谢谢老师!!!
f1 = linspace(c/360e-9, c/780e-9,39); # frequency vector
f2 = linspace(c/3000e-9, c/14000e-9,111);
theta = 0; # angle vector
d = [0; 40e-9; 15e-9; 40e-9; 0]; # air/SiO2/Si/SiO2/air
nf1 = length(f1);
nf2 = length(f2);
nd = length(d);
# refractive index of each layer (dispersive)
n1 = matrix(nd,nf1);
n1(1,1:nf1) = 1; # air
n1(2,1:nf1) = getfdtdindex("AZO",f1,min(f1),max(f1));
n1(3,1:nf1) = getfdtdindex("Ag (Silver) - CRC",f1,min(f1),max(f1));
n1(4,1:nf1) = getfdtdindex("AZO",f1,min(f1),max(f1));
n1(5,1:nf1) = 1; # air
n2 = matrix(nd,nf2);
n2(1,1:nf2) = 1; # air
n2(2,1:nf2) = getfdtdindex("AZO",f2,min(f2),max(f2));
n2(3,1:nf2) = getfdtdindex("Ag (Silver) - CRC",f2,min(f2),max(f2));
n2(4,1:nf2) = getfdtdindex("AZO",f2,min(f2),max(f2));
n2(5,1:nf2) = 1; # air
RT1 = stackrt(n1,d,f1); # non-dispersive index data, and theta=0
RT2 = stackrt(n2,d,f2); # dispersive data index data, and theta from 0 to 45 deg
visualize(RT1);
visualize(RT2);
plot(RT1.lambda*1e6,RT1.Rp,RT1.Rs,RT1.Tp,RT1.Ts,"wavelength (um)","Power","non-disperisive, theta=0");
legend("Rp","Rs","Tp","Ts");
plot(RT2.lambda*1e6,RT2.Rp,RT2.Rs,RT2.Tp,RT2.Ts,"wavelength (um)","Power","non-disperisive, theta=0");
legend("Rp","Rs","Tp","Ts");
# add a new sweep and set basic properties
addsweep;
setsweep("sweep", "name", "thickness_sweep_script");
setsweep("thickness_sweep_script", "type", "Ranges");
# define the parameter thickness
para = struct;
para.Name = "thickness";
para.Parameter = "n1(2,1:nf1)";
para.Type = "Length";
para.Start = 35e-9;
para.Stop = 55e-9;
para.Units = "nm";
# add the parameter thickness to the sweep
addsweepparameter("thickness_sweep_script", para);
# define results
result_1 = struct;
result_1.Name = "Tvis";
result_1.Result = "RT1.Tp";
result_2 = struct;
result_2.Name = "Rir";
result_2.Result = "RT2.Rp";
# add the results R & T to the sweep
addsweepresult("thickness_sweep_script", result_1);
addsweepresult("thickness_sweep_script", result_2);
setsweep("thickness_sweep_script", "number of points", 5);
# run the sweep
runsweep("thickness_sweep_script");
# view the results
R = getsweepresult("thickness_sweep_script", "Tvis");
T = getsweepresult("thickness_sweep_script", "Rir");
plot(R.thickness*1e9, R.T, "AZO thickness (nm)","R");
plot(T.thickness*1e9, T.T, "AZO thickness (nm)","T");
April 23, 2022 at 12:30 pmApril 25, 2022 at 6:08 pmGuilin Sun
Ansys Employee我觉得你把简单问题复杂化了。
你只需要将
d = [0; 40e-9; 15e-9; 40e-9; 0]; # air/SiO2/Si/SiO2/air
仿真循环了,要改某个厚度,设为Di和给出一个线阵数据,并定义RDi(1:nf,1:lengh(Di)),则
for(n=1:length(Di)){
d = [0; 40e-9; Di(n); 40e-9; 0]; # air/SiO2/Si/SiO2/air
RT1 = stackrt(n1,d,f1); # non-dispersive index data, and theta=0
RDi(:,n)=RT1.Rp;
}
即可。你琢磨一下。
April 26, 2022 at 7:02 amoylllc
Subscriber老师,是这样的,我的目标是做一个三层薄膜,然后改变中间薄膜的厚度或者是两侧薄膜的厚度,然后计算薄膜在不同厚度下一定波段上的平均红外反射率和平均可见光透过率,最后得到一个平均红外反射率×平均可见光透过率最高的结果,比如40nm/10nm/40nm这样,所以我想的是用stackrt仿真,将参数设置为不同层的厚度,然后运行参数扫描及优化,定义一个平均红外反射率×平均可见光透过率为Z,Z就是我要看的结果,最后Z对厚度作图,这样得到最优结果。但是我目前遇到的问题是我不知道怎样将参数设置为不同层的厚度,我看参数扫描及优化里的教程,选择的参数是要在model里选的,像我上面的脚本里所写的那样,我把参数定义为n2(2,1:nf2),最后运行失败了。所以是我脚本写的有问题还是说我不应该用这种方法,用循环的方法更好?
April 26, 2022 at 12:18 pmoylllc
Subscriber老师,我按照您的方法写了循环,但运行报错,请问是怎么回事
f1 = linspace(c/380e-9, c/780e-9,41); # frequency vector
f2 = linspace(c/3e-6, c/14e-6,111);
nf1 = length(f1);
nf2 = length(f2);
theta = 0; # angle vector
Di = linspace(6,10,5);#定义Di
RDi = matrix(1:nf1,1:length(Di));#定义RDi
#Ag层厚度循环
for(n=1:length(Di)){
d = [0; 40e-9; Di(n); 40e-9; 0]; # air/SiO2/Si/SiO2/air
nd = length(d);
# refractive index of each layer (dispersive)
n1 = matrix(nd,nf1);
n1(1,1:nf1) = 1; # air
n1(2,1:nf1) = getfdtdindex("AZO",f1,min(f1),max(f1));
n1(3,1:nf1) = getfdtdindex("Ag (Silver) - CRC",f1,min(f1),max(f1));
n1(4,1:nf1) = getfdtdindex("AZO",f1,min(f1),max(f1));
n1(5,1:nf1) = 1; # air
n2 = matrix(nd,nf2);
n2(1,1:nf2) = 1; # air
n2(2,1:nf2) = getfdtdindex("AZO",f2,min(f2),max(f2));
n2(3,1:nf2) = getfdtdindex("Ag (Silver) - CRC",f2,min(f2),max(f2));
n2(4,1:nf2) = getfdtdindex("AZO",f2,min(f2),max(f2));
n2(5,1:nf2) = 1; # air
RT1 = stackrt(n1,d,f1); # non-dispersive index data, and theta=0
RT2 = stackrt(n2,d,f2); # non-dispersive index data, and theta=0
RDi(1:nf1,n)=RT1.Ts;
}
plot(RT1.lambda*1e6,RDi(1:nf1,1),"wavelength (um)","Power","non-disperisive, theta=0");
以及如果我想把不同银层厚度画在一张图上,该怎么做呢?
April 26, 2022 at 3:32 pmGuilin Sun
Ansys EmployeeDi = linspace(6,10,5);#定义Di
错了!你只需要定义一个维度,为什么要定义三个维度呢?主要问题是你对这个
d = [0; 40e-9; 15e-9; 40e-9; 0]; # air/SiO2/Si/SiO2/air
理解错了。每个数是每层的厚度,你看看说明。
d = [0; 40e-9; Di(n); 40e-9; 0]; # air/SiO2/Si/SiO2/air
这句话显然说明Di(n)是一维数组,但是你却定义为3维。
你只需改变某一层的厚度,用一维函数D表示,给D赋值。我专门说“设为Di和给出一个线阵数据”,看来你没有理解这句话。
哪一句出错,你要修改它,看看要求是什么,为什么出错,这是一般写程序的基本方法。
Plot只能做曲线,不同层厚度你可以画多条曲线,也可以用image: image - Script command
你可能需要时间学习了解脚本工作原理。
解析结果可以给出指定波长范围的数值。不清楚为什么要给两个波段分别计算,幸亏这种方法计算快,否则你可就浪费太多时间了。难道f1范围的结果不能从f2中得到吗?
可能需要花点时间想一想怎样更有效地仿真。
网上有很多脚本使用的视频,请花时间看一下吧。April 27, 2022 at 1:23 amoylllc
Subscriber谢谢老师的解答,我的确在编程方面基础薄弱,所以才犯这么多基础性错误,我再好好学习一下,谢谢老师
April 27, 2022 at 7:55 amApril 27, 2022 at 2:45 pmGuilin Sun
Ansys Employee抱歉,是我看错了,我以为你用的是Matrix。
这是解析结果,误差可以忽略不记,没有什么精度的问题。
April 28, 2022 at 2:01 amoylllc
Subscriber不好意思老师,我没说清楚,我指的是0.38-0.78范围内波长间隔为0.01,3-14um范围内波长间隔为0.1,所以分开计算了April 28, 2022 at 3:31 pmGuilin Sun
Ansys Employee实际完全没有必要,解析计算相对仿真来说快很多,不至于一分钟都等不了吧?可以把频率点设置为变量,先大致测试,最后再用多点。Viewing 10 reply threads- The topic ‘关于参数扫描’ is closed to new replies.
Ansys Innovation SpaceBoost Ansys Fluent Simulations with AWS
Computational Fluid Dynamics (CFD) helps engineers design products in which the flow of fluid components is a significant challenge. These different use cases often require large complex models to solve on a traditional workstation. Click here to join this event to learn how to leverage Ansys Fluids on the cloud, thanks to Ansys Gateway powered by AWS.
Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.
Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
Trending discussions- Ansys Insight: FDTD 和 varFDTD 常见的发散原因以及处理
- Ansys Insight: 透射率反射率电场大于1,或者透射率反射率之和大于1的原因与解决方案–综合贴
- Ansys Insight: FDTD Solutions 的光源类型及其典型应用:初学者
- Ansys Insight: 关于FDTD 并行计算的有关问题
- 软件打不开
- Ansys Insight: 光学强度、功率、电场强度平方的关系以及电磁能量
- Ansys Insight: 如何知道FDTD的仿真时间足够长
- 超透镜聚焦效率计算
- Ansys Insight: 如何将结果数据如何保存成txt格式
- Ansys Insight: 关于mode expansion监视器的使用和结果分析
Top Contributors-
8808
-
4658
-
3151
-
1680
-
1470
Top Rated Tags© 2023 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.
-