📄 fdtd_1d_3[1].m
字号:
% 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -