Simpson's rule with changing volumes

Click For Summary

Discussion Overview

The discussion revolves around the application of Simpson's rule to calculate the buoyancy force of a lifeboat based on its immersed volume as it enters the ocean. Participants explore the integration of cross-sectional areas along the length of the boat, considering the changing volume over time during free fall.

Discussion Character

  • Homework-related
  • Mathematical reasoning
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Noel describes the need to calculate the buoyancy force based on the immersed volume of the lifeboat, proposing to use Simpson's rule for integration.
  • Some participants clarify that the volume is a single number representing the area under the curve of cross-sectional areas, which is numerically equal to the volume.
  • There is a suggestion that if the immersed volume changes over time, a new volume must be calculated at each time step, depending on the shape of the cross sections.
  • Noel expresses difficulty with MATLAB programming, particularly with implementing a while loop to evaluate the volume at each second as the lifeboat enters the water.
  • Concerns are raised about the structure of Noel's loops, particularly regarding the incrementing of the loop counter by a fixed quantity, which may cause issues in the calculations.
  • Another participant suggests separating the loop counter from the physical location along the boat to avoid confusion in the calculations.

Areas of Agreement / Disagreement

Participants generally agree on the need to calculate the volume at each time step, but there is no consensus on the best approach to implement this in MATLAB. The discussion remains unresolved regarding the specific coding issues Noel is facing.

Contextual Notes

There are limitations in the understanding of how MATLAB interprets the loop structures and increments, which may affect the implementation of the numerical method. The discussion also highlights the need for clarity in distinguishing between the loop counter and the physical dimensions being calculated.

noelll
Messages
13
Reaction score
0
Hi there,

Homework Statement


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. Homework 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.

The Attempt at a Solution


i tried doing the simpson's rule. But i could only get a single number.
Code:
%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:
Physics news on Phys.org
noelll said:
Hi there,

Homework Statement


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. Homework 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.

The Attempt at a Solution


i tried doing the simpson's rule. But i could only get a single number.
Code:
%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
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.
 
SteamKing said:
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.

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:
%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
 

Attachments

  • lifeboat.png
    lifeboat.png
    2.2 KB · Views: 588
noelll said:
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:
%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
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.
 
SteamKing said:
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.

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!

Noel
 
noelll said:
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!

Noel
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.
 

Similar threads

Replies
31
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
10K
Replies
2
Views
6K
  • · Replies 11 ·
Replies
11
Views
3K
Replies
4
Views
21K
Replies
2
Views
2K
Replies
9
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K