广义麦克斯韦方程(线性、均匀、各向同性)
Δ × H ⃗ = ε ∂ E ∂ t + σ e E + J i \Delta \times \vec H = \varepsilon \frac{\partial E}{\partial t} + \sigma^{e} E +J_i Δ×H=ε∂t∂E+σeE+Ji ( 1.3 a ) (1.3a) (1.3a)
Δ × E ⃗ = μ ∂ H ∂ t + σ m E + M i \Delta \times \vec E = \mu \frac{\partial H}{\partial t} + \sigma^{m} E +M_i Δ×E=μ∂t∂H+σmE+Mi ( 1.3 b ) (1.3b) (1.3b)
σ e \sigma^{e} σe为电导率, J i J_i Ji 为施加电流密度, σ m \sigma^{m} σm为导磁系数**(与电导率对应,非磁导率)**, M i M_i Mi为施加磁流密度。
方程由两个矢量方程组成,在三维空间每个矢量可以分解为 3 个标量方程。因此麦克斯韦旋度方程可以表示为 6 个标量方程,在直角坐标系下,有
∂ E x ∂ t = 1 ε x ( ∂ H z ∂ y − ∂ H y ∂ z − σ x e E x − J i x ) \frac{\partial E_x}{\partial t}=\frac{1}{\varepsilon_x} ( \frac{\partial H_z}{\partial y}- \frac{\partial H_y}{\partial z}-\sigma^{e}_x E_x - J_{ix}) ∂t∂Ex=εx1(∂y∂Hz−∂z∂Hy−σxeEx−Jix) ( 1.4 a ) (1.4a) (1.4a)
∂ E y ∂ t = 1 ε y ( ∂ H x ∂ z − ∂ H z ∂ x − σ y e E y − J i y ) \frac{\partial E_y}{\partial t}=\frac{1}{\varepsilon_y} ( \frac{\partial H_x}{\partial z}- \frac{\partial H_z}{\partial x}-\sigma^{e}_y E_y - J_{iy}) ∂t∂Ey=εy1(∂z∂Hx−∂x∂Hz−σyeEy−Jiy) ( 1.4 b ) (1.4b) (1.4b)
∂ E z ∂ t = 1 ε z ( ∂ H y ∂ x − ∂ H x ∂ y − σ z e E z − J i z ) \frac{\partial E_z}{\partial t}=\frac{1}{\varepsilon_z} ( \frac{\partial H_y}{\partial x}- \frac{\partial H_x}{\partial y}-\sigma^{e}_z E_z - J_{iz}) ∂t∂Ez=εz1(∂x∂Hy−∂y∂Hx−σzeEz−Jiz) ( 1.4 c ) (1.4c) (1.4c)
∂ H x ∂ t = 1 μ x ( ∂ E y ∂ z − ∂ E z ∂ y − σ x m H x − M i x ) \frac{\partial H_x}{\partial t}=\frac{1}{\mu_x} ( \frac{\partial E_y}{\partial z}- \frac{\partial E_z}{\partial y}-\sigma^{m}_x H_x - M_{ix}) ∂t∂Hx=μx1(∂z∂Ey−∂y∂Ez−σxmHx−Mix) ( 1.4 d ) (1.4d) (1.4d)
∂ H y ∂ t = 1 μ y ( ∂ E z ∂ x − ∂ E x ∂ z − σ y m H y − M i y ) \frac{\partial H_y}{\partial t}=\frac{1}{\mu_y} ( \frac{\partial E_z}{\partial x}- \frac{\partial E_x}{\partial z}-\sigma^{m}_y H_y -M_{iy}) ∂t∂Hy=μy1(∂x∂Ez−∂z∂Ex−σymHy−Miy) ( 1.4 e ) (1.4e) (1.4e)
∂ H z ∂ t = 1 μ z ( ∂ E x ∂ y − ∂ E y ∂ x − σ z m E z − M i z ) \frac{\partial H_z}{\partial t}=\frac{1}{\mu_z} ( \frac{\partial E_x}{\partial y}- \frac{\partial E_y}{\partial x}-\sigma^{m}_z E_z -M_{iz}) ∂t∂Hz=μz1(∂y∂Ex−∂x∂Ey−σzmEz−Miz) ( 1.4 f ) (1.4f) (1.4f)
FDTD 的计算,首先用有限差分来近似麦克斯韦方程中的空间和时间导数;其次构造一组方程,以前一时间步瞬时场值来计算后一时间步瞬时场值,由此来构造时间向前推进的算法,以模拟电磁场在时域的进程。
前向差分公式(一阶精度)
f ’ ( x ) ≃ f ( x + Δ x ) − f ( x ) Δ x f’(x) \simeq \frac{f(x+ \Delta x)-f(x)}{\Delta x} f’(x)≃Δxf(x+Δx)−f(x) ( 1.6 ) (1.6) (1.6)
后向差分公式(一阶精度)
f ’ ( x ) ≃ f ( x ) − f ( x − Δ x ) Δ x f’(x) \simeq \frac{f(x)-f(x-\Delta x)}{\Delta x} f’(x)≃Δxf(x)−f(x−Δx) ( 1.7 ) (1.7) (1.7)
中心差分公式(二阶精度)
f ’ ( x ) ≃ f ( x + Δ x ) − f ( x − Δ x ) 2 Δ x f’(x) \simeq \frac{f(x+ \Delta x)-f(x- \Delta x)}{2\Delta x} f’(x)≃2Δxf(x+Δx)−f(x−Δx) ( 1.8 ) (1.8) (1.8)
虽然文献中有基于高阶精度差分公式的 FDTD 算法,但常规的 FDTD 算法是基于有二阶精度的中心差分公式的算法,这种算法在大多数电磁应用中精度是足够的,具有编程简单、易于理解的特点。
在一维情况下,场分布与另两个坐标变量无关。例如,如果研究 x x x 坐标轴上的一维问题,则在麦克斯韦两个旋度方程中对 y , z y,z y,z的导数就为零。因此旋度方程 (1.4) 可重写为
∂ E x ∂ t = 1 ε x ( − σ x e E x − J i x ) \frac{\partial E_x}{\partial t}=\frac{1}{\varepsilon_x} ( -\sigma^{e}_x E_x - J_{ix}) ∂t∂Ex=εx1(−σxeEx−Jix) ( 1. a 39 ) (1.a39) (1.a39)
∂ E y ∂ t = 1 ε y ( − ∂ H z ∂ x − σ y e E y − J i y ) \frac{\partial E_y}{\partial t}=\frac{1}{\varepsilon_y} ( - \frac{\partial H_z}{\partial x}-\sigma^{e}_y E_y - J_{iy}) ∂t∂Ey=εy1(−∂x∂Hz−σyeEy−Jiy) ( 1.39 b ) (1.39b) (1.39b)
∂ E z ∂ t = 1 ε z ( ∂ H y ∂ x − σ z e E z − J i z ) \frac{\partial E_z}{\partial t}=\frac{1}{\varepsilon_z} ( \frac{\partial H_y}{\partial x}-\sigma^{e}_z E_z - J_{iz}) ∂t∂Ez=εz1(∂x∂Hy−σzeEz−Jiz) ( 1.39 c ) (1.39c) (1.39c)
∂ H x ∂ t = 1 μ x ( − σ x m H x − M i x ) \frac{\partial H_x}{\partial t}=\frac{1}{\mu_x} (-\sigma^{m}_x H_x - M_{ix}) ∂t∂Hx=μx1(−σxmHx−Mix) ( 1.39 d ) (1.39d) (1.39d)
∂ H y ∂ t = 1 μ y ( ∂ E z ∂ x − σ y m H y − M i y ) \frac{\partial H_y}{\partial t}=\frac{1}{\mu_y} ( \frac{\partial E_z}{\partial x}-\sigma^{m}_y H_y -M_{iy}) ∂t∂Hy=μy1(∂x∂Ez−σymHy−Miy) ( 1.39 e ) (1.39e) (1.39e)
∂ H z ∂ t = 1 μ z ( − ∂ E y ∂ x − σ z m E z − M i z ) \frac{\partial H_z}{\partial t}=\frac{1}{\mu_z} ( - \frac{\partial E_y}{\partial x}-\sigma^{m}_z E_z -M_{iz}) ∂t∂Hz=μz1(−∂x∂Ey−σzmEz−Miz) ( 1.39 f ) (1.39f) (1.39f)
注意方程 (1.39a) 和 (1.39d) 仅包含对时间的导数而不包含对空间的导数,因此这些方程不代表传播场,场分量 E x E_x Ex与 H x H_x Hx 仅存在在方程中而不传播。其他四个方程代表传播场,四个方程中的电场和磁场对于 x x x 轴均为横向场,因此在一维情况下存在 TEM 波。
方程 (1.39b) 与 (1.39f) 仅含 E y E_y Ey 与 H z H_z Hz 两项,方程 (1.39c) 与 (1.39e) 仅含 E z E_z Ez 与 H y H_y Hy两项,两组方程可以分开研究。
(1)电场 y y y 分量更新方程
E y n + 1 ( i ) = C e y e ( i ) × E y n ( i ) + C e y e h z ( i ) × ( H z n + 1 / 2 ( i ) − H z n + 1 / 2 ( i − 1 ) ) + C e y j ( i ) × J i y n + 1 / 2 ( i ) E^{n+1}_y(i) =C_{eye}(i)\times E^{n}_y(i) +C_{eyehz}(i)\times (H^{n+1/2}_z(i) -H^{n+1/2}_z(i-1))+C_{eyj}(i)\times J^{n+1/2}_{iy}(i) Eyn+1(i)=Ceye(i)×Eyn(i)+Ceyehz(i)×(Hzn+1/2(i)−Hzn+1/2(i−1))+Ceyj(i)×Jiyn+1/2(i) (1.40)
式中
C e y e ( i ) = 2 ε y ( i ) − Δ t σ y e ( i ) 2 ε y ( i ) + Δ t σ y e ( i ) C_{eye}(i) =\frac{2 \varepsilon_y(i)-\Delta t \sigma^{e}_{y}(i)}{2 \varepsilon_y(i)+\Delta t \sigma^{e}_{y}(i)} Ceye(i)=2εy(i)+Δtσye(i)2εy(i)−Δtσye(i)
C e y h z ( i ) = − 2 Δ t ( 2 ε y ( i ) + Δ t σ y e ( i ) ) Δ x C_{eyhz}(i) =-\frac{2\Delta t }{(2 \varepsilon_y(i)+\Delta t \sigma^{e}_{y}(i))\Delta x} Ceyhz(i)=−(2εy(i)+Δtσye(i))Δx2Δt
C e y j ( i ) = − 2 Δ t 2 ε y ( i ) + Δ t σ y e ( i ) C_{eyj}(i) =-\frac{2\Delta t }{2 \varepsilon_y(i)+\Delta t \sigma^{e}_{y}(i) } Ceyj(i)=−2εy(i)+Δtσye(i)2Δt
(2)磁场 z z z 分量更新方程
H z n + 1 / 2 ( i ) = C h z h ( i ) × H z n − 1 / 2 ( i ) + C h z e y ( i ) × ( E y n ( i + 1 ) − E z n ( i ) ) + C h z m ( i ) × M i z n ( i ) H^{n+1/2}_z(i) =C_{hzh}(i)\times H^{n-1/2}_z(i) +C_{hzey}(i)\times (E^{n}_y(i+1) -E^{n}_z(i))+C_{hzm}(i)\times M^{n}_{iz}(i) Hzn+1/2(i)=Chzh(i)×Hzn−1/2(i)+Chzey(i)×(Eyn(i+1)−Ezn(i))+Chzm(i)×Mizn(i) (1.41)
式中
C h z h ( i ) = 2 μ z ( i ) − Δ t σ z m ( i ) 2 μ z ( i ) + Δ t σ z m ( i ) C_{hzh}(i) =\frac{2 \mu_z(i)-\Delta t \sigma^{m}_{z}(i)}{2 \mu_z(i)+\Delta t \sigma^{m}_{z}(i)} Chzh(i)=2μz(i)+Δtσzm(i)2μz(i)−Δtσzm(i)
C h z e y ( i ) = − 2 Δ t ( 2 μ z ( i ) + Δ t σ z m ( i ) ) Δ x C_{hzey}(i) =-\frac{2\Delta t }{(2 \mu_z(i)+\Delta t \sigma^{m}_{z}(i))\Delta x } Chzey(i)=−(2μz(i)+Δtσzm(i))Δx2Δt
C h z m ( i ) = − 2 Δ t 2 μ z ( i ) + Δ t σ z m ( i ) C_{hzm}(i) =-\frac{2\Delta t }{2 \mu_z(i)+\Delta t \sigma^{m}_{z}(i) } Chzm(i)=−2μz(i)+Δtσzm(i)2Δt
(3)电场 z z z 分量更新方程
E z n + 1 ( i ) = C e z e ( i ) × E z n ( i ) + C e z h y ( i ) × ( H y n + 1 / 2 ( i + 1 ) − H y n + 1 / 2 ( i ) ) + C e z j ( i ) × J i z n + 1 / 2 ( i ) E^{n+1}_z(i) =C_{eze}(i)\times E^{n}_z(i) +C_{ezhy}(i)\times (H^{n+1/2}_y(i+1) -H^{n+1/2}_y(i))+C_{ezj}(i)\times J^{n+1/2}_{iz}(i) Ezn+1(i)=Ceze(i)×Ezn(i)+Cezhy(i)×(Hyn+1/2(i+1)−Hyn+1/2(i))+Cezj(i)×Jizn+1/2(i) (1.42)
式中
C e z e ( i ) = 2 ε z ( i ) − Δ t σ z e ( i ) 2 ε z ( i ) + Δ t σ z e ( i ) C_{eze}(i) =\frac{2 \varepsilon_z(i)-\Delta t \sigma^{e}_{z}(i)}{2 \varepsilon_z(i)+\Delta t \sigma^{e}_{z}(i)} Ceze(i)=2εz(i)+Δtσze(i)2εz(i)−Δtσze(i)
C e z h y ( i ) = − 2 Δ t ( 2 ε z ( i ) + Δ t σ z e ( i ) ) Δ x C_{ezhy}(i) =-\frac{2\Delta t }{(2 \varepsilon_z(i)+\Delta t \sigma^{e}_{z}(i))\Delta x} Cezhy(i)=−(2εz(i)+Δtσze(i))Δx2Δt
C e z j ( i ) = − 2 Δ t 2 ε z ( i ) + Δ t σ z e ( i ) C_{ezj}(i) =-\frac{2\Delta t }{2 \varepsilon_z(i)+\Delta t \sigma^{e}_{z}(i) } Cezj(i)=−2εz(i)+Δtσze(i)2Δt
(4)磁场 y y y 分量更新方程
H y n + 1 / 2 ( i ) = C h y h ( i ) × H y n − 1 / 2 ( i ) + C h y e h ( i ) × ( E z n ( i + 1 ) − E z n ( i ) ) + C h y m ( i ) × M i y n ( i ) H^{n+1/2}_y(i) =C_{hyh}(i)\times H^{n-1/2}_y(i) +C_{hyeh}(i)\times (E^{n}_z(i+1) -E^{n}_z(i))+C_{hym}(i)\times M^{n}_{iy}(i) Hyn+1/2(i)=Chyh(i)×Hyn−1/2(i)+Chyeh(i)×(Ezn(i+1)−Ezn(i))+Chym(i)×Miyn(i)(1.43)
式中
C h y h ( i ) = 2 μ y ( i ) − Δ t σ y m ( i ) 2 μ y ( i ) + Δ t σ y m ( i ) C_{hyh}(i) =\frac{2 \mu_y(i)-\Delta t \sigma^{m}_{y}(i)}{2 \mu_y(i)+\Delta t \sigma^{m}_{y}(i)} Chyh(i)=2μy(i)+Δtσym(i)2μy(i)−Δtσym(i)
C h y e z ( i ) = − 2 Δ t ( 2 μ y ( i ) + Δ t σ y m ( i ) ) Δ x C_{hyez}(i) =-\frac{2\Delta t }{(2 \mu_y(i)+\Delta t \sigma^{m}_{y}(i))\Delta x } Chyez(i)=−(2μy(i)+Δtσym(i))Δx2Δt
C h y m ( i ) = − 2 Δ t 2 μ y ( i ) + Δ t σ y m ( i ) C_{hym}(i) =-\frac{2\Delta t }{2 \mu_y(i)+\Delta t \sigma^{m}_{y}(i) } Chym(i)=−2μy(i)+Δtσym(i)2Δt
附录 A 的代码给出了基于式 (1.42) 与式 (1.43) 的一维 FDTD MATLAB 仿真程序。程序计算了由 z z z 向电流屏 J z J_z Jz 所产生的电场与磁场,电流屏与两个理想导电平面平行并处于二者中间,其他空间区域填充以空气。两导电平面间距 1 m 1m 1m,空间步长 Δ x = 1 m m \Delta x =1mm Δx=1mm ,电流屏电流密度为 1 A / m 2 1A/m^2 1A/m2 ,按照高斯函数随时间变化
J z ( t ) = e − ( t − 2 × 1 0 − 10 5 × 1 0 − 11 ) 2 J_z(t) = e^{-(\frac{ t-2\times10^{-10} }{5\times 10^{-11}})^2} Jz(t)=e−(5×10−11t−2×10−10)2
激励源电流屏厚度 1 m m 1mm 1mm ,可将 J z J_z Jz 转换为表面电流密度 K z K_z Kz ,大小为 1 × 1 0 − 3 A / m 2 1\times 10^{-3}A/m^2 1×10−3A/m2 。该激励源在屏两侧产生磁场,幅度为 5 × 1 0 − 4 A / m 5\times 10^{-4}A/m 5×10−4A/m 。为场在自由空间中传播,故产生的电场为 μ 0 × 5 × 1 0 − 4 = 0.1885 V / m \mu_0 \times 5 \times 10^{-4} =0.1885V/m μ0×5×10−4=0.1885V/m ,其中 μ 0 ⋍ 337 Ω \mu_0 \backsimeq 337\Omega μ0⋍337Ω 。
程序中有几点值得注意:其一为电场存储数组比磁场存储数组多一个节点,这是因为电场和磁场在离散化后交叉分布的结果(图 1.12 与 图 1.13);其二,两端理想导电平面上需要设置边界条件,即 E z = 0 E_z =0 Ez=0 ;其三,如结果图 1.14 所示,场量经理想导电平面反射后,电场方向点到,代表反射系数为 1,磁场方程不变,表示反射系数为 -1。
算法流程图:
主程序 fdtd1D.m
% 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 parallel 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.
clc, clear, close all;
% 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
dt = 3e-12; % duration of time step in seconds
number_of_time_steps = 1000; % 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 wavefront
time = dt * [0 : number_of_time_steps - 1];
Jz_waveform = exp( - (( time - 2e-10) / 5e-11 ).^2);
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; % Appky PEC boundary condition at x = 1 m
% Subroutine to plot the current state of the fields
plot_fields;
end
初始化绘图参数 initialize_plotting_parameters.m
% 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');
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');
绘制图片 plot_fields.m
% subroutine used to plot 1D transient fields
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;
参考书籍:The Finite-Difference Time-Domain Method For Electromagnetics with MATLAB Simulations by Atef Z. Elsherbeni, Veysel Demir