You are on page 1of 3

!

Max Austin Kondrath


!Project 1 - CEE 303
!(2/10/12)
!Sailboat Mast

------------------------------------------------------------------!external function that calculates the value of the function (d2y/dx2)


! 2*E*I = 4x10^6
-------------------------------------------------------------real function Mast(a,I)
real,intent(in) :: a, I
Mast = (((2700*z*e**((-1/5)*a))/((2*(5*10**9)*I)(5+3*a)))*(13-a)**2)
end function Mast
-------------------------------------------------------------real function Sail(b)
real, intent(in) :: b
Sail = b
end function Sail

---------------------Main Program-------------------------!RK4 sailboat mast deflection approximation


program Sailboat
real, external :: Mast
real, external :: Sail
real z,g,y,gi,yi,h, dh
real k1,k2,k3,k4
real L1,L2,L3,L4
real I, I2, I3
real count
real, dimension(3,27) :: out
real, dimension(3,27) :: out2
real, dimension(3,27) :: out3
I = 4*10**(-4)
I2 = 3.8*10**(-4)
I3 = 4.2*10**(-4)
dh = .5
h = 0
gi = 0
yi = 0
z = 0
g = 0
y=0
count = 1
Do while (h<13.5)
k1 = Sail(gi)
L1 = Mast(z,I)

k2 = Sail(gi + .5*h*L1)
L2 = Mast(z+.5*(h),I)
k3 = Sail(gi + .5*h*L2)
L3 = Mast(z+.5*h,I)
k4 = Sail(gi+L3*h)
L4 = Mast(z+h,I)
g = gi + (1/6)*(k1 +2*k2+2*k3+k4)*dh
y = yi + (1/6)*(L1+2*L2+2*L3+L4)*dh
out(1,count) = g
out(2,count) = y
out(3,count) = h
count = count +1
h = h + dh
end Do
---------------------------------------------------------!Outputs finished array of values to a text file
open (unit = 1, file = 'Sailboat.txt')
write (1,*) out
close (unit=1)
---------Sensitivity trial 1------------------------!Sensitivity to parameter I (+- 5%)
!Find peak deflection at top of mast for:
!I2 = 3.8x10^-4
!I3 = 4.2x10^-4
!Rerun code with new I values
!Reset variables:
dh = .5
h = 0
gi = 0
yi = 0
z = 0
g = 0
y = 0
count = 1
Do while (h<13.5)
k1 = Sail(gi)
L1 = Mast(z,I2)
k2 = Sail(gi + .5*h*L1)
L2 = Mast(z+.5*(h),I2)
k3 = Sail(gi + .5*h*L2)
L3 = Mast(z+.5*h,I2)
k4 = Sail(gi+L3*h)

L4 = Mast(z+h,I2)
g = gi + (1/6)*(k1 +2*k2+2*k3+k4)*dh
y = yi + (1/6)*(L1+2*L2+2*L3+L4)*dh
out2(1,count) = g
out2(2,count) = y
out2(3,count) = h

end Do
write (*,*) "The deflection at the top of the mast for [I-(.05)*I] =" , y
-------------------Sensitivity Trial 2----------------dh = .5
h = 0
gi = 0
yi = 0
g = 0
y = 0
z = 0
count = 1
Do while (h<13.5)
k1 = Sail(gi)
L1 = Mast(z)
k2 = Sail(gi + .5*h*L1)
L2 = Mast(z+.5*(h))
k3 = Sail(gi + .5*h*L2)
L3 = Mast(z+.5*h)
k4 = Sail(gi+L3*h)
L4 = Mast(z+h)
g = gi + (1/6)*(k1 +2*k2+2*k3+k4)*dh
y = yi + (1/6)*(L1+2*L2+2*L3+L4)*dh
out3(1,count) = g
out3(2,count) = y
out3(3,count) = h
count = count +1
h = h + dh
end Do
write (*,*) "The deflection at the top of the mast for [I+(.05)*I] =" , y

--------------------------------end-------------------------

end program

You might also like