Simulation with Matlab: wave scattering

Illustration of Radar cross section reduction via active treatment


First the animation: that is video from figure 4., introducing wave scattering and some stealthness principles, here the principle of surface treatment (for example with an absorbing medium) for radar signals reduction.



Simulation and computationnal aspects rely on finite difference method, see for example (french) this page and also for example (also french) introduction to Matlab programming, and more specifically activities 8, simulation of monodimensionnal wave scattering, 9, simulation of bidimensionnal wave scattering, and 10, simulation of wave scattering inside a medium.

About the simulation and animation on which result is shown on top, the Matlab code is:
clear all;close all
clc;
c=8;
Lx=100;Ly=Lx;
Nx=150;Ny=150;
dx=Lx/Nx;dy=Ly/Ny;
x=linspace(0,Lx,Nx);
y=linspace(0,Ly,Ny);

dt=sqrt(dx^2+dy^2)/(2*c);
nu=1;       % Source frequency
Temis=4;    % source emitting duration
T=20;
t=[0:dt:T];Nt=length(t);

gax=c^2*dt^2/dx^2;
gay=c^2*dt^2/dy^2;

% Source location
sx=round(Nx/8);
sy=round(Ny/8);

u=zeros(Nx,Ny,Nt);


%% Obstacle 1
Ox=round(Nx/2);Oy=round(Ny/2);% centre

for k=2:Nt-1
    for i=2:Nx-1
        for j=2:Ny-1
            
            tmp1=u(i-1,j,k)+u(i+1,j,k)-2*u(i,j,k);
            tmp2=u(i,j-1,k)+u(i,j+1,k)-2*u(i,j,k);
            u(i,j,k+1)=2*u(i,j,k)-u(i,j,k-1)+gax*tmp1+gay*tmp2;
        end
    end
    if (k*dt<Temis)
        u(sx,sy,k+1)=2*sin(2*pi*nu*k*dt);
    else
        u(sx,sy,k+1)=0;
    end
    %
    % Obstacle(s): 
    for l=0:10
        X=Ox+l;
        for XX=-5:5
            Z=X+XX;
            u(Z,-Z+2*X,k+1)=0;
            u(Z+1,-Z+2*X,k+1)=0;
        end
    end
        % Absorbing condition (CLA) 
	  %   on the front face 
	  %   (from source and radar point of vue) 
	  %   of the object
        X=Ox;
        for XX=-5:5
            Z=X+XX;
            u(Z,-Z+2*X,k+1)=u(Z-1,-Z+2*X-1,k);
        end
        for XX=-4:5
            Z=X+XX;
            u(Z,-Z+2*X+1,k+1)=u(Z-1,-Z+2*X,k);
        end
    %
    % Not wnated reflections:
    u(1,:,k+1)=u(2,:,k);
    u(Nx,:,k+1)=u(Nx-1,:,k);
    u(:,1,k+1)=u(:,2,k);
    u(:,Ny,k+1)=u(:,Ny-1,k);
end

% For source drawing purpose
u(sx,sy,:)=10;

% For obstacle drawing purpose
for l=0:10
    X=Ox+l;
    for XX=-5:5
        Z=X+XX;
        u(Z,-Z+2*X,:)=1;
        u(Z+1,-Z+2*X,:)=1;
    end
end
    X=Ox;
    for XX=-5:5
        Z=X+XX;
        u(Z,-Z+2*X,:)=1.5;u(Z-1,-Z+2*X-1,:)=2;
    end
    for XX=-4:5
        Z=X+XX;
        u(Z,-Z+2*X+1,:)=1.5;u(Z-1,-Z+2*X,:)=2;
    end

fig=figure(1);clf;whitebg('w')
colormap(jet)

MM=[];

for k=1:2:Nt
    subplot(211);
    %imagesc(squeeze(u(:,:,k)));
    pcolor(squeeze(u(:,:,k)));
    axis off,axis square
    shading flat
    caxis([-0.5 2])
    %colorbar
    
    subplot(212),hold on
    set(pp,'linewidth',3')
    pp=plot(t,zeros(size(t)),'--k');
    set(pp,'linewidth',0.5')
    axis([0 T -0.6 0.6])
    xlabel('Temps [ms]','fontsize',16)
    ylabel('Amplitude','fontsize',16)
    grid on
    %pause(0.01)
    MM=[MM getframe(fig)];
end

%break
movie2avi(MM,'Anim.avi')


Video resulting from movie2avi is usually a heavy (if not really huge) one.
One can directly enable Matlab to use some codecs, see movie2avi parameters, via
help movie2avi
or, also see Matlab alternative solution to video generation: VideoWriter, which is to used nearly the same way as movie2avi, but is a rather more complete with respect to codecs; see the list of available "profiles"
VideoWriter.getProfiles()


Another alternative is to convert video after Matlab process, via for example ffmpeg
ffmpeg -i film.avi film.mp4

which one can then use directly use, for example, inside html5 <video> (as at the top of page), or to convert to animated gif, via convert utility (ImageMagic software)
convert -loop 2 film.avi film.gif

See also: