An interactive two-phase stratified flow simulation demonstrating fluid mechanics principles in a horizontal pipe.
Stratify simulates the flow of two immiscible fluids (oil and water) in a horizontal pipe, demonstrating key fluid mechanics concepts including:
- Stratified flow patterns
- Viscous coupling between fluid layers
- No-slip boundary conditions
- Parabolic velocity profiles (Poiseuille flow)
- Interface dynamics
When two immiscible fluids with different densities flow through a horizontal pipe at low velocities, they naturally stratify due to gravity. The lighter fluid (oil) occupies the upper portion while the denser fluid (water) flows below.
┌────────────────────────────────────┐
│ ~~~~~~~~ Upper Fluid (Oil) ~~~~~~~│ ρ₁, μ₁
│════════════ Interface ═════════════│ y = 0
│ ≋≋≋≋≋≋ Lower Fluid (Water) ≋≋≋≋│ ρ₂, μ₂
└────────────────────────────────────┘
For a single-phase laminar flow in a pipe, the velocity profile follows a parabolic distribution known as Hagen-Poiseuille flow:
Where:
-
$u(r)$ = velocity at radial position$r$ -
$u_{max}$ = maximum velocity at pipe center -
$R$ = pipe radius -
$r$ = radial distance from center
The maximum velocity relates to the pressure gradient by:
Key insight: Velocity is inversely proportional to viscosity (
At solid boundaries (pipe walls), the fluid velocity must equal zero:
This fundamental principle means:
- Fluid particles in direct contact with the wall are stationary
- Velocity gradually increases toward the center
- Creates a boundary layer near the wall
At the interface between two fluids, two conditions must be satisfied:
Both fluids must have the same velocity at the interface:
The shear stress must be continuous across the interface:
From these conditions, the interface velocity can be derived:
Where:
-
$U_1$ ,$U_2$ = bulk/driving velocities of each fluid -
$\mu_1$ ,$\mu_2$ = dynamic viscosities
Physical interpretation: The more viscous fluid has a stronger influence on the interface velocity because it resists velocity gradients more effectively.
When one fluid flows and the other is stationary, momentum is transferred across the interface through viscous drag:
Fast-moving fluid ────────────→ Drags the interface
↕ Shear stress
Slow/stationary fluid ─────→ Gets dragged along
The drag force is proportional to:
- The velocity difference between fluids
- Inversely proportional to viscosity (more viscous = slower response)
This explains why:
- A stationary viscous fluid still moves slightly due to drag from the flowing fluid
- High viscosity fluids resist being dragged and respond more slowly
The complete velocity profile combines:
- Native Poiseuille flow - What each fluid would do independently
- Interface coupling - Blending toward the shared interface velocity
For each fluid layer:
Where
- At interface (
$y = 0$ ):$\beta = 0$ , velocity =$u_i$ - At wall (
$y = H$ ):$\beta = 1$ , velocity = 0 (no-slip)
| Parameter | Symbol | Unit | Range |
|---|---|---|---|
| Flow Rate (Upper) | m/s | -2 to +2 | |
| Flow Rate (Lower) | m/s | -2 to +2 | |
| Viscosity (Upper) | Pa·s | 0.5 to 5 | |
| Viscosity (Lower) | Pa·s | 0.5 to 5 |
- Counter-flow: Set opposite flow directions (e.g., upper = +1, lower = -1)
- Viscous dragging: Set one flow to 0, observe how the other drags it
- High viscosity contrast: See how interface velocity shifts toward the more viscous fluid
- Equal conditions: Both fluids at same rate and viscosity should show symmetric profiles
| Action | Control |
|---|---|
| Rotate view | Left-click + drag |
| Zoom | Scroll wheel |
| Adjust parameters | Control panel sliders |
- 8,000 particles per fluid phase
- Position updated using velocity integration
- Periodic boundary conditions at pipe ends
- Real-time velocity profile calculation
- Interface velocity computed from viscosity-weighted average
- Boundary layer enforcement near walls
- Three.js WebGL renderer
- Custom particle shaders for spherical appearance
- Depth-sorted rendering for proper visibility
- Node.js 18+
- pnpm (recommended) or npm
# Clone the repository
git clone https://github.com/ErenDexter/Stratify.git
cd Stratify
# Install dependencies
pnpm install
# Start development server
pnpm devpnpm build
pnpm preview- Bird, R.B., Stewart, W.E., & Lightfoot, E.N. (2002). Transport Phenomena. John Wiley & Sons.
- White, F.M. (2011). Fluid Mechanics. McGraw-Hill.
- Brennen, C.E. (2005). Fundamentals of Multiphase Flow. Cambridge University Press.
- Taitel, Y., & Dukler, A.E. (1976). A model for predicting flow regime transitions in horizontal and near horizontal gas-liquid flow. AIChE Journal, 22(1), 47-55.
MIT License - feel free to use, modify, and distribute.
Ranat Das Prangon
Built with ❤️ using SvelteKit, Three.js, and TailwindCSS