Continuity & Bernoulli's Equation | Fluid Mechanics with Python | Skill-Lync Resources

50% OFF - Ends Soon!

Lesson 4 of 13 30 min

Continuity & Bernoulli's Equation

When you put your thumb over a garden hose, the water shoots out faster. When wind speeds up over an airplane wing, pressure drops and lift is generated. Both phenomena follow two of the most powerful tools in fluid mechanics: the continuity equation (conservation of mass) and Bernoulli's equation (conservation of energy).

In this lesson, we'll derive these relations, understand their assumptions, and use them to measure and predict flow.

Conservation of Mass: The Continuity Equation

Mass cannot be created or destroyed. For steady flow through a stream tube, the mass flow rate is constant:

Sponsored

3,000+ engineers placed at Mahindra, Bosch, TATA ELXSI

Including Continental, Capgemini, Ola Electric & 500+ more companies

See Where They Work

$$\dot{m} = \rho A V = \text{constant}$$

Between two cross-sections:

$$\rho_1 A_1 V_1 = \rho_2 A_2 V_2$$

Sponsored

Gaurav Jadhav is now a CAE Engineer

Practical projects and mock interviews made the difference

See His Journey

For an incompressible fluid ($\rho_1 = \rho_2$), this simplifies to a volumetric balance:

$$A_1 V_1 = A_2 V_2 = Q$$

Where $Q$ is the volumetric flow rate (m³/s). This is why a narrowing pipe speeds the flow up.

Sponsored

Get up to ₹60,000 off with Founder's Scholarship

Only 42 seats left for the April batch

Check Eligibility
import numpy as np

# Water flows through a pipe that narrows from 100 mm to 50 mm.
rho = 998.0
D1, D2 = 0.10, 0.05    # diameters (m)
V1 = 2.0               # inlet velocity (m/s)

A1 = np.pi * D1**2 / 4
A2 = np.pi * D2**2 / 4
V2 = V1 * A1 / A2      # continuity for incompressible flow

Q = A1 * V1
print(f"Flow rate Q = {Q*1000:.2f} L/s")
print(f"Inlet velocity  V1 = {V1:.2f} m/s")
print(f"Outlet velocity V2 = {V2:.2f} m/s")
Output:
Flow rate Q = 15.71 L/s
Inlet velocity  V1 = 2.00 m/s
Outlet velocity V2 = 8.00 m/s

Halving the diameter quarters the area, so velocity quadruples — from 2 to 8 m/s.

🎯 3,000+ Engineers Placed
Sponsored
Harshal Sukenkar

Harshal

Fiat Chrysler

Abhishek

Abhishek

TATA ELXSI

Srinithin

Srinithin

Xitadel

Ranjith

Ranjith

Core Automotive

Gaurav Jadhav

Gaurav

Automotive Company

Bino K Biju

Bino

Design Firm

Aseem Shrivastava

Aseem

EV Company

Puneet

Puneet

Automotive Company

Vishal Kumar

Vishal

EV Startup

Bernoulli's Equation

Along a streamline, for steady, incompressible, inviscid flow, the sum of pressure, kinetic, and potential energy per unit volume is constant:

$$p + \tfrac{1}{2}\rho V^2 + \rho g z = \text{constant}$$

Dividing by $\rho g$ gives the head form, where each term has units of length:

$$\frac{p}{\rho g} + \frac{V^2}{2g} + z = H$$

  • $p/\rho g$ = pressure head
  • $V^2/2g$ = velocity head
  • $z$ = elevation head
  • $H$ = total head (constant)

Assumptions of Bernoulli's Equation

Bernoulli's equation is valid only when all of these hold:

AssumptionMeaning
Steady flowProperties do not change with time
Incompressible$\rho$ constant (Mach number < 0.3 for gases)
InviscidNo friction/viscous losses
Along a streamlineBoth points on the same streamline
No shaft workNo pump or turbine between the points

When friction matters, we add a head-loss term $h_L$; when a pump or turbine is present, we add $h_p$ or $h_t$ — that becomes the energy equation.

Energy and Hydraulic Grade Lines

Two useful graphical concepts:

  • Energy Grade Line (EGL): plots total head $H = p/\rho g + V^2/2g + z$. It slopes downward in the flow direction due to losses.
  • Hydraulic Grade Line (HGL): plots $p/\rho g + z$ (excludes velocity head). The HGL lies below the EGL by exactly the velocity head $V^2/2g$.

Where the HGL drops below the pipe, pressure is sub-atmospheric — a cavitation warning sign.

Stagnation Pressure and the Pitot Tube

At a stagnation point, the fluid is brought to rest ($V=0$) and all velocity head converts to pressure. The stagnation pressure is:

$$p_0 = p + \tfrac{1}{2}\rho V^2$$

A Pitot-static tube measures both stagnation pressure $p_0$ and static pressure $p$; their difference gives velocity:

$$V = \sqrt{\frac{2(p_0 - p)}{\rho}}$$

Pitot Tube Velocity

import numpy as np

# A Pitot-static tube in an air duct reads a pressure difference
# of 250 Pa. Find the air velocity.
rho_air = 1.204     # kg/m^3 at 20 C
dp = 250.0          # p0 - p (Pa)

V = np.sqrt(2 * dp / rho_air)
print(f"Air velocity: {V:.2f} m/s")

# Same instrument in water with dp = 5 kPa
rho_water = 998.0
dp_w = 5000.0
V_w = np.sqrt(2 * dp_w / rho_water)
print(f"Water velocity: {V_w:.2f} m/s")
Output:
Air velocity: 20.38 m/s
Water velocity: 3.17 m/s

Venturi and Orifice Flow Measurement

A Venturi meter has a converging throat that accelerates the flow and lowers its pressure. Combining continuity and Bernoulli, the ideal flow rate is:

$$Q = C_d A_2 \sqrt{\frac{2(p_1 - p_2)}{\rho\,(1 - (A_2/A_1)^2)}}$$

Where $C_d$ is the discharge coefficient (≈ 0.98 for a Venturi, ≈ 0.61 for a sharp orifice) accounting for real losses.

Venturi Flow-Rate Solver

import numpy as np

def venturi_flow(D1, D2, dp, rho, Cd=0.98):
    """Flow rate through a Venturi meter."""
    A1 = np.pi * D1**2 / 4
    A2 = np.pi * D2**2 / 4
    beta = A2 / A1
    Q_ideal = A2 * np.sqrt(2 * dp / (rho * (1 - beta**2)))
    return Cd * Q_ideal, A1, A2

rho = 998.0
D1, D2 = 0.10, 0.06     # pipe and throat diameters (m)
dp = 18000.0            # measured pressure drop (Pa)

Q, A1, A2 = venturi_flow(D1, D2, dp, rho)
V_throat = Q / A2 / 0.98  # ideal throat velocity (back out for display)
print(f"Throat/pipe area ratio: {A2/A1:.3f}")
print(f"Flow rate Q = {Q*1000:.2f} L/s")
print(f"Pipe velocity = {Q/A1:.2f} m/s")
Output:
Throat/pipe area ratio: 0.360
Flow rate Q = 13.07 L/s
Pipe velocity = 1.66 m/s

The fluids library offers differential_pressure_meter_solver for production-grade Venturi and orifice calculations including Reynolds-dependent discharge coefficients.

Torricelli's Theorem and Tank Draining

For a tank draining through a small hole at depth $h$ below the surface, Bernoulli gives Torricelli's theorem:

$$V = \sqrt{2gh}$$

The same speed a body reaches falling freely from height $h$. As the tank empties, $h$ decreases, so the outflow slows. The water height follows:

$$\frac{dh}{dt} = -\frac{C_d A_{hole}}{A_{tank}}\sqrt{2gh}$$

Tank Draining with a Plot

import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp

g = 9.81
Cd = 0.62                       # orifice discharge coefficient
D_tank = 1.0                    # tank diameter (m)
D_hole = 0.02                   # hole diameter (m)
A_tank = np.pi * D_tank**2 / 4
A_hole = np.pi * D_hole**2 / 4
h0 = 2.0                        # initial water height (m)

def dhdt(t, h):
    h = max(h[0], 0.0)
    return [-Cd * A_hole / A_tank * np.sqrt(2 * g * h)]

# Integrate until the tank empties
sol = solve_ivp(dhdt, [0, 4000], [h0], max_step=1.0, dense_output=True)
t = np.linspace(0, sol.t[-1], 300)
h = sol.sol(t)[0]
h = np.clip(h, 0, None)

# Analytical drain time: t = (A_tank/(Cd*A_hole)) * sqrt(2 h0 / g)
t_empty = (A_tank / (Cd * A_hole)) * np.sqrt(2 * h0 / g)
print(f"Initial Torricelli velocity: {np.sqrt(2*g*h0):.2f} m/s")
print(f"Analytical drain time: {t_empty:.1f} s ({t_empty/60:.1f} min)")

plt.figure(figsize=(8, 5))
plt.plot(t, h, 'b-', linewidth=2)
plt.xlabel('Time (s)')
plt.ylabel('Water height h (m)')
plt.title('Tank Draining (Torricelli)')
plt.grid(True, alpha=0.3)
plt.show()
Output:
Initial Torricelli velocity: 6.26 m/s
Analytical drain time: 1631.0 s (27.2 min)

The height curve falls steeply at first (high $h$, fast outflow) and flattens as the tank nearly empties — a parabolic-in-time decay characteristic of $\sqrt{h}$ outflow.

Common Pitfalls

  • Applying Bernoulli across a pump, turbine, or major loss. Use the full energy equation with $h_p$, $h_t$, or $h_L$ instead.
  • Ignoring compressibility for fast gas flow. Above Mach 0.3, density changes and incompressible Bernoulli fails.
  • Forgetting the discharge coefficient. Real Venturi/orifice flow is less than ideal; multiply by $C_d$.
  • Mixing pressure and head units. Keep all terms in the same form (all pressure, or all head) within an equation.
  • Using gauge vs absolute inconsistently. As long as both points use the same reference, gauge pressure is fine in Bernoulli.

Key Takeaways

  • Continuity: $\rho_1 A_1 V_1 = \rho_2 A_2 V_2$; for incompressible flow $A_1V_1 = A_2V_2 = Q$.
  • Bernoulli: $p + \tfrac{1}{2}\rho V^2 + \rho g z = $ constant, valid only for steady, incompressible, inviscid, work-free flow along a streamline.
  • The EGL plots total head and the HGL plots it minus velocity head; losses tilt them downward.
  • Pitot tubes ($V=\sqrt{2\Delta p/\rho}$) and Venturi meters turn pressure differences into velocity and flow rate.
  • Torricelli ($V=\sqrt{2gh}$) governs tank draining, integrable in Python for the full height-vs-time history.

You've now built the core toolkit of classical fluid mechanics — mass and energy conservation — ready for momentum analysis, pipe flow, and beyond.

3,000+ Engineers Placed in Top Companies
Career Growth

3,000+ Engineers Placed in Top Companies

Join the ranks of successful engineers at Bosch, Tata, L&T, and 500+ hiring partners.