模拟的空间总长1m,激励在0.5m处,两边为理想电导体边界(PEC),信号到达边界后反射,电场反向,反射系数为-1,磁场不反向,程序如下:
clc
close all
clear 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, Δ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 &