% Rayleigh Wave Simulator
% Creates animation of surface particle motion in Rayleigh waves
% Chad Greene
% 08OCT2008
alpha = 10; % P wave speed [m/s]
T = 1; % period in [s]
beta = alpha/sqrt(3); % S wave speed [m/s]
Cr = sqrt(2-2/sqrt(3))*beta; % Rayleigh wave speed [m/s]
P = 1/Cr; % ray parameter [s/m]
lambda = Cr*T; % wavelength of Rayleigh wave
w = 2*pi/T; % angular frequency [rad/s]
t = 0:T/48:8*T; % time array [s]
xloc = 2*.42*w*P*[-6:6]; % x-location of centers
mov = avifile('RayleighWaveAnimation.avi','compression','i420');
fig=figure('visible','off'); % makes figure invisible
ux = NaN(length(xloc),length(t)); % preallocation of ux
uxt = NaN(length(t),length(xloc));% preallocation of uxt
uz = NaN(length(xloc),length(t)); % preallocation of uz
uzt = NaN(length(t),length(xloc));% preallocation of uzt
for nn = 1:length(t)
set(gca,'fontsize',14)
for n = 1:13
x = xloc(n);
ux(n,:) = .42*w*P.*sin(w*(P*x-t))+x;
uz(n,:) = .62*w*P.*cos(w*(P*x-t));
plot(ux(n,:),uz(n,:),'g-'); hold on
end
plot([min(ux(1,:)) max(ux(13,:))],[0 0],'k-')
axis equal
axis([min(ux(1,:)) max(ux(13,:)) 2*min(uz(1,:)) 2*max(uz(13,:))])
title('Particle motion in Rayleigh waves')
xlabel('x -->')
ylabel('<-- z')
set(gca,'XTick',[],'XTickLabel',{},'YTick',[],'YTickLabel',{})
for q = 1:13
uxt(nn,:) = .42*w*P.*sin(w*(P*xloc-t(nn)-(q-7)*T/12))+xloc;
uzt(nn,:) = .62*w*P.*cos(w*(P*xloc-t(nn)-(q-7)*T/12));
plot(uxt(nn,q),uzt(nn,q),'r.')
end
set(gcf,'color','w','position',[100 400 800 200]) % sets figure color and size
box off
hold off
mov = addframe(mov,fig);
end
close(fig)
mov = close(mov);