2D Navier-Stokes Back
CFD Simulator

2D Navier-Stokes Flow Simulator

Run vorticity-stream function CFD for lid-driven cavity flow. Adjust Reynolds number and grid size, then watch vorticity contours and streamlines develop.

Parameters

Parameter A50
Parameter B25

About

Run vorticity-stream function CFD for lid-driven cavity flow. Adjust Reynolds number and grid size, then watch vorticity contours and streamlines develop.

Result 1
Result 2

What is Lid-Driven Cavity Flow?

🧑‍🎓
What exactly is a "lid-driven cavity" in this simulator? It sounds like a box with a moving lid?
🎓
Exactly right! It's a classic benchmark problem in CFD. Imagine a square container filled with fluid, where the top wall (the "lid") slides sideways. That motion drags the fluid inside, creating complex swirling patterns. In this simulator, you control the speed of that lid, which directly changes the Reynolds number.
🧑‍🎓
Wait, really? So the Reynolds number isn't just a property of the fluid? How does changing the lid speed here affect the flow?
🎓
Great question! The Reynolds number ($Re$) here represents the ratio of inertial forces to viscous forces. A higher lid speed increases inertia, making the flow more chaotic. Try it: slide the "Reynolds Number" control up from 100 to 1000. You'll see the single, centered vortex break apart into smaller, off-center vortices in the corners.
🧑‍🎓
So the colored contours show vorticity, and the lines are streamlines. What's the practical difference, and why do engineers care about both?
🎓
In practice, they tell complementary stories. Vorticity (the colors) shows *where* the fluid is rotating locally—like pinpointing tiny whirlpools. Streamlines (the black lines) show the overall path a fluid particle would take. Engineers use both to identify recirculation zones, mixing efficiency, and stress points. For instance, adjusting the "Grid Size" parameter refines these visuals, showing more detail in the corner vortices.

Physical Model & Key Equations

The simulator solves the 2D, incompressible Navier-Stokes equations using the vorticity-stream function formulation. This approach eliminates pressure and enforces mass conservation automatically. The governing equation for vorticity ($\omega$) transport is:

$$\frac{\partial \omega}{\partial t}+ (\mathbf{u}\cdot \nabla)\omega = \frac{1}{Re}\nabla^2 \omega$$

Where $\omega = \nabla \times \mathbf{u}$ is the vorticity (a scalar in 2D, measuring local rotation), $\mathbf{u}$ is the velocity vector, $t$ is time, and $Re$ is the Reynolds number. The term $(\mathbf{u}\cdot \nabla)\omega$ represents convection, and $\frac{1}{Re}\nabla^2 \omega$ represents viscous diffusion.

The stream function ($\psi$) is solved from the vorticity to obtain the flow field. It is defined such that velocity components are its derivatives, guaranteeing an incompressible flow:

$$\nabla^2 \psi = -\omega$$

$$ u = \frac{\partial \psi}{\partial y}, \quad v = -\frac{\partial \psi}{\partial x}$$ Here, $\psi$ is the stream function. Lines of constant $\psi$ are the streamlines you see in the simulation. The velocity components $(u, v)$ are derived from it, ensuring the flow satisfies $\nabla \cdot \mathbf{u} = 0$ (incompressibility).

Real-World Applications

Chemical Mixing Tanks: The flow inside a stirred tank reactor is very similar to a lid-driven cavity. Engineers use this model to optimize paddle design and placement, ensuring chemicals mix thoroughly and efficiently without dead zones where fluid stagnates.

Microfluidic Devices: In lab-on-a-chip devices, fluids are often manipulated in tiny etched chambers. Understanding the vortex formation at different flow speeds (Reynolds numbers) is crucial for designing efficient cell sorters, mixers, and sensors.

Building Ventilation: Airflow in a room with a ceiling fan or a ventilation inlet creating a shear flow along the ceiling can be modeled as a cavity flow. This helps HVAC engineers design systems that minimize drafts and ensure proper air circulation.

Coating and Painting Processes: When applying a liquid coating (like paint or a protective film) over a surface contained within a raised border, the fluid dynamics resemble a driven cavity. Simulating this helps predict coating thickness uniformity and avoid defects.

Common Misconceptions and Points to Note

When you start using this simulator, there are a few points that are easy to misunderstand. First, you might tend to think "higher Reynolds numbers are closer to real flow," but that's not correct. Increasing Re does make the vortices more complex, but that's a state attempting to mimic "unsteady, near-turbulent behavior." However, this simulation is 2D and calculates under the assumption of "laminar flow." It's fundamentally different from real-world 3D turbulence, so directly using results from, say, Re=10000 for pump design is risky. Remember, it's a tool for observing the "trend" of a phenomenon.

Next, the grid size N setting. With N=32 or 64, calculations are fast, but especially at high Reynolds numbers, the vortex shapes can be coarse, and sometimes the solution can become unstable and oscillate. This happens because numerical diffusion becomes strong and cancels out the actual physical viscous effects. In practice, mesh (grid) resolution is the lifeline of simulation, and a "mesh dependency study"—the essential process of refining the mesh until results no longer depend on its coarseness—is mandatory. With this tool too, you can experience its importance by comparing, for example at Re=1000, how the bottom-left secondary vortex is represented when you change N to 64, 128, and 256.

Finally, understand the implication of the fact that "pressure is not calculated." The vorticity-stream function method is stable and excellent for computation, but it cannot be used directly for phenomena where you "need to know the pressure itself," such as wing lift/drag or pressure loss in pipes. For those cases, you need "primitive variable methods" (like the MAC or SIMPLE methods) that solve for velocity and pressure directly. This tool is your first step for understanding flow "patterns" and "structure."

Related Engineering Fields

The computation of this lid-driven cavity flow might seem simple, but it's actually directly connected to the foundational techniques of various engineering fields. The first to mention is cooling design for electronic devices. Knowledge of this "circulating flow within a closed domain" is extremely useful when optimizing airflow inside a casing or heat transfer around a heat sink. Think of the cavity lid motion corresponding to a fan, and the heated section corresponding to a heat-generating component.

Another is painting and coating processes. When extruding paint from a slit to coat a substrate, the paint's viscosity (effectively the Reynolds number) and the die shape determine whether a uniform film is formed. By observing in this simulator how high viscosity (low Re) leads to sluggish flow and low viscosity (high Re) leads to complex vortices, you can visualize the challenges in process control.

Furthermore, it's also applied in bioengineering. For instance, insights from this cavity flow are sometimes used as a first-approximation model for analyzing blood flow inside artificial hearts or circulation (stagnation) within an aneurysmal blood vessel. In particular, the secondary vortices that form in the corners become "poorly washed regions," providing clues to predict areas prone to thrombus formation.

For Further Learning

Once you're comfortable with this simulator, try delving into the "numerical solution algorithm" itself. What this tool does internally can be broadly divided into two computational stages. First, it advances the vorticity transport equation in time using an explicit method (e.g., Euler's method). Next, to solve the Poisson equation $\nabla^2 \psi = -\omega$ from the obtained vorticity, it uses an iterative method (like Gauss-Seidel or SOR). The reason calculations get heavier when you increase N is the increased number of these iterative computations.

Mathematically, vector calculus identities (e.g., $\nabla \times (\nabla \phi) = 0$) are key in deriving the vorticity equation by eliminating the pressure term from the Navier-Stokes equations. Also, solving the Poisson equation is mathematically identical in form to calculating electrostatic potential in electromagnetism or deflection in structural mechanics. Knowing this fact—that "the same equation appears across different fields"—will dramatically broaden your perspective on engineering.

As a recommended next topic, look into "Lid-Driven Cavity Flow". This is a more general model where not just the lid but also side walls can move, allowing observation of more complex vortex transitions. Alternatively, building on this 2D knowledge, moving to 3D cavity flow or the fundamental flow around an object, "flow around a circular cylinder," will introduce you to even richer phenomena like Kármán vortex streets. In any case, the intuition you develop here—physically feeling "how changing a parameter changes the physical phenomenon"—will undoubtedly become a valuable skill when you use more advanced CFD software.