Bernoulli Equation Simulator

JJ Ben-Joseph headshot JJ Ben-Joseph

Time step is clamped between 0.001 s and 0.1 s for smooth animation.

Enter values and press Play.
Simulation summary will appear here.

Bernoulli Head Balancer

Test your feel for Bernoulli’s equation by trimming a nozzle to keep the downstream pressure inside a safe head band while gusts, pump boosts, and elevation shifts perturb the flow seeded by your inputs.

Current P₂
Target P₂
Stability band
±— Pa
Score
0

Balance head, dodge surges

Click to play · objective: Keep total head level

Drag/tap nozzle or use ← → keys

Set the calculator inputs, then press play to start balancing head.

1. Why pair Bernoulli's equation with animation?

Bernoulli's principle links pressure, velocity, and elevation along a streamline, asserting that their energy contributions trade off to keep the total constant. Textbook problems ask for the unknown pressure at a nozzle exit or the speed at a pipe constriction, but without a picture the flow seems static. In reality a fluid parcel accelerates or slows, gaining kinetic energy while surrendering pressure or climbing against gravity. The simulator above turns the algebra into a moving story: a circle representing a parcel slides through a pipe that widens or narrows according to the specified velocities. Three striped bars track how much of the parcel's mechanical energy resides in pressure, kinetic, or potential form. As the parcel approaches a throat, the kinetic bar swells while the pressure bar shrinks, and if the pipe rises, the green potential bar grows. This visualization helps students and engineers connect the terms in Bernoulli's equation to tangible changes in flow. Because everything runs locally in your browser, you can experiment with extreme cases, pause the motion, or export a CSV without installing software.

2. Variables, units, and assumptions

The calculator requires fluid density ρ , initial pressure P 1 , initial velocity v 1 , initial elevation h 1 , final velocity v 2 , and final elevation h 2 . All inputs must be finite SI values; the script rejects negative densities or nonnumeric entries. Gravity is taken as g = 9.81 m/s². The flow is assumed steady, inviscid, incompressible, and along a single streamline with no pump or turbine adding or removing energy. A fixed time step Δt controls the animation; it is clamped between 0.001 and 0.1 seconds for visual clarity. To depict the pipe geometry, the code infers an upstream cross-sectional area of one square unit; continuity then sets the downstream area by A 2 = v 1 v 2 . Heights change linearly along the pipe. These simplifications keep the visualization intuitive while preserving Bernoulli's core energy balance.

3. Governing equations

Bernoulli's equation for points 1 and 2 reads

P 1 + 1 2 ρ v 1 2 + ρ g h 1 = P 2 + 1 2 ρ v 2 2 + ρ g h 2 .

Solving for the unknown pressure gives

P 2 = P 1 + 1 2 ρ( v 1 2 - v 2 2 ) + ρ g ( h 1 - h 2 ) .

The total mechanical energy per unit volume E = P + 1 2 ρ v 2 + ρ g h remains constant along the path. The simulator computes E at the inlet, then updates each term as the parcel advances, verifying that the sum changes only within numerical error. Deviations appear in the caption as an energy drift percentage. Because the equations are algebraic, the animation does not solve differential equations; instead it interpolates the velocity and height between the endpoints and applies the analytic formulas at each frame.

4. Numerical update scheme

The particle starts at the left end of the canvas with velocity v 1 . Each animation frame advances its position using an explicit Euler step x_{n+1} = x_n + v(x_n) Δt , where v(x) interpolates linearly between v 1 and v 2 . Height follows a similar interpolation. At each new position the code computes pressure from the rearranged Bernoulli equation and updates the energy bars: orange for pressure energy P , blue for kinetic energy 1 2 ρ v^2, and green for potential energy ρ g h. The bars' widths represent fractions of the inlet total. Because the analytic expression guarantees constant E , the integration is numerically stable, but extremely large Δt values can cause the particle to skip past the outlet; therefore the controls bound the step size and allow pausing or resetting if the motion becomes erratic.

5. Worked example

A fire hose delivers water (ρ = 1000 kg/m³) from street level to a nozzle 5 m above the pump. The hose enters the pump at 0.1 MPa with speed 2 m/s and exits the nozzle at 25 m/s. Plugging these values into Bernoulli's equation predicts the nozzle pressure:

P 2 = 1.0×10^5 + 1 2 (1000)(2^2-25^2) + (1000)(9.81)(0-5)

which evaluates to roughly 33 kPa, indicating a significant pressure drop as kinetic and potential energy increase. Entering these numbers and pressing Play shows the parcel accelerating through a contracting pipe while the orange pressure bar shrinks and the blue kinetic bar dominates. The green bar grows slightly due to the 5 m elevation gain. The caption reports negligible energy drift, confirming numerical consistency. Press Pause at mid-travel to read intermediate values, or download the CSV to analyze how pressure varies with position.

6. Comparison table

The table contrasts the hose scenario with two variations: a larger outlet velocity and a downhill nozzle. Pressures are computed using the analytic expression above.

Case v₂ (m/s) h₂ (m) P₂ (kPa)
Baseline 25 5 33
Faster stream 30 5 -19
Downhill 25 -2 101

7. Reading the animation

The canvas renders a horizontal pipe whose diameter tapers to reflect the velocity change dictated by continuity. The parcel's speed is indicated by its horizontal motion, while the pipe's centerline follows the specified elevations. The energy bars beneath the canvas portray the instantaneous partition: orange for pressure, blue for kinetic, green for potential. Their striped patterns ensure legibility without relying on color alone. The figcaption and hidden text summary narrate the current position, pressure, and energy drift for screen-reader users.

8. Limitations

The model assumes inviscid, steady, one-dimensional flow with no pumps, turbines, or losses. Real pipes exhibit friction, shocks, and secondary flows at bends. Pressures below vapor pressure can trigger cavitation, an effect absent here. Rapid transients, compressibility, and turbulence also violate the assumptions. The animation's interpolation ignores entrance effects and the true shape of streamlines through complex geometries. Nevertheless, for modest velocities in smooth pipes the simulator captures the essence of Bernoulli's balance.

9. Extensions

Future upgrades could add head-loss terms, couple multiple pipe segments, or integrate a Reynolds-number check with the Reynolds Number Calculator. Combining this tool with the Hagen–Poiseuille Flow Simulator or the Venturi Effect Calculator would allow exploration of energy losses and flow measurements in more complex systems.

10. References

Embed this calculator

Copy and paste the HTML below to add the Bernoulli Principle Streamline Simulator to your website.