%***********************************************************************
% 1-D FDTD code with simple radiation boundary conditions
%***********************************************************************
%
%
%
% This MATLAB M-file implements the finite-difference time-domain
% solution of Maxwell's curl equations over a one-dimensional space
% lattice comprised of uniform grid cells.
%
% To illustrate the algorithm, a sinusoidal wave (1GHz) propagating
% in a nonpermeable lossy medium (epsr=1.0, sigma=5.0e-3 S/m) is
% modeled. The simplified finite difference system for nonpermeable
% media (discussed in Section 3.6.6 of the text) is implemented.
%
% The grid resolution (dx = 1.5 cm) is chosen to provide 20
% samples per wavelength. The Courant factor S=c*dt/dx is set to
% the stability limit: S=1. In 1-D, this is the "magic time step."
%
% The computational domain is truncated using the simplest radiation
% boundary condition for wave propagation in free space:
%
% Ez(imax,n+1) = Ez(imax-1,n)
%
% To execute this M-file, type "fdtd1D" at the MATLAB prompt.
% This M-file displays the FDTD-computed Ez and Hy fields at every
% time step, and records those frames in a movie matrix, M, which is
% played at the end of the simulation using the "movie" command.
%
%***********************************************************************
clear
%***********************************************************************
% Fundamental constants
%***********************************************************************
cc=2.99792458e8; %speed of light in free space
muz=4.0*pi*1.0e-7; %permeability of free space
epsz=1.0/(cc*cc*muz); %permittivity of free space
freq=1.0e+9; %frequency of source excitation
lambda=cc/freq; %wavelength of source excitation
omega=2.0*pi*freq;
%***********************************************************************
% Grid parameters
%***********************************************************************
ie=200; %number of grid cells in x-direction
ib=ie+1;
dx=lambda/20.0; %space increment of 1-D lattice
dt=dx/cc; %time step
omegadt=omega*dt;
nmax=round(12.0e-9/dt); %total number of time steps
%***********************************************************************
% Material parameters
%***********************************************************************
eps=1.0;
sig=5.0e-3;
%***********************************************************************
% Updating coefficients for space region with nonpermeable media
%***********************************************************************
scfact=dt/muz/dx;
ca=(1.0-(dt*sig)/(2.0*epsz*eps))/(1.0+(dt*sig)/(2.0*epsz*eps));
cb=scfact*(dt/epsz/eps/dx)/(1.0+(dt*sig)/(2.0*epsz*eps));
%***********************************************************************
% Field arrays
%***********************************************************************
ez(1:ib)=0.0;
hy(1:ie)=0.0;
%***********************************************************************
% Movie initialization
%***********************************************************************
x=linspace(dx,ie*dx,ie);
subplot(2,1,1),plot(x,ez(1:ie)/scfact,'r'),axis([0 3 -1 1]);
ylabel('EZ');
subplot(2,1,2),plot(x,hy,'b'),axis([0 3 -3.0e-3 3.0e-3]);
xlabel('x (meters)');ylabel('HY');
rect=get(gcf,'Position');
rect(1:2)=[0 0];
M=moviein(nmax/2,gcf,rect);
%***********************************************************************
% BEGIN TIME-STEPPING LOOP
%***********************************************************************
for n=1:nmax
%***********************************************************************
% Update electric fields
%***********************************************************************
ez(1)=scfact*sin(omegadt*n);
rbc=ez(ie);
ez(2:ie)=ca*ez(2:ie)+cb*(hy(2:ie)-hy(1:ie-1));
ez(ib)=rbc;
%***********************************************************************
% Update magnetic fields
%***********************************************************************
hy(1:ie)=hy(1:ie)+ez(2:ib)-ez(1:ie);
%***********************************************************************
% Visualize fields
%***********************************************************************
if mod(n,2)==0;
rtime=num2str(round(n*dt/1.0e-9));
subplot(2,1,1),plot(x,ez(1:ie)/scfact,'r'),axis([0 3 -1 1]);
title(['time = ',rtime,' ns']);
ylabel('EZ');
subplot(2,1,2),plot(x,hy,'b'),axis([0 3 -3.0e-3 3.0e-3]);
title(['time = ',rtime,' ns']);
xlabel('x (meters)');ylabel('HY');
M(:,n/2)=getframe(gcf,rect);
end
%***********************************************************************
% END TIME-STEPPING LOOP
%***********************************************************************
end
movie(gcf,M,0,10,rect);


海神之光
- 粉丝: 6w+
- 资源: 7654
最新资源
- 五、AIGC大模型-09手动实现ReAct-Agent
- COMSOL实现煤体钻孔周围损伤变形 该案列考虑温度场和渗流扩散场对损伤影响,介绍钻孔周围损伤分布、损伤后瓦斯压力分布,可分析损伤后渗透率应力等 ,COMSOL模拟煤体钻孔周围损伤变形:考虑温度场与
- Jstarfish_JavaKeeper_1741869643.zip
- 数据结构_逻辑结构_存储结构_教学辅导_1741871896.zip
- 数据结构_地铁线路查询_HTML_mapboxgl_本地运行_1741874081.zip
- 8B52E5A3-F708-4C73-B2CC-5B0C7A0C3A99.zip
- 转正和答辩所用的PPT模板
- 基于 JAVA实现的行为验证码 tianai-captcha 目前支持的行为验证码类型 滑块验证码 旋转验证码 滑动还原验证码 文字点选验证码
- zbar-gtk-0.23.90-5.el8.x64-86.rpm.tar.gz
- 数据结构_哈夫曼编码_译码器_可视化教学工具_1741873260.zip
- 数据结构_Python_语言描述_教学辅助材料_1741870634.zip
- 数据结构_高级_课程作业_Lab实践_1741872828.zip
- 五、AIGC大模型-10多模态大语言模型基础知识与示例
- zbar-devel-0.23.90-5.el8.x64-86.rpm.tar.gz
- 高效质量管理,从全星FMEA开始-FMEA、PC、PFD无缝集成
- VMD-CNN-BiGRU-Attention实现时间序列预测 风速数据集 Matlab语言 你先用,你就是创新程序已调试好,无需更改代码直接替Excel运行 时间序列单列,也可以加好友成多变量的回归
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


