background:
1D FDTD implementation based on Formula 1.42 (EZ component), 1.43 (Hy component).
calculates the electric field and the magnetic field component, which is produced by the Jz of the z-direction current slice, the Jz is located in the middle of two ideal conductor plates, the two plates are parallel and extend infinitely to the Y and Z directions.
the parallel plate is 1m apart and the differential grid δx=1mm.
The current surface density causes the discontinuity of the magnetic field component of the boundary plane (current thin layer), which generates HY waves on both sides, each with a strength of 5x10^ ( -4) a/m. Because the electromagnetic wave travels in the free space, the intrinsic impedance is η0.
It shows the propagation process from the left and right plates before and after reflection. In this case, the PEC boundary, the Tangent electric field component (EZ) disappears on the PEC surface.
The transformation of the field from step650 to 700 is observed, and the propagation characteristics of the incident wave and reflected waves of the PEC plate are shown. After the PEC reflex, EZ polarity reversed, this is because the reflection coefficient is equal to-1;
and the magnetic field component Hy has no reverse, the reflection coefficient equals 1.
Here's the code in the book (Barely moving):
The 1th one is the main program:
Percent------------------------------------------------------------------------------percent Output Info about this M-fi lefprintf (' \n****************************************************************\n '); fprintf (' \ n <FDTD 4 Electromagnetics with MATLAB simulations> \ n '); fprintf (' \ n Listing a.1 \ n '); time_stamp = Datestr (now, 31); [Wkd1, WKD2] = weekday (today, ' long '); fprintf (' Now was%20s, and it is%7s \ n \ nthe ', time_stamp, wkd2);-------- ----------------------------------------------------------------------% This program demonstrates a one-dimensional FDTD simulation.% The problem geometry is composed of both PEC plates extending to% infinity in Y and z dimensions, Paralle L to all 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 are placed% at th E Center of the problem space. The current source excites fields% in the problem spaCe due to a z-directed current density jz,% which have a Gaussian waveform in time.% Define initial constantseps_0 = 8.8541 87817e-12; % permittivity of free spacemu_0 = 4*pi*1e-7; % permeability of free SPACEC = 1/sqrt (MU_0*EPS_0); % speed of light% Define problem geometry and parametersdomain_size = 1; % 1D problem space length in METERSDX = 1e-3; % cell size in METERS,ΔX=0.001MDT = 3e-12; % duration of time step in secondsnumber_of_time_steps = 2000; % Number of Iterationsnx = round (DOMAIN_SIZE/DX); % number of cells in 1D problem spacesource_position = 0.5; % position of the current source jz% Initialize field and material arraysceze = 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 spacesigma_e_z = Zeros (nx+1, 1); % Free Spacechyh = 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 spacesigma_m_y = Zeros (NX, 1); % free space% Calculate FDTD Updating Coefficientsceze = (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 waveformtime = 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 plottinginitialize_plotting_parameters;% FDTD loopfor time_step = 1:number_of_time_steps% Update Jz for the current time STEPJZ (source_position_index) = Jz_waveform (time_step);% update magnetic fieldhy (1:NX) = Ch YH (1:NX). * Hy (1:NX) ... + chyez (1:NX). * (EZ (2:NX+1)-EZ (1:NX)) ... + Chym (1:nx). * My (1:NX);% Update Electric F Ieldez (2:NX) = Ceze (2:NX). * EZ (2:NX) ... + cezhy (2:NX). * (Hy (2:NX)-hy (1:nx-1)) ... + CEZJ (2:nx). * J Z (2:NX); Ez (1) = 0; % Apply PEC boundary condition at x = 0 mEz (nx+1) = 0; % Apply PEC boundary condition at x = 1 m% subroutine to plot the current state of the Fieldsplot_fields;end
The 2nd one is initialize_plotting_parameters, Just look at the name. Initialization 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 ', ' Linewid Th ', 1.5); Lhy = line (Hy_positions, 377*hy, hy*0, ' Color ', ' r ', ' LineWidth ', 1.5, ' LineStyle ', '-. '); Set (GCA, ' fontsize ', ' n ', ' 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 ', ' Horizontalali Gnment ', ' center ', ' fontweight ', ' bold '), text (1, 1, 1.1, ' PEC ', ' HorizontalAlignment ', ' center ', ' fontweight ', ' bold '); /pre>
The 3rd one is drawing:
% subroutine used to plot 1D transient field delete (lez);d elete (lhy); lez = line (Ez_positions, ez*0, Ez, ' Color ', ' B ', ' Lin Ewidth ', 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 ']);d Rawno W
Operation Result:
, the polarity of the electric field is reversed and the polarity of the magnetic field component is the same after reflection from the PEC plate.
After reflection, the polarity of the electric field is changed again;
"FDTD electromagnetic field using MATLAB" figure of reading notes 1.14