📄 abc_free_space.m
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ABC_Free_Space FDTD with absorbing boundary conditions
% ABC_Free_Space(T) Implements a gaussian pulse through the
% problem space for T time steps.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function ABC_Free_Space = ABC_Free_Space(time)
max_time = time;
max_space = 200; %must be divisible by two
eta = 0.5;
%Initialize arrays
E = zeros(max_space,1); %Electric array
H = E; %Magnetic array
%Initialize values for ABC
E_low_m2 = 0;
E_low_m1 = 0;
E_high_m2 = 0;
E_high_m1 = 0;
%Initialize values for pulse
spread = 12;
center_problem_space = max_space/2;
t0 = 40;
place_pulse = 5;
%Main FDTD Loop
for n = 1:max_time
%Loop for E_x
for k = 2:max_space
E(k) = E(k) + eta*( H(k-1)-H(k) );
end
pulse = exp(-.5*((t0-n)/spread)^2);
E(center_problem_space) = E(center_problem_space) + pulse;
%ABC E
E(1) = E_low_m2;
E_low_m2 = E_low_m1;
E_low_m1 = E(2);
E(max_space) = E_high_m2;
E_high_m2 = E_high_m1;
E_high_m1 = E(max_space-1);
%Loop for H_y
for j = 1:max_space-1
H(j) = H(j) + eta*( E(j)-E(j+1) );
end
end
figure(1)
plot(E,'r')
ylabel('E_x')
axis([0 max_space -1.1 1.1])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -