MATLAB Answers

How to solve for dh in draining of a cylinder??

46 views (last 30 days)
Brian Peoples
Brian Peoples on 18 Feb 2019
Commented: Brian Peoples on 18 Feb 2019
So I was able to perform the while loop, but I am struggling on making a vector dh to watch the change in height after each time step. I do not want it to be directly related to the height, but more of a sanity check to make sure the loop is changing the height correctly. so not
dh = h(dt) - h(dt-1)
I know flow rate is given as:
Q = AV
My instructions say:
Use the flow rate to calculate how much water drained form the tank in the currenttime step and then use the area of the tank (not the exit hole) to calculate how much the height of the water change. You can call this vector dh.....
function [Q,h,t,V] = hw4_func_BDP(Initial_Height,Outer_D,Inner_D)
%I got V by starting off with the Bernoulli's equation, crossing off
%pressure for the top and the bottom of the cylindrical container because the open drain causes it to equal
%zero, crossed out out the velocity on the top due to it being ostensibly
%zero (Because D>>d Vtop << Vbottom), crossed out density because it is the
%same all throughout the equation, then we are left with gh1 = 1/2 V2^2,
%therefore V2 is equal to sqrt(2gh).
p = 1000; %(kg/m^3) pressure of water
g = 9.81; %(m/s^2) acceleration due to gravity
k = ((Inner_D^2)/(Outer_D^2))*sqrt(2*g); %constant with diameters of large hole vs exit hole
%Outputs for time, height, velocity,
%and flow rate in while loop
%Output Variables
t = [0];
V = [0];
Q = [0];
if Initial_Height == 5
h = 5;
h = 2;
dt = 1; %time step
while h > 0
t(1+dt) = t(dt) + 1; %time goes up by 1 each time
h(1+dt) = sqrt(Initial_Height-.5*k.*t(1+dt)).^2; %Fluid Height
V(1+dt) = sqrt(2*g.*h(1+dt)); %Velocity
Q(1+dt) = pi*(Inner_D/2)^2 .*V(1+dt); %Flow Rate
%dh for sanity check
dt = dt+1;
%Last peramitors errasing when h is less than 0 and making the last time
%step equal to zero
h(dt) = 0
V(dt) = 0
Q(dt) = 0

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!