Who likes programming?
5 posters
:: Okami :: Okami :: Guild Chat
Page 1 of 1
Who likes programming?
Fancy finishing off my script? =]
% SAWT.m
% CEdunno,Autumn
% Small Amplitude Wave Theory
% Robert Claridge, December, 2009
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
clear all;
close all;
clc;
%--------------------------------------------------------------------------
% Known Data
g=9.81;
% Variables
a=input('amplitude');
T=input('period');
z=linspace(-250, a, 250);
w=(2*pi)/T;
k=(w^2)/g;
% SAWT
u=a*w*exp(k*z);
umax=max(u);
fprintf(1,'velocity of u [SAWT] %6.3f [m/s]\n',umax);
% Second Order Stokes
usos=a*g*(k/w)*exp(k*z);
umaxsos=max(usos);
fprintf(1,'velocity of u [SOS] %6.3f [m/s]\n',umaxsos);
% N.B. as second term=0, the u is the same as the SAWT
% 5th Order Soution
eps=a*k;
% eps=(H/2)*k Assume a=H/2 here
u5=((g/k^3)^0.5)*k*(eps*exp(k*z)-(((eps^3)*exp(k*z))/2)+((eps^4)*exp(2*k*z))-((37/24)*(eps^5)*exp(k*z))+((eps^5)*exp(3*k*z)/4));
u5max=max(u5);
fprintf(1,'velocity of u [5th Order] %6.3f [m/s]\n',u5max);
% LRWT
Flrwt=[0.01:0.01:0.5];
alpha=[0.50;
1.05;
1.55;
-0.6;
-1.1;
0.1;
0.09;
-0.22;
0.05;
-0.38;
-0.15;
0.55;
0.55;
0.7;
0.2;
0;
-1.1;
-0.3;
-0.5;
0.49;
0.51;
0.05;
1.43;
-1.5;
-0.85;
-1.2;
-1.25;
-0.48;
-0.7;
-0.05;
-0.43;
-0.49;
-0.4;
-0.3;
-0.22;
-0.18;
-0.01;
-0.05;
0.1;
0.1;
0.18;
0.18;
0.22;
0.23;
0.12;
0.25;
0.24;
0.25;
0.4;
0.3;]';
Hlrwt=[0.3;
0.2;
0.18;
0.09;
1.58;
5.59;
7.58;
4.90;
3.30;
1.95;
0.60;
1.00;
1.60;
1.53;
1.18;
0.90;
0.40;
0.20;
0.50;
0.50;
0.70;
0.20;
0.20;
0.38;
0.10;
0.30;
0.08;
0.10;
0.10;
0.02;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;]';
for i = 1:length(alpha)
km(i) = ((2.*pi.*Flrwt(i)).^2)/9.81;
end
x=linspace(-500, 500, 250);
for i = 1:length(x);
for j = 1:length(z);
for m = 1:length(alpha)
output(m) =(Hlrwt(m)/2) * (2*pi*Flrwt(m)) * exp(km(m)*z(j)) * cos(km(m)*x(i)+alpha(m));
output2(m) = (Hlrwt(m)/2) * cos(km(m)*x(i) + alpha(m));
end
ulrwt(i,j) = sum(output);
italrwt(i) = sum(output2);
end
end
ulrwtmax=max(max(ulrwt));
fprintf(1,'velocity of u [LRWT] %6.3f [m/s]\n',ulrwtmax);
% Wheeler Stretching of LRWT
zstar=z+italrwt((length(x)/2)+1);
% Velocity Graph
figure
plot(u,z,'r',usos,z,'k',u5,z,'g',ulrwt(length(x)/2,,z,'b',ulrwt((length(x)/2)+1,,zstar,'m'); % For LRWT one wants to plot the speeds purely under the maximum crest rather than all the velocities of all the wave components
xlabel('[m/s]');
ylabel('Depth from Crest[m]')
title('SAWT');
legend('SAWT','SOS','5th Order','LRWT','LRWT+W','location','best');
grid on;
% SAWT.m
% CEdunno,Autumn
% Small Amplitude Wave Theory
% Robert Claridge, December, 2009
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
clear all;
close all;
clc;
%--------------------------------------------------------------------------
% Known Data
g=9.81;
% Variables
a=input('amplitude');
T=input('period');
z=linspace(-250, a, 250);
w=(2*pi)/T;
k=(w^2)/g;
% SAWT
u=a*w*exp(k*z);
umax=max(u);
fprintf(1,'velocity of u [SAWT] %6.3f [m/s]\n',umax);
% Second Order Stokes
usos=a*g*(k/w)*exp(k*z);
umaxsos=max(usos);
fprintf(1,'velocity of u [SOS] %6.3f [m/s]\n',umaxsos);
% N.B. as second term=0, the u is the same as the SAWT
% 5th Order Soution
eps=a*k;
% eps=(H/2)*k Assume a=H/2 here
u5=((g/k^3)^0.5)*k*(eps*exp(k*z)-(((eps^3)*exp(k*z))/2)+((eps^4)*exp(2*k*z))-((37/24)*(eps^5)*exp(k*z))+((eps^5)*exp(3*k*z)/4));
u5max=max(u5);
fprintf(1,'velocity of u [5th Order] %6.3f [m/s]\n',u5max);
% LRWT
Flrwt=[0.01:0.01:0.5];
alpha=[0.50;
1.05;
1.55;
-0.6;
-1.1;
0.1;
0.09;
-0.22;
0.05;
-0.38;
-0.15;
0.55;
0.55;
0.7;
0.2;
0;
-1.1;
-0.3;
-0.5;
0.49;
0.51;
0.05;
1.43;
-1.5;
-0.85;
-1.2;
-1.25;
-0.48;
-0.7;
-0.05;
-0.43;
-0.49;
-0.4;
-0.3;
-0.22;
-0.18;
-0.01;
-0.05;
0.1;
0.1;
0.18;
0.18;
0.22;
0.23;
0.12;
0.25;
0.24;
0.25;
0.4;
0.3;]';
Hlrwt=[0.3;
0.2;
0.18;
0.09;
1.58;
5.59;
7.58;
4.90;
3.30;
1.95;
0.60;
1.00;
1.60;
1.53;
1.18;
0.90;
0.40;
0.20;
0.50;
0.50;
0.70;
0.20;
0.20;
0.38;
0.10;
0.30;
0.08;
0.10;
0.10;
0.02;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;]';
for i = 1:length(alpha)
km(i) = ((2.*pi.*Flrwt(i)).^2)/9.81;
end
x=linspace(-500, 500, 250);
for i = 1:length(x);
for j = 1:length(z);
for m = 1:length(alpha)
output(m) =(Hlrwt(m)/2) * (2*pi*Flrwt(m)) * exp(km(m)*z(j)) * cos(km(m)*x(i)+alpha(m));
output2(m) = (Hlrwt(m)/2) * cos(km(m)*x(i) + alpha(m));
end
ulrwt(i,j) = sum(output);
italrwt(i) = sum(output2);
end
end
ulrwtmax=max(max(ulrwt));
fprintf(1,'velocity of u [LRWT] %6.3f [m/s]\n',ulrwtmax);
% Wheeler Stretching of LRWT
zstar=z+italrwt((length(x)/2)+1);
% Velocity Graph
figure
plot(u,z,'r',usos,z,'k',u5,z,'g',ulrwt(length(x)/2,,z,'b',ulrwt((length(x)/2)+1,,zstar,'m'); % For LRWT one wants to plot the speeds purely under the maximum crest rather than all the velocities of all the wave components
xlabel('[m/s]');
ylabel('Depth from Crest[m]')
title('SAWT');
legend('SAWT','SOS','5th Order','LRWT','LRWT+W','location','best');
grid on;
Re: Who likes programming?
When this works do we get credited on your paper? So when you become a big Engineering Super Star, Do they get their name in small print? THIS SMALL!
And no, I have absolute no knowledge on that sort of thang....
And no, I have absolute no knowledge on that sort of thang....
Re: Who likes programming?
Mozillo wrote:When this works do we get credited on your paper? So when you become a big Engineering Super Star, Do they get their name in small print? THIS SMALL!
And no, I have absolute no knowledge on that sort of thang....
Of course =]
new edited script (that now doesn't work =_=)
% SAWT.m
% CEdunno,Autumn
% Small Amplitude Wave Theory
% Robert Claridge, December, 2009
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
clear all;
close all;
clc;
%--------------------------------------------------------------------------
% Known Data
g=9.81;
% Variables
a=input('amplitude');
T=input('period');
z=linspace(-250, a, 250);
w=(2*pi)/T;
k=(w^2)/g;
%--------------------------------------------------------------------------
% SAWT
u=a*w*exp(k*z);
umax=max(u);
fprintf(1,'velocity of u [SAWT] %6.3f [m/s]\n',umax);
%--------------------------------------------------------------------------
% Second Order Stokes
usos=a*g*(k/w)*exp(k*z);
umaxsos=max(usos);
fprintf(1,'velocity of u [SOS] %6.3f [m/s]\n',umaxsos);
% N.B. as second term=0, the u is the same as the SAWT
%--------------------------------------------------------------------------
% 5th Order Soution
eps=a*k;
% eps=(H/2)*k Assume a=H/2 here
u5=((g/k^3)^0.5)*k*(eps*exp(k*z)-(((eps^3)*exp(k*z))/2)+((eps^4)*exp(2*k*z))-((37/24)*(eps^5)*exp(k*z))+((eps^5)*exp(3*k*z)/4));
u5max=max(u5);
fprintf(1,'velocity of u [5th Order] %6.3f [m/s]\n',u5max);
%--------------------------------------------------------------------------
% LRWT
Flrwt=[0.01:0.01:0.5];
alpha=[0.50;
1.05;
1.55;
-0.6;
-1.1;
0.1;
0.09;
-0.22;
0.05;
-0.38;
-0.15;
0.55;
0.55;
0.7;
0.2;
0;
-1.1;
-0.3;
-0.5;
0.49;
0.51;
0.05;
1.43;
-1.5;
-0.85;
-1.2;
-1.25;
-0.48;
-0.7;
-0.05;
-0.43;
-0.49;
-0.4;
-0.3;
-0.22;
-0.18;
-0.01;
-0.05;
0.1;
0.1;
0.18;
0.18;
0.22;
0.23;
0.12;
0.25;
0.24;
0.25;
0.4;
0.3;]';
Hlrwt=[0.3;
0.2;
0.18;
0.09;
1.58;
5.59;
7.58;
4.90;
3.30;
1.95;
0.60;
1.00;
1.60;
1.53;
1.18;
0.90;
0.40;
0.20;
0.50;
0.50;
0.70;
0.20;
0.20;
0.38;
0.10;
0.30;
0.08;
0.10;
0.10;
0.02;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;]';
for i = 1:length(alpha)
km(i) = ((2.*pi.*Flrwt(i)).^2)/9.81;
end
x=linspace(-500, 500, 250);
for i = 1:length(x);
for j = 1:length(z);
for m = 1:length(alpha)
output(m) =(Hlrwt(m)/2) * (2*pi*Flrwt(m)) * exp(km(m)*z(j)) * cos(km(m)*x(i)+alpha(m));
output2(m) = (Hlrwt(m)/2) * cos(km(m)*x(i) + alpha(m));
end
ulrwt(i,j) = sum(output);
italrwt(i) = sum(output2);
end
end
ulrwtmax=max(max(ulrwt));
fprintf(1,'velocity of u [LRWT] %6.3f [m/s]\n',ulrwtmax);
% Wheeler Stretching of LRWT
zstar=z+italrwt((length(x)/2)+1);
%--------------------------------------------------------------------------
% LRWT without contamination : Get rid of data with frequency higher than
% 0.18
Flrwt2=[0.01:0.01:0.18];
alpha2=[0.50;
1.05;
1.55;
-0.6;
-1.1;
0.1;
0.09;
-0.22;
0.05;
-0.38;
-0.15;
0.55;
0.55;
0.7;
0.2;
0;
-1.1;
-0.3]';
Hlrwt2=[0.3;
0.2;
0.18;
0.09;
1.58;
5.59;
7.58;
4.90;
3.30;
1.95;
0.60;
1.00;
1.60;
1.53;
1.18;
0.90;
0.40;
0.20]';
for i = 1:length(alpha2)
km2(i) = ((2.*pi.*Flrwt2(i)).^2)/9.81;
end
for i = 1:length(x);
for j = 1:length(z);
for m = 1:length(alpha2)
output3(m) =(Hlrwt2(m)/2) * (2*pi*Flrwt2(m)) * exp(km2(m)*z(j)) * cos(km2(m)*x(i)+alpha2(m));
output4(m) = (Hlrwt2(m)/2) * cos(km2(m)*x(i) + alpha2(m));
end
ulrwt2(i,j) = sum(output3);
italrwt2(i) = sum(output4);
end
end
ulrwtmax2=max(max(ulrwt2));
fprintf(1,'velocity of u [LRWT-Cut1] %6.3f [m/s]\n',ulrwtmax2);
% Wheeler Stretching of LRWT-C1
zstar2=z+italrwt2((length(x)/2)+1);
% Linear Extrapolation of LRWT-C1
dudz=gradient(ulrwt2(length(x)/2,,z);
z0=find(abs(z-0) == min(abs(z-0)));
dudz0=dudz(z0);
ulrwt0=ulrwt2(length(x)/2,z0);
if z(i)>0
ulrwt2=ulrwt0+(z(i)*dudz0);
else
ulrwt2;
end
%--------------------------------------------------------------------------
% Attempt Cut from 0.04-0.11 Hz
Flrwt3=[0.04:0.01:0.11];
alpha3=[-0.6;
-1.1;
0.1;
0.09;
-0.22;
0.05;
-0.38;
-0.15]';
Hlrwt3=[
0.09;
1.58;
5.59;
7.58;
4.90;
3.30;
1.95;
0.60]';
for i = 1:length(alpha3)
km3(i) = ((2.*pi.*Flrwt3(i)).^2)/9.81;
end
for i = 1:length(x);
for j = 1:length(z);
for m = 1:length(alpha3)
output5(m) =(Hlrwt3(m)/2) * (2*pi*Flrwt3(m)) * exp(km3(m)*z(j)) * cos(km3(m)*x(i)+alpha3(m));
output6(m) = (Hlrwt3(m)/2) * cos(km3(m)*x(i) + alpha3(m));
end
ulrwt3(i,j) = sum(output5);
italrwt3(i) = sum(output6);
end
end
ulrwtmax3=max(max(ulrwt3));
fprintf(1,'velocity of u [LRWT-Cut2] %6.3f [m/s]\n',ulrwtmax3);
% Velocity of this cut heavily underpredicts w.r.t 5th Order, Hence Wheeler
% stretching will only make it worse
%--------------------------------------------------------------------------
% Velocity Graph
figure
plot(u,z,'r',usos,z,'k',u5,z,'g',ulrwt(length(x)/2,,z,'b',ulrwt((length(x)/2)+1,,zstar,'m',ulrwt2((length(x)/2)+1,,z,'y-',ulrwt2((length(x)/2)+1,,zstar2,'y');
% For LRWT one wants to plot the speeds purely under the maximum crest rather than all the velocities of all the wave components
xlabel('[m/s]');
ylabel('Depth from Crest[m]')
title('SAWT');
legend('SAWT','SOS','5th Order','LRWT','LRWT+W','LRWT+C1','LRWT+C1+W','location','best');
grid on;
% Surface Profile Graph
figure
plot(x,italrwt,'k',x,italrwt2,'r');
xlabel('x[m]');
ylabel('ita')
title('Surface Profile Plot');
legend('LRWT','LRWT+C','location','best');
grid on;
Re: Who likes programming?
I would believe that it is most likely a way of testing this small amplitude wave theory. By a........... test programme thing. You know, he codes for it all, then the programme will show him if it works or not.... or something....
Re: Who likes programming?
Mozillo wrote:I would believe that it is most likely a way of testing this small amplitude wave theory. By a........... test programme thing. You know, he codes for it all, then the programme will show him if it works or not.... or something....
Essentially we have to formulate a code capable of plotting a wave profile and finding the velocity profile under the water surface.
When you think how complicated a sea wave is explained in pure maths, you understand my pain D:
I'm sure you've heard of the fourier series and how you can add many sin waves together to compose a more complex set =]
(I think we kinda did it at GCSE physics, and then again at A-level)
Re: Who likes programming?
Yeah, our physics teacher showed us that a bit when doing waves and stuff in A-level, never got told what it was, just looked nice....
Wow, that sounds.... REALLY important.... o.o maybe?
I do like how all the Tenshiis* in the guild are WELL smart!
*well, most anyway
Wow, that sounds.... REALLY important.... o.o maybe?
I do like how all the Tenshiis* in the guild are WELL smart!
*well, most anyway
Re: Who likes programming?
From what I've seen, all the tenshii's really are smart!
It's like an underlying criteria to become one in my opinion XD
It's like an underlying criteria to become one in my opinion XD
Re: Who likes programming?
That's cause stupid people are unpleasant to talk to so we simply don't get to know them.
They could be nice people, but when they're stupid, its hard to pay attention to them!
They could be nice people, but when they're stupid, its hard to pay attention to them!
Re: Who likes programming?
He was probably implying Ryan. Not that Ryan isn't smart.
Kamatari- Jesus
- Number of posts : 1901
Age : 33
Location : I NEED MORE BLEACH
Ki : 526
Registration date : 2008-01-03
Re: Who likes programming?
Kamatari wrote:He was probably implying Ryan. Not that Ryan isn't smart.
Yeah that's what I thought.
Just it's so obvious that he meant that there's really no point in implying it.
Just say it out straight Chris!
Re: Who likes programming?
I'm smart 0.0. What are you smoking Chris?
Sheepkilla- MUDKIP, I CHOOSE YOU
- Number of posts : 1010
Age : 27
Location : Danbury, Connecticut
Ki : 926
Registration date : 2008-02-17
:: Okami :: Okami :: Guild Chat
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|