fdtd_1d_3[1].m

来自「fdtd一维到三维算法」· M 代码 · 共 97 行

M
97
字号
% Excercise 3% 1D FDTD free space propagation% modified programme (using Absorbing boundary condition ABC)% Note: ABC works only in 1D - need Perfectly Matched Layer (PML)%       for 2D and 3D problems.% Coded by Pradip Mukhopadhyay% 7 March 2005%% For EEE355F AJW%%%%KE = 201;                %number of grid in z directionkc = fix(KE/2) ;           % centre of the gridex = zeros(1,KE);         % initilize the Ex fieldhy = zeros(1,KE);         % initilize the Hy fieldcb = zeros(1,KE);cb(1,:) = 0.5;% Constant for ABCex_left_m1 = 0.0;ex_left_m2 = 0.0;ex_right_m1 = 0.0;ex_right_m2 = 0.0;% A Gaussian pulset0 = 36.0 ;spread = 12 ;NSTEPS = 300 ;          % number of time stepsfor n=1:NSTEPS    for k=2:KE        ex(1,k) = ex(1,k) + cb(1,k).*(hy(1,k-1) -hy(1,k));    end    pulse = exp(-0.5*((t0-n)/spread)^2.0);    %The Gaussian pulse    ex(1,kc) = pulse;                      % adding the pulse at the centre of the grid    ex(1,1) = ex_left_m2;                       % left boundary    ex_left_m2= ex_left_m1;    ex_left_m1 = ex(1,2);    ex(1,KE) = ex_right_m2;                  % right boundary    ex_right_m2= ex_right_m1;    ex_right_m1 = ex(1,KE-1);    for k=1:KE-1        hy(1,k) = hy(1,k) + 0.5*(ex(1,k) -ex(1,k+1));    end    plot(ex);    axis([1 KE -1 1]);    title('1D EM Propagation - ABC boundary condition')    pause(0.01);end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?