FDTD Script 命令学习-pinch

pinch命令在FDTD方法中用于处理多维矩阵,它可以删除指定维度并重新赋值。例如,当处理一个四维矩阵时,pinch可以去除变量数为1的维度,或将特定维度如频率或位置进行选择性保留,生成新的二维矩阵用于后续分析或图像绘制。在功率监视器的例子中,pinch结合find命令用于选取特定频率的2D数据,简化数据结构以便于可视化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考FDTD官网pinch命令介绍:https://optics.ansys.com/hc/en-us/articles/360034405674-pinch-Script-command

1、pinch命令功能:

(1)第一个语法out=pinch(x):对多维度矩阵进行降低维度操作,删除原始矩阵变量中变量数为1的维度,并进行赋值;例子:y=pinch(x) 假如原始x为一个四维矩阵(1*1*1*M),前三个维度的变量数都是1,经过pinch命令后,矩阵的维度降为M*1阶矩阵,并对新的矩阵y进行赋值,对应关系如下 y(i)=x(1,1,1,i);

(2)第二个语法pinch(x,i):对多维度矩阵x进行第i个维度的删除操作,并进行赋值;

例子:y=pinch(x,2) 假如原始x为一个四维N*M*K*P阶矩阵,经过pinch(x,2)命令,将x矩阵的第二个维度(变量数为M)进行删除,并对新的矩阵y进行赋值,y矩阵为三维N*K*P阶矩阵,对应关系y(i,j,k)=x(i,1,j,k) (备注:赋值时x矩阵中被删除的第二个维度,均以1替代,即以该维度下的首个变量来进行赋值);

思考:如果N,K,P中某一个或几个为1,那么进过pinch(x,2)进行y矩阵赋值后,新矩阵y是几维矩阵?

(3)第三个语法pinch(x,i,j):该语法算是第二个语法的补充;与语法2相同点均可以对矩阵x进行第i个维度的删除操作,并进行赋值;不同点在于语法2进行赋值时对于被删除的维度上的变量默认采用第一个变量进行赋值,而语法3在赋值时对于被删除的维度上的变量可以低j个变量来进行赋值;

例子:y=pinch(x,2,4) 假如原始x为一个四维N*M*K*P阶矩阵,经过pinch(x,2,4)命令,将x矩阵的第二个维度(变量数为M)进行删除,并对新的矩阵y进行赋值,y矩阵为三维N*K*P阶矩阵,对应关系y(i,j,k)=x(i,4,j,k) (备注:赋值时x矩阵中被删除的第二个维度,均以4替代,即以该维度下的第四个变量来进行赋值);

2. pinch命令官网例子解读:

Suppose the power monitor named "field" is a 2D monitor in the XY plane set to record multiple frequency points between 200THz and 300THz. In this case, the variable Ex will be a 4D matrix, where the dimensions are length(X) by length(Y) by length(Z) by length(F). Since this is a 2D monitor in the XY plane, there will be only one Z position, which means the length of the third dimension (Z) will be 1.”

翻译:假设名称为field的功率监视器是一个在XY平面上的2D监视器,用来200THz到300THz频率间多个频率下的功率值。在该情况下,变量Ex将会是一个四维变量,维度是(x)长度*(y)长度*(z)长度*(f)长度。由于该监视器是在XY平面的2D监视器,所以只有一个Z位置值,即第三个维度Z变量数为1.

“With the pinch and find commands, we can select a particular frequency to be imaged. First, the find command is used to determine the index of the frequency value closest to 250THz. Next, the pinch command is used to select the data in Ex corresponding to that frequency. A second pinch command is used to remove the singleton Z dimension. The end result is the 2D matrix Ex(x,y) at a specific value of z and f.”

翻译:使用pinch和find命令,我可以选择特定频率下的数据来进行成像。第一,find命令用来确定频率接近250THz的频率索引值(即为在f矩阵中变量所处位置)。第二,使用pinch命令来选择250THz频率下的Ex结果。第三,第二个pinch命令用来删除单变量的Z维度。最终结果是在特定的z位置和频率250THz下的2D矩阵Ex(x,y)。

m="field";      # 监视器名称,该监视器为xy平面的2D
x=getdata(m,"x");  # 获取监视器中x的数据
y=getdata(m,"y");
z=getdata(m,"z");
f=getdata(m,"f");
Ex=getdata(m,"Ex");
fi=find(f,250e12);  # 在矩阵f中找到最接近250e12的值,并将其索引(即第几个变量)赋予fi
Ex=real(Ex);     # 取Ex的实部    
?"Size of x: "+num2str(length(x)); # 显示x矩阵的变量数
?"Size of y: "+num2str(length(y));
?"Size of z: "+num2str(length(z));
?"Size of f: "+num2str(length(f));
?"Size of Ex: "+num2str(size(Ex));
to_plot=pinch(Ex,4,fi);   # select frequency. Size will be length(x) by length(y) by length(z) 将Ex矩阵中第四个维度(f)进行删除,赋值时该维度变量取第fi个变量,该命令功能为选取出频率接近250e12时的其他维度变量并赋值给to_plot
to_plot=pinch(to_plot);   # remove singleton z dimension. Size will be length(x) by length(y) 再次采用pinch命令将单变量的维度z消除,新的to_plot矩阵维度为(x)长度*(y)长度
image(x*1e6,y*1e6,to_plot, "x (um)","y (um)","Ex at "+num2str(f(fi)/1e12)+ " THz" ); # 以x和y为轴(单位um),对变量Ex(x,y)做图;图表名称Ex at 250 THz

以上为本人对pinch命令的学习笔记,希望对大家有帮助。

FDTD软件英文使用说明 Initial Properties dialog box ................................................................................... 33 Mask Export............................................................................................................. 41 Profile Designer....................................................................................................... 42 Wafer Properties ..................................................................................................... 42 Profiles In Use ......................................................................................................... 44 Properties ................................................................................................................ 45 Toolbars ................................................................................................................... 45 Status bar................................................................................................................. 45 Color Spectrum ....................................................................................................... 46 Workbook Mode ...................................................................................................... 49 3D Graph Items........................................................................................................ 50 Show slice selector................................................................................................. 54 Refractive Index (X, Y, and Z directions) .............................................................. 54 Zoom tool................................................................................................................. 54 Edit Parameters....................................................................................................... 56 2D Simulation Parameters...................................................................................... 62 3D Simulation Parameters...................................................................................... 66 3D Simulation Parameters for 64-bit simulator .................................................... 68 2D Band Solver Parameters ................................................................................... 73 PWE Band Solver .................................................................................................... 78 Test Script................................................................................................................ 86 Run Script (2D or 3D).............................................................................................. 86 Generate Template Script....................................................................................... 86 Generate Layout Script........................................................................................... 86 Generate Scanning Script ...................................................................................... 86 Preferences menu ................................................................................................... 87 Edit Menu ................................................................................................................. 89 3D Objects ...................................................................................................... 93 Common elements of 3D object waveguides ....................................................... 94 Clipping Planes ..................................................................................................... 103 Profile Designer ........................................................................................... 107 Main parts of the GUI ............................................................................................ 108 Main menu bar....................................................................................................... 112 Toolbars ................................................................................................................. 112 Library Browser toolbar ....................................................................................... 113 Profile toolbar........................................................................................................ 114Table of Contents Installing OptiFDTD ......................................................................................... 1 Hardware and software requirements..................................................................... 1 Protection key ........................................................................................................... 2 Installation ................................................................................................................. 2 Technical support ..................................................................................................... 3 Overview........................................................................................................... 5 What is OptiFDTD? ................................................................................................... 5 OptiFDTD applications and how they relate to one another................................. 6 OptiFDTD_Designer .................................................................................................. 6 Main elements of a layout design............................................................................ 8 What’s new in OptiFDTD 8.0 ......................................................................... 11 64-bit 2D Simulator ................................................................................................. 11 Heating Absorption................................................................................................. 13 Total Field Scattering Field 2D simulations and analysis ................................... 13 OptiFDTD_Designer....................................................................................... 17 Main parts of the GUI .............................................................................................. 18 Main menu bar......................................................................................................... 22 Toolbars ................................................................................................................... 22 OptiFDTD_Designer menus and buttons..................................................... 23 File menu ................................................................................................................. 23 Edit menu................................................................................................................. 24 View menu ............................................................................................................... 25 Tools menu .............................................................................................................. 27 Draw menu............................................................................................................... 27 Simulation menu ..................................................................................................... 31 Preferences menu ................................................................................................... 31 Window menu.......................................................................................................... 32 Help menu................................................................................................................ 32 OptiFDTD_Designer functions...................................................................... 33OptiBPM Specific Materials ........................................................................ 169 Material Class ........................................................................................................ 169 Create and edit materials ..................................................................................... 169 Dielectric material (Ordinary)............................................................................... 170 Diffused material ................................................................................................... 173 OptiFDTD Specific Materials....................................................................... 177 Material Class ........................................................................................................ 177 Create and edit materials ..................................................................................... 177 Dielectric ................................................................................................................ 178 Dispersion.............................................................................................................. 183 Converting the ‘Sellmeier equation’ to ‘Lorentz Model’ .................................... 184 Nonlinear................................................................................................................ 192 Perfect Conductor................................................................................................. 196 2D Band Solver ............................................................................................ 199 2D Band Solver Parameters ................................................................................. 199 File menu ............................................................................................................... 201 Simulation menu ................................................................................................... 201 View menu ............................................................................................................. 201 Help menu.............................................................................................................. 202 Waveguides.................................................................................................. 205 Waveguide properties........................................................................................... 205 Waveguide profiles ............................................................................................... 205 Wafer ...................................................................................................................... 208 Waveguide vs. wafer............................................................................................. 209 Initial data .............................................................................................................. 211 Local Coordinate System ..................................................................................... 211 User Interface of a Parameterized position of a Layout Shape ........................ 212 Waveguides ........................................................................................................... 214 Linear ..................................................................................................................... 216 Arc .......................................................................................................................... 222 Elliptic .................................................................................................................... 228 Ring ........................................................................................................................ 233 S-Bend Sines ......................................................................................................... 239 S-Bend Arc............................................................................................................. 239 S-Bend Sine ........................................................................................................... 244S-Bend Cosine....................................................................................................... 250 Linear Taper........................................................................................................... 256 Parabolic Taper ..................................................................................................... 262 Exponential Taper ................................................................................................. 267 S-Bend Arc Taper.................................................................................................. 273 S-Bend Sine Taper ................................................................................................ 278 S-Bend Cosine Taper............................................................................................ 285 Circular Lens ......................................................................................................... 291 Elliptic Lens ........................................................................................................... 296 Parabolic Lens....................................................................................................... 303 Hyperbolic Lens .................................................................................................... 309 Polynomial ............................................................................................................. 315 Photonic Band Gap (PBG) Crystal Structure ..................................................... 321 Basic 3D Linear Tapering and Proportional Interpretation of Fiber Profile..... 330 Input Field..................................................................................................... 339 Input Field vs. Input Plane.................................................................................... 339 Insert an input plane ............................................................................................. 340 Input Field dialog box ........................................................................................... 343 Mode—Global Data: ADI Method ......................................................................... 359 Mode Solver 2D ..................................................................................................... 379 Mode Solver 2D—menus ...................................................................................... 380 Mode Solver 2D—tabs .......................................................................................... 396 TFSF Region Properties ....................................................................................... 401 3D Mode Solver............................................................................................ 407 Main parts of the GUI ............................................................................................ 410 Main menu bar....................................................................................................... 414 Toolbars ................................................................................................................. 414 3D Mode Solver menus and buttons.......................................................... 417 File menu ............................................................................................................... 417 View menu ............................................................................................................. 417 Simulation menu ................................................................................................... 419 Data menu.............................................................................................................. 419 Preferences menu ................................................................................................. 420 Help menu.............................................................................................................. 420 3D Mode Solver functions........................................................................... 421Profile Designer menus............................................................................... 117 File menu ............................................................................................................... 117 View menu ............................................................................................................. 117 Tools menu ............................................................................................................ 117 Help menu.............................................................................................................. 117 Profile Designer context menu ............................................................................ 118 Profile Designer functions .......................................................................... 119 Library Browser..................................................................................................... 119 Compare Libraries ................................................................................................ 119 Edit Variables and Functions............................................................................... 122 Mode—Global Data: ADI Method ......................................................................... 123 Mode Settings........................................................................................................ 124 Options................................................................................................................... 125 Profiles.......................................................................................................... 127 Fiber ....................................................................................................................... 127 Channel .................................................................................................................. 131 OptiBPM Specific Diffused Materials ......................................................... 137 Custom Diffusion Processes and Arbitrary Index Profiles ............................... 137 Diffusion Process Library .................................................................................... 137 Ti:LiNb03 profile - Titanium diffusion in lithium niobate................................... 138 Ti:LiNbO 3 Pro toolbar ........................................................................................... 139 Mg:LiNb03 profile - Magnesium diffusion in lithium niobate............................ 143 Mg:LiNb0 3 Pro toolbar .......................................................................................... 144 Proton Exchange profile - H+:LiNb03.................................................................. 148 Proton Exchange toolbar ..................................................................................... 149 Annealing Process................................................................................................ 151 OptiBPM Specific User Function Profile.................................................... 153 OptiBPM Specific User DLL Profile............................................................ 159 Center point ........................................................................................................... 162 Materials ....................................................................................................... 167Mode Found........................................................................................................... 421 Status Bar .............................................................................................................. 422 3D Graph Items...................................................................................................... 422 Show slice selector............................................................................................... 426 Customize .............................................................................................................. 426 Data menu.............................................................................................................. 429 3D Graph Settings................................................................................................. 432 Layout Options...................................................................................................... 441 Observation Points, Areas, and Lines ....................................................... 445 Observation Point ................................................................................................. 445 Observation Area .................................................................................................. 445 Observation Line................................................................................................... 446 Simulation toolbar................................................................................................. 446 Observation Points...................................................................................... 447 Observation properties—Point dialog box ......................................................... 448 Observation Area......................................................................................... 451 Observation properties -- X-Z Area dialog box .................................................. 452 Observation properties -- Y-Z Area dialog box .................................................. 455 Observation properties -- X-Y Area dialog box .................................................. 457 Observation Area Analysis dialog box ............................................................... 459 Observation Line.......................................................................................... 474 Observation properties -- Vertical Line dialog box............................................ 475 OptiFDTD_Simulator (2D)............................................................................ 479 Main parts of the GUI ............................................................................................ 480 Main menu bar....................................................................................................... 483 Toolbars ................................................................................................................. 483 OptiFDTD_Simulator (2D) menus and buttons ......................................... 485 File menu ............................................................................................................... 485 View menu ............................................................................................................. 485 Simulation menu ................................................................................................... 487 Preferences menu ................................................................................................. 489Export..................................................................................................................... 597 3D Graph Items...................................................................................................... 598 Simulation menu ................................................................................................... 598 Components menu................................................................................................ 601 Preferences menu ................................................................................................. 601 OptiFDTD Tools............................................................................................ 605 Overlap Integral............................................................................................ 607 Gaussian Overlap Scanner ......................................................................... 615 Overlap Integral Scanner ............................................................................ 619 Multiple Fields .............................................................................................. 623 Notes ...................................................................................................................... 628 Multiple Gaussians ...................................................................................... 629 Notes ...................................................................................................................... 632 Confinement Factor ..................................................................................... 633 Notes ...................................................................................................................... 638 Far Field........................................................................................................ 639 Fraunhofer approximation ................................................................................... 639 Fresnel-Kirchhoff Diffraction Formula ................................................................ 640 2D Far Field............................................................................................................ 641 3D Far Field............................................................................................................ 643 References............................................................................................................. 645 Mode 2D........................................................................................................ 647 Modes of Planar Waveguides .............................................................................. 649 File menu ............................................................................................................... 650 Edit menu............................................................................................................... 650 View menu ............................................................................................................. 651 Simulation menu ................................................................................................... 651 Window menu........................................................................................................ 651Help menu.............................................................................................................. 489 Simulation Parameters ......................................................................................... 490 Boundary Conditions............................................................................................ 491 Observation Point ................................................................................................. 492 Finalization ............................................................................................................ 494 OptiFDTD_Simulator (2D) functions .......................................................... 495 View list.................................................................................................................. 495 Status bar............................................................................................................... 496 3D Graph settings ................................................................................................. 501 OptiFDTD_Simulator (3D)............................................................................ 513 Main parts of the GUI ............................................................................................ 514 Main menu bar....................................................................................................... 517 Toolbars ................................................................................................................. 517 OptiFDTD_Simulator (3D) menus and buttons ......................................... 519 File menu ............................................................................................................... 519 View menu ............................................................................................................. 519 Simulation menu ................................................................................................... 522 Preferences menu ................................................................................................. 523 Help menu.............................................................................................................. 523 Simulation Parameters ......................................................................................... 524 Boundary Conditions............................................................................................ 525 Finalization ............................................................................................................ 527 OptiFDTD_Simulator (3D) functions .......................................................... 529 View list.................................................................................................................. 529 Status bar............................................................................................................... 530 3D Graph settings ................................................................................................. 535 PWE Band Solver......................................................................................... 545 OptiFDTD_Analyzer (2D Simulations)........................................................ 553 Main parts of the GUI ............................................................................................ 554 Components .......................................................................................................... 556 Main menu bar....................................................................................................... 559Toolbars ................................................................................................................. 559 OptiFDTD_Analyzer menus and buttons (2D Simulations)...................... 561 File menu ............................................................................................................... 561 View menu ............................................................................................................. 562 Components menu................................................................................................ 563 Simulation menu ................................................................................................... 564 Preferences menu ................................................................................................. 564 Tools menu ............................................................................................................ 564 Window menu........................................................................................................ 565 Help menu.............................................................................................................. 565 OptiFDTD_Analyzer functions (2D Simulations)....................................... 567 Export..................................................................................................................... 567 3D Graph Items...................................................................................................... 568 Components menu................................................................................................ 568 Simulation menu ................................................................................................... 568 Preferences menu ................................................................................................. 571 Tools menu ............................................................................................................ 571 OptiFDTD_Analyzer (3D Simulations)........................................................ 575 Main parts of the GUI ............................................................................................ 576 Main menu bar....................................................................................................... 580 Toolbars ................................................................................................................. 580 OptiFDTD_Analyzer menus and buttons (3D simulations) ...................... 581 File menu ............................................................................................................... 581 View menu ............................................................................................................. 582 Components menu................................................................................................ 583 Simulation menu ................................................................................................... 584 Preferences menu ................................................................................................. 584 Tools menu ............................................................................................................ 584 Window menu........................................................................................................ 585 Help menu.............................................................................................................. 585 OptiFDTD_Analyzer functions (3D simulations) ....................................... 587 Analysis Tools....................................................................................................... 587Code V Converter......................................................................................... 727 Data format ............................................................................................................ 729 EXFO OWA Converter ................................................................................. 731 Zemax Converter.......................................................................................... 739 Conversion ............................................................................................................ 739 Notes on Conversion ............................................................................................ 740 Data formats .......................................................................................................... 741 ZEMAX Beam File (ZBF) binary format ............................................................... 741 Appendix A: Opti2D Graph Control............................................................ 743 User interface features ......................................................................................... 744 Graph Properties dialog ....................................................................................... 754 Appendix B: File formats ............................................................................ 763 Data file formats .................................................................................................... 763 Appendix C: Parser supported functions.................................................. 773 Supported functions ............................................................................................. 773 Function Limits and _FnRslt_.............................................................................. 778 Appendix D: Batch processing................................................................... 781 Automatic loading of VB Script from command line ......................................... 785Simulation functions............................................................................................. 652 Correlation Function Method (CFM).................................................................... 660 File menu ............................................................................................................... 661 Edit menu............................................................................................................... 661 View menu ............................................................................................................. 662 Simulation menu ................................................................................................... 662 Window menu........................................................................................................ 662 Simulation functions............................................................................................. 663 User Defined File................................................................................................... 672 File menu ............................................................................................................... 673 Edit menu............................................................................................................... 674 View menu ............................................................................................................. 674 Simulation menu ................................................................................................... 674 Window menu........................................................................................................ 674 Notes: ..................................................................................................................... 676 Mode 3D........................................................................................................ 677 File menu ............................................................................................................... 677 Edit menu............................................................................................................... 678 View menu ............................................................................................................. 678 Operations menu................................................................................................... 680 Simulation menu ................................................................................................... 680 Draw Tool menu .................................................................................................... 681 Preferences menu ................................................................................................. 681 Layout Designer Dialog boxes of Mode Solver 3D ............................................ 683 Layout Settings layout dialog box....................................................................... 702 Waveguide Colors layout dialog box .................................................................. 703 Notes: ..................................................................................................................... 704 User Guide of View 3D................................................................................. 705 Commands of View 3D ......................................................................................... 705 View menu ............................................................................................................. 707 Toolbars menu ...................................................................................................... 707 Status Bar menu.................................................................................................... 708 Settings menu ....................................................................................................... 711 Dialog boxes of View 3D....................................................................................... 713 Notes: ..................................................................................................................... 726
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值