I, the copyright holder of this work, release this work into the public domain. This applies worldwide. In some countries this may not be legally possible; if so: I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.
MATLAB source code
% an illustration of a spherical waveplane_wave=1;spherical_wave=2;%wave_type = plain_wave;wave_type=spherical_wave;ifwave_type==plane_wave% window sizeLx=0.4;Lx=1;% blow up the image by this factor to display betterfactor=80;% a small shift to be added below for graph. purposes.shift=0.3;elseifwave_type==spherical_waveLx=0.5;Ly=Lx;factor=1;shift=3;endMx=Lx/2;Wy=Ly/2;M=400;N=floor(M*Ly/Lx);[X,Y]=meshgrid(linspace(-Lx/2,Lx/2,M),linspace(-Ly/2,Ly/2,N));wavenumber=100;T=1;nt=10;Time=linspace(0,T,nt);forrepeat=1:1% go over one time period of the fieldforiter=1:(nt-1)% nt is same as 1 due to peridicityt=Time(iter);ifwave_type==plane_wave% plane waveZ=real(exp(i*wavenumber*Y)*exp(-i*2*pi*t));elseifwave_type==spherical_wave% spherical waveZ=exp(sqrt(-1)*wavenumber*sqrt(X.^2+Y.^2))*exp(-sqrt(-1)*2*pi*t)./sqrt(X.^2+Y.^2);end% plot the real part of the field Zfigure(1);clf;holdon;axisequal;axisoff;image(factor*(real(Z+shift)));% add shift to Z for graphing purposescolormapjet;shadinginterp;file=sprintf('Movie_frame%d.eps',1000+iter);disp(file);%show the frame number we are atsaveas(gcf,file,'psc2')%save the current framepause(0.1);endend% The following command was used to create the animated figure.% convert -antialias -loop 10000 -delay 15 -compress LZW Movie_frame10* Spherical_wave2.gif