SlideShare a Scribd company logo
Matlab Code for Solution of the Equation of Ship Rolling, CDF & LRFD
close all
clear all
clc
sigmahat=0.5;
significant_waveheight=0.10;
g=9.8;
A=8.1e-3*g;
B=3.11/(significant_waveheight^2);
t_start(1)=0;
t_end=900;
t_step=0.01;
number_t_step=(t_end-t_start(1))/t_step;
wave_omega_start(1)=0.05;
wave_omega_end=6;
wave_omega_step=0.05;
number_wave_omega_step=(wave_omega_end-wave_omega_start(1))/wave_omega_step;
for j=1:number_t_step+1
summation_wave_amplitude(j)=0;
end
%for i=1:number_wave_omega_step+1
%phase(i)=6.2832*rand(1,1);% Phase angle is not included in the following
for loop because
% the phase angle will be changed in each time
step
%end
load ('random_phase_for_irregularwave.mat')
for j=1:number_t_step+1
for i=1:number_wave_omega_step+1 % this loop will sum the wave amplitude
at each time step over all frequencies
%S(i)=A*wave_omega_start(i)^-5*exp(-B*wave_omega_start(i)^-4);
S(i)=0.0081*((g^2)/(wave_omega_start(i)^5))*exp(-
0.032*(g/(significant_waveheight*(wave_omega_start(i)^2)))^2);
zeta(i)=sqrt(2*S(i)*wave_omega_step);
wave_amplitude=zeta(i)*cos(wave_omega_start(i)*t_start(j)+phase(i));
summation_wave_amplitude(j)=summation_wave_amplitude(j)+wave_amplitude;
if(i<number_wave_omega_step+1) %if statement is used to eleminate the
121th element of wave_omega_start
wave_omega_start(i+1)=wave_omega_start(i)+wave_omega_step;
end
end
if(j<number_t_step+1)%if statement is used to eleminate the 40002th
element of wave_omega_start
t_start(j+1)=t_start(j)+t_step;
end
end
figure
plot(t_start,summation_wave_amplitude)
title('Time vs Irregular Wave Amplitude');
xlabel('Time in second');
ylabel('Amplitude in meter');
figure
histfit(summation_wave_amplitude);
title('Histogram for Irregular Wave');
xlabel('Wave Amplitude');
ylabel('Frequency');
figure
[muhat_1,sigmahat_1] = normfit(summation_wave_amplitude);
pdfNormal_1 = normpdf(summation_wave_amplitude,muhat_1,sigmahat_1);
plot(summation_wave_amplitude, pdfNormal_1)
title('PDF for Irregular Wave');
xlabel('Wave Amplitude');
ylabel('f(Wave Amplitude)');
figure
cdfNormal_1=normcdf(summation_wave_amplitude,muhat_1, sigmahat_1);
plot(summation_wave_amplitude,cdfNormal_1)
title('CDF for Irregular Wave');
xlabel('Wave Amplitude');
ylabel('F(Wave Amplitude)');
time_period_roll=6.3366;
natural_omega=(2*3.1416)/time_period_roll;
density=997.04;
beam=[6.50 6.58 6.75 6.84 7.01 6.92 6.67 6.64 5.23 2.70];
draft=3.81;
displacement=227984;
metacentric_height=.947;
moment_of_inertia=(displacement*metacentric_height)/natural_omega^2;
damping_coefficient_1=0.01107;
damping_coefficient_2=0.01186;
%b_1=damping_coefficient_1/moment_of_inertia;
%b_2=damping_coefficient_2/moment_of_inertia;
b_1=0.14639;
b_2=0.14639;
for j=1:number_t_step+1% for each time step initially the summation of
heeling moment is considered 0
summation_heeling_moment(j)=0;
end
for i=1:number_wave_omega_step+1% This loop will calculte the coefficient of
right hand side/heeling moment at each frequency
time_period_wave(i)=(2*3.1416)/wave_omega_start(i);
wave_length(i)=(g/(2*3.1416))*time_period_wave(i)^2;
for j=1:number_t_step+1% this loop generates the wave amplitude at each
frequency over the defined time period.
wave_apmlitude(j)=zeta(i)*cos(wave_omega_start(i)*t_start(j)+phase(i));
end
wave_height(i)=max(wave_apmlitude)- min(wave_apmlitude);% wave height is
calculted for the wave of each frequency by subtracting minimum amplitude
from maximum amplitude
%reduction_coefficient_wave_slope(i)=atan(wave_height(i)/wave_length(i));
reduction_coefficient_wave_slope=0.682;
if (time_period_wave(i)>=11.2)
coeff_roll_add_mass=(((time_period_wave(i)-11.2)*.015)/2.7)+.07;
else
coeff_roll_add_mass=0.07-(((11.2-time_period_wave(i))*.015)/2.7);
end
%simpson rule
delata_l=1;
b44=(delata_l/3)*coeff_roll_add_mass*density*draft*beam.^3;
added_mass_moment(i)=b44(1)+b44(2)+b44(3)+b44(4)+b44(5)+b44(6)+b44(7)+b44(8)+
b44(9)+b44(10);
amplitude_e(i)=0.5*reduction_coefficient_wave_slope*(wave_height(i)/g)*wave_o
mega_start(i)^2*(abs(natural_omega^2-
(wave_omega_start(i)^2*added_mass_moment(i))/moment_of_inertia));
for j=1:number_t_step+1% this loop will sum the right hand side at each
frequency over the time period
heeling_moment=(1/(g*1000))*amplitude_e(i)*moment_of_inertia*cos(wave_omega_s
tart(i)*t_start(j)+phase(i));
summation_heeling_moment(j)=summation_heeling_moment(j)+heeling_moment;
end
end
figure
plot(t_start,summation_heeling_moment)
title('Time vs Heeling Moment');
xlabel('Time in second');
ylabel('Heeling Moment');
figure
histfit(summation_heeling_moment);
title('Histogram for Heeling Moment');
xlabel('Heeling Moment');
ylabel('Frequency');
figure
[muhat_2,sigmahat_2] = normfit(summation_heeling_moment);
muhat_2
sigmahat_2
pdfNormal_2 = normpdf(summation_heeling_moment,muhat_2,sigmahat_2);
plot(summation_heeling_moment, pdfNormal_2)
title('PDF for Heeling Moment');
xlabel('Heeling Moment');
ylabel('f(Heeling Moment)');
figure
cdfNormal_2=normcdf(summation_heeling_moment,muhat_2, sigmahat_2);
plot(summation_heeling_moment,cdfNormal_2)
title('CDF for Heeling Moment');
xlabel('Heeling Moment');
ylabel('F(Heeling Moment)');
f_1=inline('-b_1*v-b_2*v*abs(v)-natural_omega^2*x+summation_right_side');%
According to the runge kutta method the second order differential
%equation should be represented as :
%v_dot+b_1*v+b_2*v*abs(v)+natural_omega^2*x=summation_right_side
x_initial(1)=0;% initial roll angle is zero
v_initial(1)=0;% initial roll velocity is zero
for j=1:number_t_step+1% Right hand side is a function of time
summation_right_side_A(j)=0;%
summation_right_side_B(j)=0;
summation_right_side_C(j)=0;
end
% the following loop will sum the right hand side at first for each time
% step
for j=1:number_t_step+1
for i=1:number_wave_omega_step+1% this loop wiil sum the right hand side
for each time step over all frequencies
right_hand_side_A=amplitude_e(i)*cos(wave_omega_start(i)*t_start(j)+phase(i))
;% according to the runge kutta procedure only t_start(j) is used for right
hand side
summation_right_side_A(j)=summation_right_side_A(j)+right_hand_side_A;% right
hand side is summed for each time step which will be used in dv_1.
right_hand_side_B=amplitude_e(i)*cos(wave_omega_start(i)*(t_start(j)+t_step*0
.5)+phase(i));% according to the runge kutta procedure only
t_start(j)+t_step*0.5 is used for right hand side
summation_right_side_B(j)=summation_right_side_B(j)+right_hand_side_B;%right
hand side is summed for each time step which will be used in dv_2 & dv_3.
right_hand_side_C=amplitude_e(i)*cos(wave_omega_start(i)*(t_start(j)+t_step)+
phase(i));% according to the runge kutta procedure only t_start(j)+t_step is
used for right hand side
summation_right_side_C(j)=summation_right_side_C(j)+right_hand_side_C;%right
hand side is summed for each time step which will be used in dv_4.
end
end
for j=1:number_t_step+1
dx_1=t_step*v_initial(j);
dv_1=t_step*f_1(b_1,b_2,natural_omega,summation_right_side_A(j),v_initial(j),
x_initial(j));
dx_2=t_step*(v_initial(j)+(dv_1/2));
dv_2=t_step*f_1(b_1,b_2,natural_omega,summation_right_side_B(j),v_initial(j)+
0.5*dv_1,x_initial(j)+dx_1*0.5);
dx_3=t_step*(v_initial(j)+(dv_2/2));
dv_3=t_step*f_1(b_1,b_2,natural_omega,summation_right_side_B(j),v_initial(j)+
0.5*dv_2,x_initial(j)+dx_2*0.5);
dx_4=t_step*(v_initial(j)+(dv_3));
dv_4=t_step*f_1(b_1,b_2,natural_omega,summation_right_side_C(j),v_initial(j)+
dv_3,x_initial(j)+dx_3);
if(j<number_t_step+1)
x_initial(j+1)=x_initial(j)+(1/6)*(dx_1+2*dx_2+2*dx_3+dx_4);%
x_initial is the roll angle
v_initial(j+1)=v_initial(j)+(1/6)*(dv_1+2*dv_2+2*dv_3+dv_4);
end
end
for j=1:number_t_step+1
x_initial_1(j)=x_initial(j)*57.2975;
end
figure
plot(t_start,x_initial_1)
title('Time vs Roll Angle');
xlabel('Time in second');
ylabel('Roll Angle in Degree');
figure
histfit(x_initial_1);
title('Histogram for Roll Angle');
xlabel('Roll Angle');
ylabel('Frequency');
figure
[muhat_3,sigmahat_3] = normfit(x_initial_1);
pdfNormal_3 = normpdf(x_initial_1,muhat_3,sigmahat_3);
plot(x_initial_1, pdfNormal_3)
title('PDF for Roll Angle');
xlabel('Roll Angle');
ylabel('f(Roll Angle)');
figure
cdfNormal_3=normcdf(x_initial_1,muhat_3, sigmahat_3);
plot(x_initial_1,cdfNormal_3)
title('CDF for Roll Angle');
xlabel('Roll Angle');
ylabel('F(Roll Angle)');
for j=1:number_t_step+1
righting_moment(j)=(1/1000)*displacement*metacentric_height*sin(x_initial(j))
;
end
figure
plot(t_start,righting_moment)
title('Time vs Righting Moment');
xlabel('Time in second');
ylabel('Righting Moment');
figure
histfit(righting_moment);
title('Histogram for Righting Moment');
xlabel('Righting Moment');
ylabel('Frequency');
figure
[muhat_4,sigmahat_4] = normfit(righting_moment);
muhat_4
sigmahat_4
pdfNormal_4 = normpdf(righting_moment,muhat_4,sigmahat_4);
plot(righting_moment, pdfNormal_4)
title('PDF for Righting Moment');
xlabel('Righting Moment');
ylabel('f(Righting Moment)');
figure
cdfNormal_4=normcdf(righting_moment,muhat_4, sigmahat_4);
plot(righting_moment,cdfNormal_4)
title('CDF for Righting Moment');
xlabel('Righting Moment');
ylabel('F(Righting Moment)');
%probability calculation
A=find(abs(righting_moment)<abs(summation_heeling_moment));
cases_rm_less_then_hm=length(A)
total_number_of_events=number_t_step+1
P_A=cases_rm_less_then_hm/total_number_of_events% probability that righting
moment is less then heeling moment
deck_immersion_angle=4.89;
B=find(abs(x_initial_1)>deck_immersion_angle);
cases_ra_greater_then_deack_angle=length(B)
P_B=cases_ra_greater_then_deack_angle/total_number_of_events
cases_for_A_and_B=0;
for j=1:number_t_step+1
if((abs(x_initial_1(j))>deck_immersion_angle) &&
(abs(righting_moment(j))<abs(summation_heeling_moment(j))))
cases_for_A_and_B=cases_for_A_and_B+1;
end
end
cases_for_A_and_B
P_C=cases_for_A_and_B/total_number_of_events
p=1;
q=500;
r(1)=1;
for m=1:160
l=1;
for n=p:q
segment_righting_moment_(m,l)=abs(righting_moment(n));
segment_heeling_moment_(m,l)=abs(summation_heeling_moment(n));
l=l+1;
end
[segment_muhat_4(m),segment_sigmahat_4(m)]=normfit(segment_righting_moment_(m
,1:500));
[segment_muhat_2(m),segment_sigmahat_2(m)]=normfit(segment_heeling_moment_(m,
1:500));
z(m)=(segment_muhat_4(m)-
segment_muhat_2(m))/sqrt(segment_sigmahat_4(m)*segment_sigmahat_4(m)+segment_
sigmahat_4(m)*segment_sigmahat_4(m));
p=p+500;
q=q+500;
if(m<160)%if statement is used to eleminate the 40002th element of
wave_omega_start
r(m+1)=r(m)+1;
end
end
figure
plot(r,z)
title('"Z" values for the each segment from the total 800 second window');
xlabel('Segment No');
ylabel('"Z"');
p_normal=normcdf(z);
figure
plot(r,p_normal)
title('probability for the each segment from the total 800 second window');
xlabel('Segment No');
ylabel('probability');
p=1;
q=40;
r1(1)=1;
for m=1:4
average_p_normal(m)=0;
for n=p:q
average_p_normal(m)=average_p_normal(m)+p_normal(n);
end
mean_p_normal(m)=average_p_normal(m)/40;
p=p+40;
q=q+40;
if(m<4)%if statement is used to eleminate the 40002th element of
wave_omega_start
r1(m+1)=r1(m)+1;
end
end
pp = polyfit(r1,mean_p_normal,3);
x1 = linspace(1,4);
y1_2 = polyval(pp,x1);
figure
plot(r1,mean_p_normal,'o')
hold on
plot(x1,y1_2)
hold off
save('average_p_normal.mat','y1_2','-append')
Matlab Code for the Comparison of Capsizing Probability for Different Sea State
close all
clear all
clc
load('average_p_normal.mat')
figure
plot(x1,y1_1,'k')
hold on
plot(x1,y1_2,'c')
hold on
plot(x1,y1_3,'b')
hold on
plot(x1,y1_4,'m')
hold on
plot(x1,y1_5,'g')
hold on
plot(x1,y1_6,'y')
hold on
plot(x1,y1_7,'r')
hold on
ylabel('Probaility of Capsizing')
xlabel('segment no')
legend('Sea Stae 1','Sea state 2','Sea state 3','Sea state 4','Sea state
5','Sea state 6','Sea state 7')
box off
a2 = axes('XAxisLocation', 'Top');
set(a2, 'color', 'none')
set(a2, 'YTick', [])
set(a2, 'XLim', [0 800])
xlabel(a2,'Time')

More Related Content

Viewers also liked

Funciones de la administración
Funciones de la administraciónFunciones de la administración
Funciones de la administración
Daniela Caro Vitalic
 
Strategy Formulation _ Coursera_main
Strategy Formulation _ Coursera_mainStrategy Formulation _ Coursera_main
Strategy Formulation _ Coursera_main
Sayantan Ghosh
 
brochure ycbs abuja 2016 4 aa print
brochure ycbs abuja 2016 4 aa printbrochure ycbs abuja 2016 4 aa print
brochure ycbs abuja 2016 4 aa print
Ekine Tonye
 
Journey to Financial Security
Journey to Financial SecurityJourney to Financial Security
Journey to Financial Security
Scott Ayers
 
How to select: Succession planning software
How to select: Succession planning softwareHow to select: Succession planning software
How to select: Succession planning software
Talentia Software UK
 
Presentación1
Presentación1Presentación1
Plantilla de diseño
Plantilla de diseñoPlantilla de diseño
Plantilla de diseño
Amandy R Mu
 

Viewers also liked (7)

Funciones de la administración
Funciones de la administraciónFunciones de la administración
Funciones de la administración
 
Strategy Formulation _ Coursera_main
Strategy Formulation _ Coursera_mainStrategy Formulation _ Coursera_main
Strategy Formulation _ Coursera_main
 
brochure ycbs abuja 2016 4 aa print
brochure ycbs abuja 2016 4 aa printbrochure ycbs abuja 2016 4 aa print
brochure ycbs abuja 2016 4 aa print
 
Journey to Financial Security
Journey to Financial SecurityJourney to Financial Security
Journey to Financial Security
 
How to select: Succession planning software
How to select: Succession planning softwareHow to select: Succession planning software
How to select: Succession planning software
 
Presentación1
Presentación1Presentación1
Presentación1
 
Plantilla de diseño
Plantilla de diseñoPlantilla de diseño
Plantilla de diseño
 

Similar to Capsizing

Drill bit optimization code
Drill bit optimization codeDrill bit optimization code
Drill bit optimization code
ANKIT KUKREJA
 
Final_project_Matlab
Final_project_MatlabFinal_project_Matlab
Final_project_Matlab
Spencer Minder
 
Fourier series example
Fourier series exampleFourier series example
Fourier series example
Abi finni
 
LAB05ex1.mfunction LAB05ex1m = 1; .docx
LAB05ex1.mfunction LAB05ex1m = 1;                          .docxLAB05ex1.mfunction LAB05ex1m = 1;                          .docx
LAB05ex1.mfunction LAB05ex1m = 1; .docx
smile790243
 
Solutions_Manual_to_accompany_Applied_Nu.pdf
Solutions_Manual_to_accompany_Applied_Nu.pdfSolutions_Manual_to_accompany_Applied_Nu.pdf
Solutions_Manual_to_accompany_Applied_Nu.pdf
WaleedHussain30
 
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfIncorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
aartechindia
 
Surge Swab pressure code
Surge Swab pressure codeSurge Swab pressure code
Surge Swab pressure code
ANKIT KUKREJA
 
Two Dimensional Unsteady Heat Conduction in T-shaped Plate.pdf
Two Dimensional Unsteady Heat Conduction in T-shaped Plate.pdfTwo Dimensional Unsteady Heat Conduction in T-shaped Plate.pdf
Two Dimensional Unsteady Heat Conduction in T-shaped Plate.pdf
Shehzaib Yousuf Khan
 
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdf
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdfConsider a 4-Link robot manipulator shown below. Use the forward kine.pdf
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdf
meerobertsonheyde608
 
Acceleration Modelling of EV1_FR8695
Acceleration Modelling of EV1_FR8695Acceleration Modelling of EV1_FR8695
Acceleration Modelling of EV1_FR8695
Siddhesh Ozarkar
 
Matlab kod taslağı
Matlab kod taslağıMatlab kod taslağı
Matlab kod taslağı
Merve Cvdr
 
BS LAB Manual (1).pdf
BS LAB Manual  (1).pdfBS LAB Manual  (1).pdf
BS LAB Manual (1).pdf
ssuser476810
 
HIDRAULICA DE CANALES
HIDRAULICA DE CANALESHIDRAULICA DE CANALES
HIDRAULICA DE CANALES
Dennis Ventura Huaman
 
Lag lead compensator design in frequency domain 7th lecture
Lag lead compensator design in frequency domain  7th lectureLag lead compensator design in frequency domain  7th lecture
Lag lead compensator design in frequency domain 7th lecture
Khalaf Gaeid Alshammery
 
DC servo motor
DC servo motorDC servo motor
DC servo motor
Web Design & Development
 
HodgeCyce
HodgeCyceHodgeCyce
HodgeCyce
Bridget Jones
 
control system
control systemcontrol system
control system
naqeeb93
 
Time Dependent and Independent operations (signal and systems)
Time Dependent and Independent operations (signal and systems)Time Dependent and Independent operations (signal and systems)
Time Dependent and Independent operations (signal and systems)
Omkar Rane
 
ilovepdf_merged
ilovepdf_mergedilovepdf_merged
ilovepdf_merged
Marcello Gomes
 
I need help understanding the Pan Tompkins algorythm, and Id also .pdf
I need help understanding the Pan Tompkins algorythm, and Id also .pdfI need help understanding the Pan Tompkins algorythm, and Id also .pdf
I need help understanding the Pan Tompkins algorythm, and Id also .pdf
eyewatchsystems
 

Similar to Capsizing (20)

Drill bit optimization code
Drill bit optimization codeDrill bit optimization code
Drill bit optimization code
 
Final_project_Matlab
Final_project_MatlabFinal_project_Matlab
Final_project_Matlab
 
Fourier series example
Fourier series exampleFourier series example
Fourier series example
 
LAB05ex1.mfunction LAB05ex1m = 1; .docx
LAB05ex1.mfunction LAB05ex1m = 1;                          .docxLAB05ex1.mfunction LAB05ex1m = 1;                          .docx
LAB05ex1.mfunction LAB05ex1m = 1; .docx
 
Solutions_Manual_to_accompany_Applied_Nu.pdf
Solutions_Manual_to_accompany_Applied_Nu.pdfSolutions_Manual_to_accompany_Applied_Nu.pdf
Solutions_Manual_to_accompany_Applied_Nu.pdf
 
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfIncorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
 
Surge Swab pressure code
Surge Swab pressure codeSurge Swab pressure code
Surge Swab pressure code
 
Two Dimensional Unsteady Heat Conduction in T-shaped Plate.pdf
Two Dimensional Unsteady Heat Conduction in T-shaped Plate.pdfTwo Dimensional Unsteady Heat Conduction in T-shaped Plate.pdf
Two Dimensional Unsteady Heat Conduction in T-shaped Plate.pdf
 
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdf
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdfConsider a 4-Link robot manipulator shown below. Use the forward kine.pdf
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdf
 
Acceleration Modelling of EV1_FR8695
Acceleration Modelling of EV1_FR8695Acceleration Modelling of EV1_FR8695
Acceleration Modelling of EV1_FR8695
 
Matlab kod taslağı
Matlab kod taslağıMatlab kod taslağı
Matlab kod taslağı
 
BS LAB Manual (1).pdf
BS LAB Manual  (1).pdfBS LAB Manual  (1).pdf
BS LAB Manual (1).pdf
 
HIDRAULICA DE CANALES
HIDRAULICA DE CANALESHIDRAULICA DE CANALES
HIDRAULICA DE CANALES
 
Lag lead compensator design in frequency domain 7th lecture
Lag lead compensator design in frequency domain  7th lectureLag lead compensator design in frequency domain  7th lecture
Lag lead compensator design in frequency domain 7th lecture
 
DC servo motor
DC servo motorDC servo motor
DC servo motor
 
HodgeCyce
HodgeCyceHodgeCyce
HodgeCyce
 
control system
control systemcontrol system
control system
 
Time Dependent and Independent operations (signal and systems)
Time Dependent and Independent operations (signal and systems)Time Dependent and Independent operations (signal and systems)
Time Dependent and Independent operations (signal and systems)
 
ilovepdf_merged
ilovepdf_mergedilovepdf_merged
ilovepdf_merged
 
I need help understanding the Pan Tompkins algorythm, and Id also .pdf
I need help understanding the Pan Tompkins algorythm, and Id also .pdfI need help understanding the Pan Tompkins algorythm, and Id also .pdf
I need help understanding the Pan Tompkins algorythm, and Id also .pdf
 

Capsizing

  • 1. Matlab Code for Solution of the Equation of Ship Rolling, CDF & LRFD close all clear all clc sigmahat=0.5; significant_waveheight=0.10; g=9.8; A=8.1e-3*g; B=3.11/(significant_waveheight^2); t_start(1)=0; t_end=900; t_step=0.01; number_t_step=(t_end-t_start(1))/t_step; wave_omega_start(1)=0.05; wave_omega_end=6; wave_omega_step=0.05; number_wave_omega_step=(wave_omega_end-wave_omega_start(1))/wave_omega_step; for j=1:number_t_step+1 summation_wave_amplitude(j)=0; end %for i=1:number_wave_omega_step+1 %phase(i)=6.2832*rand(1,1);% Phase angle is not included in the following for loop because % the phase angle will be changed in each time step %end load ('random_phase_for_irregularwave.mat') for j=1:number_t_step+1 for i=1:number_wave_omega_step+1 % this loop will sum the wave amplitude at each time step over all frequencies %S(i)=A*wave_omega_start(i)^-5*exp(-B*wave_omega_start(i)^-4); S(i)=0.0081*((g^2)/(wave_omega_start(i)^5))*exp(- 0.032*(g/(significant_waveheight*(wave_omega_start(i)^2)))^2); zeta(i)=sqrt(2*S(i)*wave_omega_step); wave_amplitude=zeta(i)*cos(wave_omega_start(i)*t_start(j)+phase(i)); summation_wave_amplitude(j)=summation_wave_amplitude(j)+wave_amplitude; if(i<number_wave_omega_step+1) %if statement is used to eleminate the 121th element of wave_omega_start wave_omega_start(i+1)=wave_omega_start(i)+wave_omega_step; end end if(j<number_t_step+1)%if statement is used to eleminate the 40002th element of wave_omega_start t_start(j+1)=t_start(j)+t_step; end end figure plot(t_start,summation_wave_amplitude) title('Time vs Irregular Wave Amplitude'); xlabel('Time in second'); ylabel('Amplitude in meter'); figure histfit(summation_wave_amplitude);
  • 2. title('Histogram for Irregular Wave'); xlabel('Wave Amplitude'); ylabel('Frequency'); figure [muhat_1,sigmahat_1] = normfit(summation_wave_amplitude); pdfNormal_1 = normpdf(summation_wave_amplitude,muhat_1,sigmahat_1); plot(summation_wave_amplitude, pdfNormal_1) title('PDF for Irregular Wave'); xlabel('Wave Amplitude'); ylabel('f(Wave Amplitude)'); figure cdfNormal_1=normcdf(summation_wave_amplitude,muhat_1, sigmahat_1); plot(summation_wave_amplitude,cdfNormal_1) title('CDF for Irregular Wave'); xlabel('Wave Amplitude'); ylabel('F(Wave Amplitude)'); time_period_roll=6.3366; natural_omega=(2*3.1416)/time_period_roll; density=997.04; beam=[6.50 6.58 6.75 6.84 7.01 6.92 6.67 6.64 5.23 2.70]; draft=3.81; displacement=227984; metacentric_height=.947; moment_of_inertia=(displacement*metacentric_height)/natural_omega^2; damping_coefficient_1=0.01107; damping_coefficient_2=0.01186; %b_1=damping_coefficient_1/moment_of_inertia; %b_2=damping_coefficient_2/moment_of_inertia; b_1=0.14639; b_2=0.14639; for j=1:number_t_step+1% for each time step initially the summation of heeling moment is considered 0 summation_heeling_moment(j)=0; end for i=1:number_wave_omega_step+1% This loop will calculte the coefficient of right hand side/heeling moment at each frequency time_period_wave(i)=(2*3.1416)/wave_omega_start(i); wave_length(i)=(g/(2*3.1416))*time_period_wave(i)^2; for j=1:number_t_step+1% this loop generates the wave amplitude at each frequency over the defined time period. wave_apmlitude(j)=zeta(i)*cos(wave_omega_start(i)*t_start(j)+phase(i)); end wave_height(i)=max(wave_apmlitude)- min(wave_apmlitude);% wave height is calculted for the wave of each frequency by subtracting minimum amplitude from maximum amplitude %reduction_coefficient_wave_slope(i)=atan(wave_height(i)/wave_length(i)); reduction_coefficient_wave_slope=0.682; if (time_period_wave(i)>=11.2) coeff_roll_add_mass=(((time_period_wave(i)-11.2)*.015)/2.7)+.07; else coeff_roll_add_mass=0.07-(((11.2-time_period_wave(i))*.015)/2.7); end %simpson rule delata_l=1; b44=(delata_l/3)*coeff_roll_add_mass*density*draft*beam.^3;
  • 3. added_mass_moment(i)=b44(1)+b44(2)+b44(3)+b44(4)+b44(5)+b44(6)+b44(7)+b44(8)+ b44(9)+b44(10); amplitude_e(i)=0.5*reduction_coefficient_wave_slope*(wave_height(i)/g)*wave_o mega_start(i)^2*(abs(natural_omega^2- (wave_omega_start(i)^2*added_mass_moment(i))/moment_of_inertia)); for j=1:number_t_step+1% this loop will sum the right hand side at each frequency over the time period heeling_moment=(1/(g*1000))*amplitude_e(i)*moment_of_inertia*cos(wave_omega_s tart(i)*t_start(j)+phase(i)); summation_heeling_moment(j)=summation_heeling_moment(j)+heeling_moment; end end figure plot(t_start,summation_heeling_moment) title('Time vs Heeling Moment'); xlabel('Time in second'); ylabel('Heeling Moment'); figure histfit(summation_heeling_moment); title('Histogram for Heeling Moment'); xlabel('Heeling Moment'); ylabel('Frequency'); figure [muhat_2,sigmahat_2] = normfit(summation_heeling_moment); muhat_2 sigmahat_2 pdfNormal_2 = normpdf(summation_heeling_moment,muhat_2,sigmahat_2); plot(summation_heeling_moment, pdfNormal_2) title('PDF for Heeling Moment'); xlabel('Heeling Moment'); ylabel('f(Heeling Moment)'); figure cdfNormal_2=normcdf(summation_heeling_moment,muhat_2, sigmahat_2); plot(summation_heeling_moment,cdfNormal_2) title('CDF for Heeling Moment'); xlabel('Heeling Moment'); ylabel('F(Heeling Moment)'); f_1=inline('-b_1*v-b_2*v*abs(v)-natural_omega^2*x+summation_right_side');% According to the runge kutta method the second order differential %equation should be represented as : %v_dot+b_1*v+b_2*v*abs(v)+natural_omega^2*x=summation_right_side x_initial(1)=0;% initial roll angle is zero v_initial(1)=0;% initial roll velocity is zero for j=1:number_t_step+1% Right hand side is a function of time summation_right_side_A(j)=0;% summation_right_side_B(j)=0; summation_right_side_C(j)=0; end % the following loop will sum the right hand side at first for each time % step for j=1:number_t_step+1
  • 4. for i=1:number_wave_omega_step+1% this loop wiil sum the right hand side for each time step over all frequencies right_hand_side_A=amplitude_e(i)*cos(wave_omega_start(i)*t_start(j)+phase(i)) ;% according to the runge kutta procedure only t_start(j) is used for right hand side summation_right_side_A(j)=summation_right_side_A(j)+right_hand_side_A;% right hand side is summed for each time step which will be used in dv_1. right_hand_side_B=amplitude_e(i)*cos(wave_omega_start(i)*(t_start(j)+t_step*0 .5)+phase(i));% according to the runge kutta procedure only t_start(j)+t_step*0.5 is used for right hand side summation_right_side_B(j)=summation_right_side_B(j)+right_hand_side_B;%right hand side is summed for each time step which will be used in dv_2 & dv_3. right_hand_side_C=amplitude_e(i)*cos(wave_omega_start(i)*(t_start(j)+t_step)+ phase(i));% according to the runge kutta procedure only t_start(j)+t_step is used for right hand side summation_right_side_C(j)=summation_right_side_C(j)+right_hand_side_C;%right hand side is summed for each time step which will be used in dv_4. end end for j=1:number_t_step+1 dx_1=t_step*v_initial(j); dv_1=t_step*f_1(b_1,b_2,natural_omega,summation_right_side_A(j),v_initial(j), x_initial(j)); dx_2=t_step*(v_initial(j)+(dv_1/2)); dv_2=t_step*f_1(b_1,b_2,natural_omega,summation_right_side_B(j),v_initial(j)+ 0.5*dv_1,x_initial(j)+dx_1*0.5); dx_3=t_step*(v_initial(j)+(dv_2/2)); dv_3=t_step*f_1(b_1,b_2,natural_omega,summation_right_side_B(j),v_initial(j)+ 0.5*dv_2,x_initial(j)+dx_2*0.5); dx_4=t_step*(v_initial(j)+(dv_3)); dv_4=t_step*f_1(b_1,b_2,natural_omega,summation_right_side_C(j),v_initial(j)+ dv_3,x_initial(j)+dx_3); if(j<number_t_step+1) x_initial(j+1)=x_initial(j)+(1/6)*(dx_1+2*dx_2+2*dx_3+dx_4);% x_initial is the roll angle v_initial(j+1)=v_initial(j)+(1/6)*(dv_1+2*dv_2+2*dv_3+dv_4); end end for j=1:number_t_step+1 x_initial_1(j)=x_initial(j)*57.2975; end figure plot(t_start,x_initial_1) title('Time vs Roll Angle'); xlabel('Time in second'); ylabel('Roll Angle in Degree'); figure
  • 5. histfit(x_initial_1); title('Histogram for Roll Angle'); xlabel('Roll Angle'); ylabel('Frequency'); figure [muhat_3,sigmahat_3] = normfit(x_initial_1); pdfNormal_3 = normpdf(x_initial_1,muhat_3,sigmahat_3); plot(x_initial_1, pdfNormal_3) title('PDF for Roll Angle'); xlabel('Roll Angle'); ylabel('f(Roll Angle)'); figure cdfNormal_3=normcdf(x_initial_1,muhat_3, sigmahat_3); plot(x_initial_1,cdfNormal_3) title('CDF for Roll Angle'); xlabel('Roll Angle'); ylabel('F(Roll Angle)'); for j=1:number_t_step+1 righting_moment(j)=(1/1000)*displacement*metacentric_height*sin(x_initial(j)) ; end figure plot(t_start,righting_moment) title('Time vs Righting Moment'); xlabel('Time in second'); ylabel('Righting Moment'); figure histfit(righting_moment); title('Histogram for Righting Moment'); xlabel('Righting Moment'); ylabel('Frequency'); figure [muhat_4,sigmahat_4] = normfit(righting_moment); muhat_4 sigmahat_4 pdfNormal_4 = normpdf(righting_moment,muhat_4,sigmahat_4); plot(righting_moment, pdfNormal_4) title('PDF for Righting Moment'); xlabel('Righting Moment'); ylabel('f(Righting Moment)'); figure cdfNormal_4=normcdf(righting_moment,muhat_4, sigmahat_4); plot(righting_moment,cdfNormal_4) title('CDF for Righting Moment'); xlabel('Righting Moment'); ylabel('F(Righting Moment)'); %probability calculation A=find(abs(righting_moment)<abs(summation_heeling_moment)); cases_rm_less_then_hm=length(A) total_number_of_events=number_t_step+1 P_A=cases_rm_less_then_hm/total_number_of_events% probability that righting moment is less then heeling moment deck_immersion_angle=4.89; B=find(abs(x_initial_1)>deck_immersion_angle); cases_ra_greater_then_deack_angle=length(B) P_B=cases_ra_greater_then_deack_angle/total_number_of_events
  • 6. cases_for_A_and_B=0; for j=1:number_t_step+1 if((abs(x_initial_1(j))>deck_immersion_angle) && (abs(righting_moment(j))<abs(summation_heeling_moment(j)))) cases_for_A_and_B=cases_for_A_and_B+1; end end cases_for_A_and_B P_C=cases_for_A_and_B/total_number_of_events p=1; q=500; r(1)=1; for m=1:160 l=1; for n=p:q segment_righting_moment_(m,l)=abs(righting_moment(n)); segment_heeling_moment_(m,l)=abs(summation_heeling_moment(n)); l=l+1; end [segment_muhat_4(m),segment_sigmahat_4(m)]=normfit(segment_righting_moment_(m ,1:500)); [segment_muhat_2(m),segment_sigmahat_2(m)]=normfit(segment_heeling_moment_(m, 1:500)); z(m)=(segment_muhat_4(m)- segment_muhat_2(m))/sqrt(segment_sigmahat_4(m)*segment_sigmahat_4(m)+segment_ sigmahat_4(m)*segment_sigmahat_4(m)); p=p+500; q=q+500; if(m<160)%if statement is used to eleminate the 40002th element of wave_omega_start r(m+1)=r(m)+1; end end figure plot(r,z) title('"Z" values for the each segment from the total 800 second window'); xlabel('Segment No'); ylabel('"Z"'); p_normal=normcdf(z); figure plot(r,p_normal) title('probability for the each segment from the total 800 second window'); xlabel('Segment No'); ylabel('probability'); p=1; q=40; r1(1)=1; for m=1:4 average_p_normal(m)=0; for n=p:q average_p_normal(m)=average_p_normal(m)+p_normal(n); end
  • 7. mean_p_normal(m)=average_p_normal(m)/40; p=p+40; q=q+40; if(m<4)%if statement is used to eleminate the 40002th element of wave_omega_start r1(m+1)=r1(m)+1; end end pp = polyfit(r1,mean_p_normal,3); x1 = linspace(1,4); y1_2 = polyval(pp,x1); figure plot(r1,mean_p_normal,'o') hold on plot(x1,y1_2) hold off save('average_p_normal.mat','y1_2','-append') Matlab Code for the Comparison of Capsizing Probability for Different Sea State close all clear all clc load('average_p_normal.mat') figure plot(x1,y1_1,'k') hold on plot(x1,y1_2,'c') hold on plot(x1,y1_3,'b') hold on plot(x1,y1_4,'m') hold on plot(x1,y1_5,'g') hold on plot(x1,y1_6,'y') hold on plot(x1,y1_7,'r') hold on ylabel('Probaility of Capsizing') xlabel('segment no') legend('Sea Stae 1','Sea state 2','Sea state 3','Sea state 4','Sea state 5','Sea state 6','Sea state 7') box off a2 = axes('XAxisLocation', 'Top'); set(a2, 'color', 'none') set(a2, 'YTick', []) set(a2, 'XLim', [0 800]) xlabel(a2,'Time')