www.gusucode.com > FDTD计算二维光子带隙的程序 > FDTD计算二维光子带隙的程序/247787/UserDefinedStructure.m
function UserDefinedStructure %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Electromagnetic Finite-Difference Time-Domain % % Version 1.20, Release 1 % % % % (C) Copyright 2005 % % Sharif University of Technology % % School of Electrical Engineering % % All Rights Reserved % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% global xCnt yCnt StructureType xCells yCells global Mu Epsilon Air Silicon GaAs Cnt LatticeCnt Cnt=LatticeCnt; % Number of grid points per unit cell if StructureType <= 0 % Simple Square Cell xCnt=Cnt*xCells; yCnt=Cnt*yCells; elseif StructureType == 1 % Simple Triangular Cell xCnt=Cnt*xCells; yCnt=round(Cnt*sqrt(3))*yCells; end SquareBandRodsExample %SquareBandHolesExample %TriangularBandHolesExample %DefectExample %WaveguideRodsExample %TriangularGKWaveguideExample function SquareBandRodsExample % Must set xCells and yCells to 1 global xCnt yCnt StructureType xCells yCells global Mu Epsilon Air Silicon GaAs Cnt LatticeCnt EpsilonHole=Silicon; EpsilonHost=Air; Radius=0.25; % Ratio of Rod Radius to Lattice Constant Host=ones(xCnt,yCnt)*EpsilonHost; Cell=PutHole(Host,(xCnt+1)/2,(yCnt+1)/2,Radius,EpsilonHole); Epsilon=Cell; Mu=ones(xCnt,yCnt); function SquareBandHolesExample % Must set xCells and yCells to 1, StructureType to 0, and % BoundaryType to 1 global xCnt yCnt StructureType xCells yCells global Mu Epsilon Air Silicon GaAs Cnt LatticeCnt EpsilonHole=Air; EpsilonHost=Silicon; Radius=0.45; % Ratio of Hole Radius to Lattice Constant Host=ones(xCnt,yCnt)*EpsilonHost; Cell=PutHole(Host,(xCnt+1)/2,(yCnt+1)/2,Radius,EpsilonHole); Epsilon=Cell; Mu=ones(xCnt,yCnt); function DefectExample % Must set xCells and yCells to 7, StructureType to 0, and % BoundaryType to 6 global xCnt yCnt StructureType xCells yCells global Mu Epsilon Air Silicon GaAs Cnt LatticeCnt EpsilonHole=Silicon; EpsilonHost=Air; Radius=0.25; % Ratio of Rod Radius to Lattice Constant Cell=ones(Cnt,Cnt)*EpsilonHost; Cell=PutHole(Cell,(Cnt+1)/2,(Cnt+1)/2,Radius,EpsilonHole); Dfct=Host; Epsilon=[ Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Dfct Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell Cell ]; Mu=ones(xCnt,yCnt); function WaveguideRodsExample % Must set xCells to 1 and yCells to 7, StructureType to 0, and % BoundaryType to 4 global xCnt yCnt StructureType xCells yCells global Mu Epsilon Air Silicon GaAs Cnt LatticeCnt EpsilonHole=Silicon; EpsilonHost=Air; Radius=0.25; % Ratio of Rod Radius to Lattice Constant Cell=ones(Cnt,Cnt)*EpsilonHost; Cell=PutHole(Cell,(Cnt+1)/2,(Cnt+1)/2,Radius,EpsilonHole); Dfct=Host; Epsilon=[Cell Cell Cell Dfct Cell Cell Cell]; Mu=ones(xCnt,yCnt); function TriangularBandHolesExample % Must set xCells and yCells to 1, StructureType to 1, and % BoundaryType to 1 global xCnt yCnt StructureType xCells yCells global Mu Epsilon Air Silicon GaAs Cnt LatticeCnt EpsilonHole=Air; EpsilonHost=Silicon; Radius=0.30; % Ratio of Hole Radius to Lattice Constant Host=ones(xCnt,yCnt)*EpsilonHost; Cell=PutHole(Host,(xCnt+1)/2,(yCnt+1)/2,Radius,EpsilonHole); Cell=PutHole(Cell,1 , 1,Radius,EpsilonHole); Cell=PutHole(Cell,1 ,yCnt,Radius,EpsilonHole); Cell=PutHole(Cell,xCnt, 1,Radius,EpsilonHole); Cell=PutHole(Cell,xCnt,yCnt,Radius,EpsilonHole); Epsilon=Cell; Mu=ones(xCnt,yCnt); function TriangularGKWaveguideExample % Must set xCells to 1 and yCells to 7, StructureType to 1, and % BoundaryType to 6 global xCnt yCnt StructureType xCells yCells global Mu Epsilon Air Silicon GaAs Cnt LatticeCnt EpsilonHole=Air; EpsilonHost=Silicon; Radius=0.30; % Ratio of Hole Radius to Lattice Constant Host=ones(xCnt,yCnt/yCells)*EpsilonHost; Cell=PutHole(Host,1 , 1,Radius,EpsilonHole); Cell=PutHole(Cell,1 ,yCnt/yCells,Radius,EpsilonHole); Cell=PutHole(Cell,xCnt, 1,Radius,EpsilonHole); Dfct=PutHole(Cell,xCnt,yCnt/yCells,Radius,EpsilonHole); Cell=PutHole(Dfct,(xCnt+1)/2,(yCnt/yCells+1)/2,Radius,EpsilonHole); Epsilon=[Cell Cell Cell Dfct Cell Cell Cell]; Mu=ones(xCnt,yCnt);