You are on page 1of 6

EMPIRIS EQUATION

clear all
close all

% Baca EXCEL File


% A = Kedalaman, D (m), Sound Speed C (m/s), Temperatur T (deg C) dan Salinitas S (ppt)

[A,B] = xlsread('Stasiun3','DATA1');

D = A(:,1); % Kedalaman, D (m)


T = A(:,2); % Temperatur, T (deg C)
S = A(:,3); % Salinitas, S (ppt)
C = A(:,4); % Kec Suara, C (m/s)

% Rumus Empiris Medwin, Leroy, Mckenzie

C_Medwin = 1449.2 + 4.6*T - 5.5e-2*T.^2 + 2.9e-4*T.^3 + (1.34 - 1e-2*T).*(S-35) + 1.6e-2*D;


C_Leroy = 1492.9 + 3*(T-10) - 6e-3*(T-10).^2 - 4e-2*(T-18).^2 + 1.2*(S-35) + 1.0e-2*(T-18).*(S-35) + D/61;
C_Mckenzie = 1448.96 + 4.591*T - 5.304e-2*T.^2 + 2.374e-4*T.^3 + 1.340*(S-35) + 1.630e-2*D + 1.675e-
7*D.^2 - 1.025e-2*T.*(S-35) - 7.139e-13*T.*D.^3;

% Plot T vs D

% figure
subplot(1,3,1), plot(T,D)
grid
axis ij
xlabel('Temperatur, T (^oC)')
ylabel('Depth, D (m)')

% Plot S vs D

%figure
subplot(1,3,2),plot(S,D)
grid
axis ij
xlabel('Salinitas, S (ppt)')
ylabel('Depth, D (m)')

% Plot C vs D

% figure
subplot(1,3,3),plot(C,D,'k',C_Medwin,D,'r',C_Leroy,D,'g',C_Mckenzie,D,'b')
grid
axis ij
xlabel('Sound Speed, C (m/s)')
ylabel('Depth, D (m)')
% legend('Data','Medwin')
legend('Data','Medwin','Leroy','Mckenzie')

figure(2)
plot(C,D,'k',C_Medwin,D,'r',C_Leroy,D,'g',C_Mckenzie,D,'b')
grid
axis ij
xlabel('Sound Speed, C (m/s)')
ylabel('Depth, D (m)')
legend('Data','Medwin','Leroy','Mckenzie')

error_Medwin = 1/11998*sum(sqrt((C_Medwin - C).^2/mean(C)))

SVP_read

clear all
close all

% Baca EXCEL File


% A = Kedalaman, D (m) dan Sound Speed, C (m/s)

[A,B] = xlsread('Stasiun3','DATA1');

D = A(:,1); % Kedalaman, D (m)


C = A(:,4); % Sound Speed, C (m/s)

% Polyfit (P(1)X^N + P(2)X^(N-1) + .......


% Orde N=6
% Polyfit Data dgn Persamaan Pangkat N
% CN = Sound Speed (m/s) dari Polyfit orde N

[P,S] = polyfit(D,C,6);
C6 = P(1)*D.^6+P(2)*D.^5+P(3)*D.^4+P(4)*D.^3+P(5)*D.^2+P(6)*D.^1+P(7)*D.^0;
save test6.txt P -ASCII

[P,S] = polyfit(D,C,5);
C5 = P(1)*D.^5+P(2)*D.^4+P(3)*D.^3+P(4)*D.^2+P(5)*D.^1+P(6)*D.^0;
save test5.txt P -ASCII

[P,S] = polyfit(D,C,12);
C12 =
P(1)*D.^12+P(2)*D.^11+P(3)*D.^10+P(4)*D.^9+P(5)*D.^8+P(6)*D.^7+P(7)*D.^6+P(8)*D.^5+P(9)*D.^4+P(10)*
D.^3+P(11)*D.^2+P(12)*D.^1+P(13)*D.^0;
save test12.txt P -ASCII

[P,S] = polyfit(D,C,13);
C13 =
P(1)*D.^13+P(2)*D.^12+P(3)*D.^11+P(4)*D.^10+P(5)*D.^9+P(6)*D.^8+P(7)*D.^7+P(8)*D.^6+P(9)*D.^5+P(10)
*D.^4+P(11)*D.^3+P(12)*D.^2+P(13)*D.^1+P(14)*D.^0;
save test13.txt P -ASCII

[P,S] = polyfit(D,C,14);
C14 =
P(1)*D.^14+P(2)*D.^13+P(3)*D.^12+P(4)*D.^11+P(5)*D.^10+P(6)*D.^9+P(7)*D.^8+P(8)*D.^7+P(9)*D.^6+P(1
0)*D.^5+P(11)*D.^4+P(12)*D.^3+P(13)*D.^2+P(14)*D.^1+P(15)*D.^0;
save test14.txt P -ASCII
% Plot C1 vs d

plot(C,D,'o',C12,D,'r',C5,D,'g',C6,D,'k',C13,D,'y',C14,D)
% figure(1)
% subplot(1,2,1), plot(C,D,'o',C12,D,'r',C5,D,'g',C6,D,'k')
grid
axis ij
xlabel('Sound Speed, C (m/s)')
ylabel('Depth, D (m)')
legend('Data','N=12','N=5','N=6','N=13')

% save test.txt P -ASCII


SVP_read_A

%clear all
%close all

% Baca EXCEL File


% A = Kedalaman, D (m) dan Sound Speed, C (m/s)

[A,B] = xlsread('Stasiun3','DATA1');

D = A(:,1); % Kedalaman, D (m)


C = A(:,4); % Sound Speed, C (m/s)

% Polyfit (P(1)X^N + P(2)X^(N-1) + .......


% Orde N=6
% Polyfit Data dgn Persamaan Pangkat N
% CN = Sound Speed (m/s) dari Polyfit orde N

[P,S] = polyfit(D,C,6);
C6 = P(1)*D.^6+P(2)*D.^5+P(3)*D.^4+P(4)*D.^3+P(5)*D.^2+P(6)*D.^1+P(7)*D.^0;
save test6.txt P -ASCII

[P,S] = polyfit(D,C,5);
C5 = P(1)*D.^5+P(2)*D.^4+P(3)*D.^3+P(4)*D.^2+P(5)*D.^1+P(6)*D.^0;
save test5.txt P -ASCII

[P,S] = polyfit(D,C,12);
C12 =
P(1)*D.^12+P(2)*D.^11+P(3)*D.^10+P(4)*D.^9+P(5)*D.^8+P(6)*D.^7+P(7)*D.^6+P(8)*D.^5+P(9)*D.^4+P(10)*
D.^3+P(11)*D.^2+P(12)*D.^1+P(13)*D.^0;
save test12.txt P -ASCII

[P,S] = polyfit(D,C,13);
C13 =
P(1)*D.^13+P(2)*D.^12+P(3)*D.^11+P(4)*D.^10+P(5)*D.^9+P(6)*D.^8+P(7)*D.^7+P(8)*D.^6+P(9)*D.^5+P(10)
*D.^4+P(11)*D.^3+P(12)*D.^2+P(13)*D.^1+P(14)*D.^0;
save test13.txt P -ASCII
% Plot C1 vs d

plot(C,D,'o',C12,D,'r',C5,D,'g',C6,D,'k',C13,D,'y')
% figure(1)
subplot(1,2,1), plot(C,D,'o',C12,D,'r',C5,D,'g',C6,D,'k',C13,D,'y')
axis ij
xlabel('Sound Speed, C (m/s)')
ylabel('Depth, D (m)')
legend('Data','N=12','N=5','N=6','N=13')

% save test.txt P -ASCII

RAYF.xx

function xdot = f( s, x )

% Munk sound speed profile

% eps = 0.00737;
%c0 = 1500;
z = x( 2 );
% xt = 2 * ( z - 1300 ) / 1300;
% c = c0 * ( 1 + eps * ( xt - 1 + exp( -xt ) ) );
load test13.txt
P = test13;
D=z;
c=
P(1)*D.^13+P(2)*D.^12+P(3)*D.^11+P(4)*D.^10+P(5)*D.^9+P(6)*D.^8+P(7)*D.^7+P(8)*D.^6+P(9)*D.^5+P(10)
*D.^4+P(11)*D.^3+P(12)*D.^2+P(13)*D.^1+P(14)*D.^0;
c2 = c^2;

% we also need derivatives of sound speed

% dxtdz = 2 / 1300;
% cz= c0 * eps * dxtdz * ( 1 - exp( -xt ) );
cz =
13*P(1)*D.^12+12*P(2)*D.^11+11*P(3)*D.^10+10*P(4)*D.^9+9*P(5)*D.^8+8*P(6)*D.^7+7*P(7)*D.^6+6*P(8)
*D.^5+5*P(9)*D.^4+4*P(10)*D.^3+3*P(11)*D.^2+2*P(12)*D.^1+1*P(13)*D.^0;
cr = 0;

% here's the RHS

xdot = zeros( 4, 1 );

xdot( 1 ) = c * x( 3 );
xdot( 2 ) = c * x( 4 );
xdot( 3 ) = -cr / c2;
xdot( 4 ) = -cz / c2;
RAYS1
% ******************************************************
% Rays
% ******************************************************

% The equations we're solving are:


% r' = c rho
% z' = c zeta
% rho' = -c_r / c2
% zeta' = -c_z / c2

clear all
close all

%send = 100000; % arclength for rays


send = 100000; % arclength for rays

%ntheta = 31; % number of rays


ntheta = 101; % number of rays

%theta = pi / 180 * linspace( -14.0, 14.0, ntheta );


theta = pi / 180 * linspace( -5, 5, ntheta );
%theta = pi / 180 * (-5.1281);
%theta = pi / 180 * (0.0);

%zs = 1000.0; % source depth


zs = 5852.79; % source depth

% plot of sound velocity profile


%SVP5A
SVP_read_A

%c0 = 1505.04; % sound speed at source depth


c0 = 1556.37; % sound speed at source depth

for ith = 1:ntheta % loop over take-off angle

% ray initial condition:


x0 = [ 0 zs cos( theta( ith ) ) / c0 sin( theta( ith ) ) / c0 ];

% now solve the DE to trace the ray


% [ s, x ] = ode45( 'rayf', 0.0, send, x0 );
% [ s, x ] = ode45( 'rayf', [0.0 send], x0 );
% [ s, x ] = ode45( 'SVP5', [0.0 send], x0 );
[ s, x ] = ode45( 'RAYF_xx', [0.0 send], x0 );
% subplot(1,2,2), plot( x( : , 1 ), x( : , 2 ) );

% Take absolute value to flip the negative part to positive part


% to take care the reflection at the water surface

subplot(1,2,2), plot( x( : , 1 ), abs (x( : , 2 ) ));


hold on; % hold the old rays on screen when plotting new rays
end
hold off;

% label the plot

xlabel( 'Range (m)' )


ylabel( 'Depth (m)' )
view( 0, -90 ); % flip plot so that z-axis is pointing down

figure(2)
for ith = 1:ntheta % loop over take-off angle

% ray initial condition:


x0 = [ 0 zs cos( theta( ith ) ) / c0 sin( theta( ith ) ) / c0 ];

% now solve the DE to trace the ray


% [ s, x ] = ode45( 'rayf', 0.0, send, x0 );
% [ s, x ] = ode45( 'rayf', [0.0 send], x0 );
% [ s, x ] = ode45( 'SVP5', [0.0 send], x0 );
[ s, x ] = ode45( 'RAYF_xx', [0.0 send], x0 );

% plot( x( : , 1 ), x( : , 2 ) );

% Take absolute value to flip the negative part to positive part


% to take care the reflection at the water surface

plot( x( : , 1 ), abs (x( : , 2 ) ));


hold on; % hold the old rays on screen when plotting new rays
end
hold off;

% label the plot

xlabel( 'Range (m)' )


ylabel( 'Depth (m)' )
view( 0, -90 ); % flip plot so that z-axis is pointing down

You might also like