How to solve a Bernoulli Equation
Afficher commentaires plus anciens
I have to solve this equation:

It has to start from known initial state and simulating forward to predetermined end point displaying output of all flow stages.
I have translated it into matlab code:
heightA+Id*DeltaL+turbulence*v^2/2*gravityG == heightA+turbulence*v^2/2*gravityG+Ifsr*DeltaL
Now I wonder should I embed it into ode45 or fsolve function?
12 commentaires
Torsten
le 21 Jan 2022
No explicit time derivatives appear in the equation. So you can use "fsolve" (or a calculation with pencil and paper because only quadratic and linear terms are present).
KarolN
le 21 Jan 2022
Torsten
le 22 Jan 2022
What initial value problem ?
You have a known state (h0,v0). You can calculate the left-hand side of the Bernoulli equation. Then either height h0 or velocity v0 change. If h0 changes to h1, v0 changes to v1 according to Bernoulli equation. If v0 changes to v1, then h0 changes to h1 according to Bernoulli equation.
Maybe you could explain in more detail the application where you try to use Bernoulli.
William Rose
le 22 Jan 2022
@Torsten is correct, as usual. The equation is not a differential equaiton and it is not an initial value problem. Write the differential equation. Also, make it clear which quantitiess in your equation are constants and which quantities are functions of time, or position, or both.
The units of all terms on both sides appear to be length - assuming
and
and α are dimensionless.
Your Matlab equation does not match your written equation. You need to add () around the denominator terms:
heightA+Id*DeltaL+turbulence*v^2/(2*gravityG) == heightA+turbulence*v^2/(2*gravityG)+Ifsr*DeltaL
KarolN
le 23 Jan 2022
William Rose
le 23 Jan 2022
@KarolN, I am travelling but I will look at your modified question later today.
A for loop is a good idea.
Your original equation has h1 and h2. But the table has only "h". What happened to h1 and h2?
William Rose
le 23 Jan 2022
Your original equation has v1 and v2, but the table has only a single v.
Your original equation has h1 and h2, but the table has only a single h.
You said in your comment that
, but the Table you provided has different values for
on every row
You said in your comment that
, but the table has different values for
on every row.
You said "Ifsr*DeltaL symbolizes energy loss on entire length of the section". This cannot be correct, because the units do not work:
is dimensionless.
You said "DeltaL = DeltaE/Id-Ifsr". Do you mean DeltaL = DeltaE/(Id-Ifsr)? Note that I added parentheses. In any case, this equation cannot be correct, becuase the units do not match, since
and
are dimensionless.
Please explain these discrepancies.
William Rose
le 23 Jan 2022
Thank you for the picture of the dam with a pipe passing through it.
I think we are having difficulty due to translation issues. I am sorry that I only speak English.
I do not understand which values you already know, and which values you are trying to calculate, and with what equations.
You used the words Segment and Section. What is a Segment and whtat is a Section, in this problem?
Is the pipe circular cross section, with radius R and length L? Or length
?
You have introduced a new variable, n, in the equation for
. What is n? What are the units for n? The reason I am asking is that I want to understand the units for
. What do you think the units are for
?
You say energy
, but the units on the right hand side and length, not energy.
, but the units on the right hand side and length, not energy.I keep asking about units, because if the units do not match then the equaito cannot be correct.
In the diagram of the dam, I woudl say p1=0, v1=0 (pressure and velocity at the surface).
I also belive that P2=0 asince it appears to be at the outflow of the pipe. The pressure at the inlet is obviously important. Let us cal the inlet pressure P3. Then
, where
and ρ = density of the fluid.
How is R computed?
The table include values for P. Does that refer to P1 or P2 or some other pressure? How was P computed?
You have given equaitons for
and
, but your equation has
on the left hand side. What is the equation for
?
Do you have an equation for pressur drop per unit legth of pipe? If you do, what is that equation?
Réponse acceptée
Plus de réponses (1)
William Rose
le 23 Jan 2022
0 votes
The pipe under the dam appears to be horizontal. I assume that R is the pipe diameter and that
is its length and that it has a circular cross section. Then the pressure loss along the pipe is Pin-Pout.
.
since it is the pressure at the top of the surface above the dam.
since it is the pipe outflow. Therefore
. is the pressure drop, or head loss, from the beginning to the end of the pipe. The Darcy Weisbach equation says
where v=average velocity, ρ=density, and
=Darcy friction factor, which is dimensionless. The Darcy fricton factor complicated. If the flow is laminar, then
where μ=dynamic viscosity, and the other quantities are defined above.
If the flow is turbulent, then the Darcy friction factor
depends on the velocity and the pipe diameter and pipe roughness. Is this all part of your study? Are you supposed to know abotu this to solve the problem?
In your table, A does not equal
, therefore A is not the cross secitnal area of the pipe. IN your table,
, which seems strange to me, In your tble, P is nt proportional to h. Therefore P is not the pressure at the inlet to the pipe. This also surprises me.
4 commentaires
William Rose
le 24 Jan 2022
It is clear that I am not going to understand this problem. It is too complicated for me. Since this is flow in a canal, the equations I gave, which were for flow in a pipe are not applicable.
I would like to help you with the Matlab part, but I still do not know what problem you are trying to solve. I am sorry that I do not have more time to devot to this problem. Good luck with your work.
Sincererly, W. Rose
KarolN
le 24 Jan 2022
You can compute hn exactly:
satisfies the equation

In the equation above, Q, B, n, and
are all known constants. Therefore we can solve for
in Matlab or Excel. In my version of Excel, I have the Analysis Tool Pack installed. Therefore I have the "Solver" utility available in Excel. I create a cell in Excel that has the formula above. I tell the Solver utility to make the formula be equal to zero, by adjusting the value in the cell containing
. The initial value of
is 2.0. Excel immediately changes the value in the cell containing
to 1.9366. The image below shows my Excel workbook before I run the solver (left) and after I run the solver (right).

In Matlab, you can solve for
as follows:
B=2; Id=.01; n=.014; Q=20.96; hn0=2;
hn=fsolve(@(hn)Q*n/Id^.5-(B*hn)^(5/3)/(B+2*hn)^(2/3),hn0);
fprintf('hn=%.4f\n',hn);
The small difference in the value of
found by Excel and Matlab is because they have different default tolerances for finding a solution.
___________
The Excel sreadsheet which you posted has Q=20,96, but in another post, you said "Q = flow capacity (calculated earlier to be 7,860 m3/s)".
The Excel spreadsheet which you posted has Id=0,01, but in another post, you said "Id = slope gradient of pipe (calculated to be 0,029%)", and an even earlier post , you showed an image which included Id=0.0029.
When you solve for
, use the correct values for Q and Id.
Now that we have a way to compute
, does that help you solve your problem?
Catégories
En savoir plus sur Vector Fields dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!









