📄 soft_source_fdtd_dielectric.m
字号:
function Soft_Source_FDTD_dielectric = Soft_Source_FDTD_dielectric(time,freq)
ddx = .01;
delta_t = ddx/(2*3e8);
max_time = time;
max_space = 200; %must be divisible by two
dielectric_begin = 100;
dielectric_end = max_space;
place_pulse = 5;
nu = 0.5;
dielectric_constant = 4;
ne= nu/dielectric_constant;
dielectic_space = ones(max_space,1);
frequency = freq*1e6;
%Set up dielectric space withing the problem space
for i = 1:max_space
if (i>=dielectric_begin & i <= dielectric_end)
dielectric_space(i)=ne;
else
dielectric_space(i)=nu;
end
end
%Dielectric Medium
E = zeros(max_space,1); %Electric array
H = E; %Magnetic array
E_low_m2 = 0;
E_low_m1 = 0;
E_high_m2 = 0;
E_high_m1 = 0;
spread = 12;
center_problem_space = max_space/2;
t0 = 40.0; %((max_space/2)-2-spread)/2;
for n = 1:max_time
for k = 2:max_space
E(k) = E(k)+dielectric_space(k)*(H(k-1)-H(k));
end
pulse = sin(2*pi*frequency*delta_t*n);
E(place_pulse) = E(place_pulse) + pulse;
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);
for j = 1:max_space-1
H(j) = H(j) +nu*(E(j)-E(j+1));
end
end
plot(E)
title('Soft Source Simulation with Dieletric Constant = 4')
ylabel('E_x')
xlabel('Problem Space with Dielectric Medium from 100 to 200')
axis([0 max_space -1.2 1.2])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -