Hagen–Poiseuille Laminar Flow Simulator

JJ Ben-Joseph headshot JJ Ben-Joseph

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

1. Real-world motivation

Whether it is blood coursing through an artery, crude oil creeping along a pipeline, or a reagent being metered in a microfluidic chip, engineers constantly deal with fluids squeezed through narrow passages. The venerable Hagen–Poiseuille equation gives the volumetric flow rate Q for such laminar motion in a circular tube, but a static number masks the richly structured velocity field. In the real world, fluid particles near the wall barely move while those at the centerline surge ahead, forming a smooth parabola. Pressure energy is irreversibly converted into heat by viscous friction. The upgraded calculator above preserves the core task of finding Q while exposing the dynamics through an HTML5 canvas. A swarm of tracer particles marches down the pipe with speeds proportional to their radial positions. An energy bar pair displays the pressure power driving the flow and the equal dissipation rate. By adjusting pressure drop, tube radius, length, viscosity, or the integration time step, visitors can immediately see how the profile broadens, compresses, or stalls. The simulation remains entirely client-side, lightweight enough for mobile browsers yet detailed enough to teach the intuition behind laminar resistance.

2. Variables and assumptions

The model follows a Newtonian fluid with dynamic viscosity μ flowing steadily through a rigid circular tube of radius r and length L. A pressure difference ΔP is maintained between the ends. Density cancels out in the derivation, so compressibility is ignored and the fluid is taken as incompressible. The code assumes that entrance effects have died out, so the velocity profile is fully developed and invariant along the pipe. Velocity varies only with radial coordinate y from the centerline, obeying no-slip at the wall and symmetry about the axis. External body forces like gravity are neglected. Inputs are restricted to finite positive numbers in SI units. Negative pressures or radii trigger validation errors, and the time step Δt is clamped between 0.001 and 0.1 seconds to ensure visually smooth motion. Under these assumptions the volumetric flow rate depends solely on the geometrical and rheological parameters.

3. Governing equations

Balancing viscous shear against the pressure gradient in cylindrical coordinates yields a second-order differential equation for the axial velocity component v. Integrating twice and applying symmetry and no-slip boundary conditions produces the parabolic profile

v(y)=ΔP4μ Lr2-y2.

The volumetric flow rate results from integrating this velocity over the cross section:

Q=πΔP r^48μ L.

The average velocity follows as =Qπ r^2, while the maximum centerline speed equals v_{ₘ}=2. The instantaneous power dissipated by viscosity equals the product of pressure drop and flow rate P_d=ΔP Q. In the simulator, this power is represented by paired energy bars: an orange bar for pressure work entering the tube and a gray bar for the equal rate of thermal dissipation. Because the analytic solution is exact for the assumed geometry, any mismatch between simulated and calculated flow highlights numerical error.

4. Numerical scheme

The fluid velocity field is steady, so the simulation need only advect passive tracer particles. Each particle is assigned a fixed radial coordinate y and corresponding axial speed v(y) derived from the equation above. Positions update with an explicit Euler step x_{n+1}=x_n+v(y)Δt. Because velocities remain constant, the scheme is unconditionally stable; however, very large Δt values make particles jump noticeably and degrade the energy-drift check. To quantify drift, the code computes a numerical average velocity from the particle ensemble and compares it to the analytic . The relative difference appears in the caption as an error percentage. Canvas resizing triggers a redraw so that the velocity profile and particles scale smoothly on any device.

5. Worked example

Consider water at room temperature with μ=1.0×10^{-3} Pa·s flowing through a tube of radius r=5 mm and length L=1 m. A pressure drop of ΔP=10 kPa drives the motion. Plugging these numbers into the Poiseuille formula gives Q=3.1×10^{-5} m³/s, an average velocity of 0.40 m/s, and a centerline speed of 0.80 m/s. Entering the same values in the form and pressing Play launches the animation: particles near the wall crawl while those at midstream cruise twice as fast. The energy bars show about 0.31 W of pressure power being dissipated as heat. Downloading the CSV produces radial positions paired with velocities; integrating the numeric profile in a spreadsheet reproduces the analytic flow rate, validating the implementation.

6. Comparison table

The table contrasts the baseline parameters above with two variations: halving the radius and doubling the viscosity. The flow rate scales with r4 and inversely with viscosity, so changes are dramatic.

Scenarior (mm)μ (Pa·s)Q (m³/s)v̄ (m/s)
Baseline50.0013.1e-50.40
Half radius2.50.0011.9e-60.12
Double viscosity50.0021.6e-50.20

7. How to read the animation

The canvas depicts a side view of the pipe. Orange strokes on the left show the theoretical velocity curve, scaled so that zero velocity meets the wall and the maximum reaches 40 pixels. Blue particles drift from left to right, their spacing revealing local speed: dense clusters signal sluggish motion near the boundary while sparse, fast streaks mark the center. The caption reports elapsed time and the percentage drift between analytic and simulated flow. When the drift exceeds a few percent, reduce the time step or increase the particle count via a page refresh. The striped energy bars underneath the canvas indicate the pressure power (orange) and its dissipation (gray); their widths grow with the magnitude of ΔP Q yet remain visually distinct for viewers with color-vision deficiencies.

8. Limitations

The simulation presumes an idealized, fully developed laminar flow in a straight, rigid, circular tube. Real systems may include entrance lengths where the profile evolves, bends or fittings that induce secondary flows, and rough walls that enhance friction. Non-Newtonian fluids such as blood or polymer solutions deviate from the linear stress–strain relationship, altering the velocity distribution. Temperature changes can modify viscosity, and compressibility becomes important for gases at high pressure drops. The particle representation ignores diffusion and interaction, so it visualizes streamlines rather than true fluid elements. Numerical drift is monitored but not corrected; extremely large time steps can still yield misleading results.

9. Extensions

Future versions could incorporate axial diffusion or heat transfer, couple multiple tubes into networks, or handle noncircular cross sections by solving the corresponding Poisson equation. A Reynolds-number check could warn when the laminar assumption breaks down; users can experiment with this separately using the Reynolds Number Calculator. Combining this tool with the Bernoulli Equation Calculator or the Venturi Effect Calculator would enable more comprehensive fluid-system analyses.

10. References

Embed this calculator

Copy and paste the HTML below to add the Hagen–Poiseuille Laminar Flow Simulator to your website.