% program to draw movie of the evolution. % the first figure is more a small dock close all clear all k_number = 500;k_max = pi*5;x_number =400; L1 = 1;L2=1.25;h=1;theta =0;N=20; k0 = 0:k_max/k_number:k_max; x = -L1:L1/x_number:0; x2 = -1-L2:L1/x_number:-L2; phi = zeros(length(k0),length(x)); phi2 = zeros(length(k0),length(x2)); phi(1,:) = 2*ones(size(phi(1,:))); phi2(1,:) = 2*ones(size(phi2(1,:))); for count = 2:length(k0) count alpha = k0(count)*tanh(k0(count)*h); % if the depth is great than twice the wavelength set depth to twice % wavewavelength H = min(h,4*pi/k0(count)); [a_s,b_s,c_s,d_s,a_a,b_a,c_a,d_a] = two_finite_docks_symmetry(alpha,h,L1,L2,theta,N); roots = dispersion_free_surface(alpha,N,h); for count2 = 1:N+1 phi(count,:) = phi(count,:) + d_s(count2)*cosh(roots(count2)*x)/cosh(roots(count2)*L1); phi2(count,:) = phi2(count,:) + a_s(count2)*exp(roots(count2)*(x2+L2)); end phi2(count,:) = phi2(count,:) + exp(-roots(1)*(x2+L2)); end eta = exp(-4*(x).^2); time = 0:0.5:10;time_display = time; time(1) = 0.0001; delta_h = L1/x_number; weight = 2*delta_h/3*ones(size(x));weight(2:2:end-1) = 4*delta_h/3;weight(1) = delta_h/3;weight(end) = delta_h/3; f= conj(phi(:,:))*(transpose(weight.*eta)); total_potential = zeros(length(k0),size(phi,2)); total_potential2 = zeros(length(k0),size(phi2,2)); for count = 1:length(k0) total_potential(count,:) = 1/(2*pi)*phi(count,:)*f(count); total_potential2(count,:) = 1/(2*pi)*phi2(count,:)*f(count); end delete small_dock_gem.gif hf=figure('Position',[100,100,600,600]); rect = get(hf,'Position'); rect(1:2) = [0 0]; % these commands ensure we capture the actual figure. for count = 1:length(time) count out = k_integrate(time(count),k0,h,total_potential); out2 = k_integrate(time(count),k0,h,total_potential2); % now we plot the figure plot(x,out,x2,out2,'LineWidth',2); hold on plot(-fliplr(x),fliplr(out),'b',x2,out2,'b',-fliplr(x2),fliplr(out2),'b','LineWidth',2); plot([-L2,-L1],[0,0],'k','LineWidth',4); plot([L1,L2],[0,0],'k','LineWidth',4); text((1+L2)*0.5,0.8,['t = ',num2str(time_display(count),'%1.1f')],'Fontsize',14) axis([-1-L2,1+L2,-1,1]) set(gca,'FontSize',14) xlabel('x','Fontsize',14) ylabel('\xi','Fontsize',16) hold off drawnow gif_add_frame(gcf,'small_dock_gem.gif',1); end