# Simpson's rule with changing volumes

Tags:
1. Apr 9, 2016

### noelll

Hi there,

1. The problem statement, all variables and given/known data
I am doing a simulation of a free-fall lifeboat trajectory into the ocean and there is a part where i need to get the volume of the lifeboat to obtain its buoyancy force.

Buoyancy force is proportional to the immersed volume of the body and this volume can be obtain by integrating the immersed cross-section area along the length of the boat(I am using Simpson's rule 1/3 for this).

2. Relevant equations

Buoyancy force = Density*gravity*volume

Question i would like to ask, do i need to find the volume in a time-step manner, currently the ideal i have in mind is at each meter of the lifeboat length i will obtain a cross-section and after reaching the end of the lifeboat length which is 8.5 m i add up all the cross-section area? however i do not know how to do it.

3. The attempt at a solution
i tried doing the simpson's rule. But i could only get a single number.
Code (Text):

%INPUTS
L      = 0;   %lower limit
U      = 8.5; % upper limit
n      = 40;  % number of segments
Length = 1;
Breath = 3;
Height = 2.3;
density= 1.025;
g      = 9.81;

func = @(x) (Breath * Height);
h = (U-L)/n;

st4 = 0;
st2 = 0;

for i = 2:h:n
st4 = st4 + 4*func(i);
end

for i = 3:h:n
st2 = st2 + 2*func(n);
end

buoyancy_force = (density*g)*(h/3*(func(1)+st4+st2+func(i)));

disp (buoyancy_force)
fprintf('step %.3f\n',i);
disp (st4)
disp (st2)
I hope anybody out there could help me, really need your help, thank you so much!
Best Regards,
Noel

Last edited: Apr 9, 2016
2. Apr 9, 2016

### SteamKing

Staff Emeritus
Well, volume is a single number. You are calculating the area under the curve of cross-sectional areas for the hull of the lifeboat, and this area is numerically equal to the volume.

If the immersed volume of the lifeboat is changing in time, then you'll have to calculate a new volume with each time step, assuming you can determine the shape of the cross sections which compose this volume at the corresponding time.

3. Apr 10, 2016

### noelll

Hi,
Thank you so much for your reply,
yes the immersed volume of the lifeboat is changing as it enters the water and i would need to evaluate a new volume each sec, when it dives in. However, i tried doing a while loop, and my code just kept running, my knowledge in matlab is at beginner's level, but i am keen to learn so i hope you could teach me what to do?

Code (Text):

%INPUTS
L      = 0;   %lower limit
U      = 8.5; % upper limit
n      = 40;  % number of segments
Length = 1;
Breath = 3;
Height = 2.3;
density= 1.025;
g      = 9.81;

func = @(x) (Breath * Height);
h = (U-L)/n;

st4 = 0;
st2 = 0;

while (i < 40)

for i = 2:h:n
st4 = st4 + 4*func(i);
end

for i = 3:h:n
st2 = st2 + 2*func(n);
end

Buoyancy_Force = (density*g)*(h/3*(func(1)+st4+st2+func(i)));

end
disp (Buoyancy_Force)
fprintf('step %.3f\n',i);
disp (st4)
disp (st2)
The following while loop i used i<40 , the reason why i put that was, i divided the lifeboat into 40 strips and so i was thinking my simpson's rule could evaluate at every i interval till it reached the 40th strip and stop.

Please help!

Thank you!,
Best Regards,
Noel

#### Attached Files:

• ###### lifeboat.png
File size:
2.3 KB
Views:
76
4. Apr 10, 2016

### SteamKing

Staff Emeritus
IDK anything about MATLAB programming, but there seems to be something strange with the structure of your loops.

You calculate h = (U - L)/n, which gives you 0.2125 using the data in your script. It's not clear how MATLAB decodes i = 2:h:n or i = 3:h:n, but if your loop counter is being incremented by 0.2125 each time, that may be a problem. h is a fixed quantity; I'm just not sure what it's doing in a loop counter.

5. Apr 10, 2016

### noelll

Hi!
Thank you for your reply!
Base on my knowledge, i = 2:h:n refers to i starting value 2 will have a increment of h till it reached the value of n .

Is this causing me the problems? What would you suggest me to do instead?

Sorry to trouble you!
Best regards,
Noel

6. Apr 10, 2016

### SteamKing

Staff Emeritus
Well, IDK if it's causing your problems, but trying to count from 2 to 40 in increments of 0.2125 is a little strange.

I think you need to separate the number of the section of interest (i = 1, 2, 3, ..., 40) from its location from one end of the boat (x = 0, 0.2125, 0.4250, ..., 8.5000.
Let the loop counter i count stations; you can always insert additional code into the body of the loop to calculate where a particular section is located.

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted