背景:

基于公式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的更多相关文章

  1. 《FDTD electromagnetic field using MATLAB》读书笔记 Figure 1.2

    函数f(x)用采样间隔Δx=π/5进行采样,使用向前差商.向后差商和中心差商三种公式来近似一阶导数. 书中代码: %% ---------------------------------------- ...

  2. 《FDTD electromagnetic field using MATLAB》读书笔记之一阶、二阶偏导数差商近似

  3. 《FDTD electromagnetic field using MATLAB 》读书笔记001-差商种类

    有限差分就是用差商代替微商,有3钟: 1.向前差商 2.向后差商 3.中心差商 上面三张途中虚线就是函数在x的精确微商(偏导数),直线就是用来代替精确 微商的差商格式.

  4. Python基础教程【读书笔记】 - 2016/7/14

    希望通过博客园持续的更新,分享和记录Python基础知识到高级应用的点点滴滴! 第六波:第2章  列表和元组 [总览]  数据结构,是通过某种方式组织在一起的数据元素的集合,数据元素可以使数字或字符串 ...

  5. 读书笔记 effective c++ Item 14 对资源管理类的拷贝行为要谨慎

    1. 自己实现一个资源管理类 Item 13中介绍了 “资源获取之时也是初始化之时(RAII)”的概念,这个概念被当作资源管理类的“脊柱“,也描述了auto_ptr和tr1::shared_ptr是如 ...

  6. TJI读书笔记17-字符串

    TJI读书笔记17-字符串 不可变的String 重载”+”和StringBuilder toString()方法的一个坑 String上的操作 格式化输出 Formatter类 字符串操作可能是计算 ...

  7. 《Linux内核设计与实现》 Chapter4 读书笔记

    <Linux内核设计与实现> Chapter4 读书笔记 调度程序负责决定将哪个进程投入运行,何时运行以及运行多长时间,进程调度程序可看做在可运行态进程之间分配有限的处理器时间资源的内核子 ...

  8. ANTLR3完全参考指南读书笔记[06]

    前言 这段时间在公司忙的跟狗似的,但忙的是没多少技术含量的活儿. 终于将AST IR和tree grammar过了一遍,计划明天写完这部分的读书笔记.   内容 1 内部表示AST构建 2 树文法   ...

  9. 认识CLR [《CLR via C#》读书笔记]

    认识CLR [<CLR via C#>读书笔记] <CLR via C#>读书笔记 什么是CLR CLR的基本概念 通用语言运行平台(Common Language Runti ...

随机推荐

  1. MyBtis—原理及初始化

    Mybatis的功能架构分为三层: 1)       API接口层:提供给外部使用的接口API,开发人员通过这些本地API来操纵数据库.接口层 一接收到调用请求就会调用数据处理层来完成具体的数据处理. ...

  2. VS2010/MFC编程入门之九(对话框:为控件添加消息处理函数)

    创建对话框类和添加控件变量在上一讲中已经讲过,这一讲的主要内容是如何为控件添加消息处理函数. MFC为对话框和控件等定义了诸多消息,我们对它们操作时会触发消息,这些消息最终由消息处理函数处理.比如我们 ...

  3. 11月16host文件

    #################################################################################################### ...

  4. office 2010 安装时出错 MSXML版本6.10.1129.0

    微软下载网址:https://www.microsoft.com/zh-cn/download/details.aspx?id=6276&751be11f-ede8-5a0c-058c-2ee ...

  5. python排序算法实现(冒泡、选择、插入)

    python排序算法实现(冒泡.选择.插入) python 从小到大排序 1.冒泡排序: O(n2) s=[3,4,2,5,1,9] #count = 0 for i in range(len(s)) ...

  6. windows10添加开机自启动程序

    1. 将要启动的程序创建快捷方式 2. 将创建的快捷方式放到以下文件夹中 C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

  7. linux开启nscd服务缓存加速

    在我使用的阿里云主机上有观察到开启了一个服务nscd ,后来谷哥了下该服务的作用.了解到nscd会缓存三种服务passwd group hosts,所以它会记录三个库,分别对应源/etc/passwd ...

  8. POJ 1170 Shopping Offers(完全背包+哈希)

    http://poj.org/problem?id=1170 题意:有n种花的数量和价格,以及m种套餐买法(套餐会便宜些),问最少要花多少钱. 思路:题目是完全背包,但这道题目不好处理的是套餐的状态, ...

  9. Python在七牛云平台的应用(一)

    七牛云:(引用百度的介绍)七牛云是国内领先的企业级公有云服务商,致力于打造以数据为核心的场景化PaaS服务.围绕富媒体场景,七牛先后推出了对象存储,融合CDN加速,数据通用处理,内容反垃圾服务,以及直 ...

  10. 位于/var/log目录下的20个Linux日志文件

    位于/var/log目录下的20个Linux日志文件[译] from:http://buptguo.com/2014/01/16/linux-var-log-files/ 原文地址:20 Linux ...