背景:

基于公式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. idea使用插件activate-power-mode给编码加上特效和带来乐趣。

    一.安装. 1. 2. 二.使用. 1. 2.

  2. Spring整合Mybatis 之分页插件使用

    [分页插件项目中的正式代码一共有个5个Java文件,这5个文件的说明如下] Page<E>[必须]:分页参数类,该类继承ArrayList,虽然分页查询返回的结果实际类型是Page< ...

  3. java--jvm启动的参数

    java启动参数共分为三类其一是标准参数(-),所有的JVM实现都必须实现这些参数的功能,而且向后兼容:其二是非标准参数(-X),默认jvm实现这些参数的功能,但是并不保证所有jvm实现都满足,且不保 ...

  4. sqoop2-1.99.5-cdh5.5.4.tar.gz的部署搭建

    不多说,直接上干货! 首先,说下博主我,为什么,好端端的Sqoop1用的好好的,然后又安装和学习Sqoop2? 因为,在Cloudera Hue里的Sqoop,是需要Sqoop2. HUE配置文件hu ...

  5. c++第二十天

    p111~p114: 与旧代码的接口 1.C++程序中的C风格字符串:任何出现字符串字面值的地方都可以以空字符结束的字符数组来替代. const char str[] = {"Hello, ...

  6. DigitalOcean(edu用户)搭建VPS

    免费上网FQ edu福利 edu邮箱 VPS VPN 1 申请 目的:利用edu邮箱的优惠获得digitalocean一年vpn,可以FQ或者免流. 1.1 准备工作 百度“github大礼包”,浏览 ...

  7. TCGA下载神器--TCGAbiolinks

    http://bioconductor.org/packages/devel/bioc/vignettes/TCGAbiolinks/inst/doc/tcgaBiolinks.html#gdcque ...

  8. c语言 找最小值

    #include <stdio.h> #define N 10 #define MIN(X,Y) ((X<Y)?(X):(Y)) int f(int arr[],int len,in ...

  9. Java回顾之ORM框架

    这篇文章里,我们主要讨论ORM框架,以及在使用上和JDBC的区别. 概述 ORM框架不是一个新话题,它已经流传了很多年.它的优点在于提供了概念性的.易于理解的数据模型,将数据库中的表和内存中的对象建立 ...

  10. [翻译]PyMongo官方文档

    PyMongo官方文档翻译 周煦辰 2016-06-30 这是本人翻译的PyMongo官方文档.现在网上分(抄)享(袭)的PyMongo博客文章很多,一方面这些文章本就是抄袭的,谈不上什么格式美观,另 ...