《FDTD electromagnetic field using MATLAB》读书笔记之 Figure 1.14
背景:
基于公式1.42(Ez分量)、1.43(Hy分量)的1D FDTD实现。
计算电场和磁场分量,该分量由z方向的电流片Jz产生,Jz位于两个理想导体极板中间,两个极板平行且向y和z方向无限延伸。
平行极板相距1m,差分网格Δx=1mm。
电流面密度导致分界面(电流薄层)磁场分量的不连续,在两侧产生Hy的波,每个强度为5×10^(-4)A/m。因为电磁波在自由空间中传播,本征阻抗为η0。
显示了从左右极板反射前后的传播过程。本例中是PEC边界,正切电场分量(Ez)在PEC表面消失。
观察图中step650到700的场的变换情况,经过PEC板的入射波和反射波的传播特征。经过PEC反射后,Ez的极性变反,这是因为反射系数等于-1;
而磁场分量Hy没有反向,反射系数等于1。
下面是书中的代码(几乎没动):
第1个是主程序:
%% ------------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n****************************************************************\n');
fprintf('\n <FDTD 4 ElectroMagnetics with MATLAB Simulations> \n');
fprintf('\n Listing A.1 \n\n'); time_stamp = datestr(now, 31);
[wkd1, wkd2] = weekday(today, 'long');
fprintf(' Now is %20s, and it is %7s \n\n', time_stamp, wkd2);
%% ------------------------------------------------------------------------------ % This program demonstrates a one-dimensional FDTD simulation.
% The problem geometry is composed of two PEC plates extending to
% infinity in y and z dimensions, parallel to each other with 1 meter
% separation. The space between the PEC plates is filled with air.
% A sheet of current source paralle to the PEC plates is placed
% at the center of the problem space. The current source excites fields
% in the problem space due to a z-directed current density Jz,
% which has a Gaussian waveform in time. % Define initial constants
eps_0 = 8.854187817e-12; % permittivity of free space
mu_0 = 4*pi*1e-7; % permeability of free space
c = 1/sqrt(mu_0*eps_0); % speed of light % Define problem geometry and parameters
domain_size = 1; % 1D problem space length in meters
dx = 1e-3; % cell size in meters, Δx=0.001m
dt = 3e-12; % duration of time step in seconds
number_of_time_steps = 2000; % number of iterations
nx = round(domain_size/dx); % number of cells in 1D problem space
source_position = 0.5; % position of the current source Jz % Initialize field and material arrays
Ceze = zeros(nx+1, 1);
Cezhy = zeros(nx+1, 1);
Cezj = zeros(nx+1, 1);
Ez = zeros(nx+1, 1);
Jz = zeros(nx+1, 1);
eps_r_z = ones (nx+1, 1); % free space
sigma_e_z = zeros(nx+1, 1); % free space Chyh = zeros(nx, 1);
Chyez = zeros(nx, 1);
Chym = zeros(nx, 1);
Hy = zeros(nx, 1);
My = zeros(nx, 1);
mu_r_y = ones (nx, 1); % free space
sigma_m_y = zeros(nx, 1); % free space % Calculate FDTD updating coefficients
Ceze = (2 * eps_r_z * eps_0 - dt * sigma_e_z) ...
./(2 * eps_r_z * eps_0 + dt * sigma_e_z); Cezhy = (2 * dt / dx) ...
./(2 * eps_r_z * eps_0 + dt * sigma_e_z); Cezj = (-2 * dt) ...
./(2 * eps_r_z * eps_0 + dt * sigma_e_z); Chyh = (2 * mu_r_y * mu_0 - dt * sigma_m_y) ...
./(2 * mu_r_y * mu_0 + dt * sigma_m_y); Chyez = (2 * dt / dx) ...
./(2 * mu_r_y * mu_0 + dt * sigma_m_y); Chym = (-2 *dt) ...
./(2 * mu_r_y * mu_0 + dt * sigma_m_y); % Define the Gaussian source waveform
time = dt * [0:number_of_time_steps-1].';
Jz_waveform = exp(-((time-2e-10)/5e-11).^2)*1e-3/dx;
source_position_index = round(nx * source_position/domain_size)+1; % Subroutine to initialize plotting
initialize_plotting_parameters; % FDTD loop
for time_step = 1:number_of_time_steps % Update Jz for the current time step
Jz(source_position_index) = Jz_waveform(time_step); % Update magnetic field
Hy(1:nx) = Chyh(1:nx) .* Hy(1:nx) ...
+ Chyez(1:nx) .* (Ez(2:nx+1) - Ez(1:nx)) ...
+ Chym(1:nx) .* My(1:nx); % Update electric field
Ez(2:nx) = Ceze (2:nx) .* Ez(2:nx) ...
+ Cezhy(2:nx) .* (Hy(2:nx) - Hy(1:nx-1)) ...
+ Cezj (2:nx) .* Jz(2:nx); Ez(1) = 0; % Apply PEC boundary condition at x = 0 m
Ez(nx+1) = 0; % Apply PEC boundary condition at x = 1 m % Subroutine to plot the current state of the fields
plot_fields;
end
第2个是initialize_plotting_parameters,看名字就知道是初始化参数:
% Subroutine used to initialize 1D plot Ez_positions = [0:nx]*dx;
Hy_positions = ([0:nx-1]+0.5)*dx;
v = [0 -0.1 -0.1; 0 -0.1 0.1; 0 0.1 0.1; 0 0.1 -0.1; ...
1 -0.1 -0.1; 1 -0.1 0.1; 1 0.1 0.1; 1 0.1 -0.1]; f = [1 2 3 4; 5 6 7 8];
axis([0 1 -0.2 0.2 -0.2 0.2]);
lez = line(Ez_positions, Ez*0, Ez, 'Color', 'b', 'linewidth', 1.5);
lhy = line(Hy_positions, 377*Hy, Hy*0, 'Color', 'r', 'LineWidth', 1.5, 'LineStyle','-.'); set(gca, 'fontsize', 12, 'fontweight', 'bold');
set(gcf,'Color','white');
axis square;
legend('E_{z}', 'H_{y} \times 377', 'location', 'northeast');
xlabel('x [m]');
ylabel('[A/m]');
zlabel('[V/m]');
grid on; p = patch('vertices', v, 'faces', f, 'facecolor', 'g', 'facealpha', 0.2);
text(0, 1, 1.1, 'PEC', 'horizontalalignment', 'center', 'fontweight', 'bold');
text(1, 1, 1.1, 'PEC', 'horizontalalignment', 'center', 'fontweight', 'bold');
第3个就是画图:
% Subroutine used to plot 1D transient field delete(lez);
delete(lhy);
lez = line(Ez_positions, Ez*0, Ez, 'Color', 'b', 'LineWidth', 1.5);
lhy = line(Hy_positions, 377*Hy, Hy*0, 'Color', 'r', 'LineWidth', 1.5, 'LineStyle', '-.');
ts = num2str(time_step);
ti = num2str(dt*time_step*1e9);
title(['time step = ' ts ' , time = ' ti ' ns']);
drawnow;
运行结果:






上图,从PEC板反射后,电场分量极性变反,磁场分量极性不变。








反射后,电场分量极性再次改变;


《FDTD electromagnetic field using MATLAB》读书笔记之 Figure 1.14的更多相关文章
- 《FDTD electromagnetic field using MATLAB》读书笔记 Figure 1.2
函数f(x)用采样间隔Δx=π/5进行采样,使用向前差商.向后差商和中心差商三种公式来近似一阶导数. 书中代码: %% ---------------------------------------- ...
- 《FDTD electromagnetic field using MATLAB》读书笔记之一阶、二阶偏导数差商近似
- 《FDTD electromagnetic field using MATLAB 》读书笔记001-差商种类
有限差分就是用差商代替微商,有3钟: 1.向前差商 2.向后差商 3.中心差商 上面三张途中虚线就是函数在x的精确微商(偏导数),直线就是用来代替精确 微商的差商格式.
- Python基础教程【读书笔记】 - 2016/7/14
希望通过博客园持续的更新,分享和记录Python基础知识到高级应用的点点滴滴! 第六波:第2章 列表和元组 [总览] 数据结构,是通过某种方式组织在一起的数据元素的集合,数据元素可以使数字或字符串 ...
- 读书笔记 effective c++ Item 14 对资源管理类的拷贝行为要谨慎
1. 自己实现一个资源管理类 Item 13中介绍了 “资源获取之时也是初始化之时(RAII)”的概念,这个概念被当作资源管理类的“脊柱“,也描述了auto_ptr和tr1::shared_ptr是如 ...
- TJI读书笔记17-字符串
TJI读书笔记17-字符串 不可变的String 重载”+”和StringBuilder toString()方法的一个坑 String上的操作 格式化输出 Formatter类 字符串操作可能是计算 ...
- 《Linux内核设计与实现》 Chapter4 读书笔记
<Linux内核设计与实现> Chapter4 读书笔记 调度程序负责决定将哪个进程投入运行,何时运行以及运行多长时间,进程调度程序可看做在可运行态进程之间分配有限的处理器时间资源的内核子 ...
- ANTLR3完全参考指南读书笔记[06]
前言 这段时间在公司忙的跟狗似的,但忙的是没多少技术含量的活儿. 终于将AST IR和tree grammar过了一遍,计划明天写完这部分的读书笔记. 内容 1 内部表示AST构建 2 树文法 ...
- 认识CLR [《CLR via C#》读书笔记]
认识CLR [<CLR via C#>读书笔记] <CLR via C#>读书笔记 什么是CLR CLR的基本概念 通用语言运行平台(Common Language Runti ...
随机推荐
- Entity Framework Code First级联删除(转)
使用Data Annotations: 如果我们要到一对主从表增加级联删除,则要在主表中的引用属性上增加Required关键字,如: public class Destination { public ...
- Flask添加翻页功能(非sqlalchemy)
最近做flask的项目,需要增加翻页的功能,网上找的教程都是结合sqlalchemy的,可是我用的不是sqlalchemy,肿木办呢? 以下是我的做法 一.前端 1.传递页码 前端我使用ajax提交表 ...
- springcloud19---springCloudConfig
Spring-cloud-config : 统一管理配置的组件,不同的环境不同的管理(连接池.数据库配置不一样).不同时间需要动态调整配置(双十一最大连接数要大). 分布式配置也可以使用config或 ...
- MySql如何安装?
官方网址:https://www.mysql.com/downloads/ Community——>MySqlCommunity Server->GA->64位: GA:正式版: C ...
- kali linux 安装过程
kali linux 安装过程 获取镜像文件 首先需要去官网获取kali linux的镜像文件,本来获取了kali的最新版,由于有些方面还没有得到完善,与VM还没有完全兼容,所以换了视频上的1.0.8 ...
- 课堂练习——Hash 20162305
课堂练习--Hash 20162305 课堂练习要求 利用除留余数法为下列关键字集合的存储设计hash函数,并画出分别用开放寻址法和拉链法解决冲突得到的空间存储状态(散列因子取0.75) 关键字集合: ...
- Nginx反向代理缓冲区优化
内容目录 proxy_buffering proxy_buffer_size proxy_buffers proxy_busy_buffers_size proxy_max_temp_file_siz ...
- __autoload自动加载类
在使用PHP的OO模式开发系统时,通常大家习惯上将每个类的实现都存放在一个单独的文件里,这样会很容易实现对类进行复用,同时将来维护时也很便利.这也是OO设计的基本思想之一.在PHP5之前,如果需要使用 ...
- SRM 585 DIV2
250pt: 一水... 500pt:题意: 给你一颗满二叉树的高度,然后找出出最少的不想交的路径并且该路径每个节点只经过一次. 思路:观察题目中给的图就会发现,其实每形成一个 就会存在一条路径. 我 ...
- 2016"百度之星" - 初赛(Astar Round2A) A.All X 矩阵快速幂
All X Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Des ...