Introduction to Fluid Mechanics
Every pipeline that carries water to your home, every wing that lifts an aircraft, every pump in a power plant — they all depend on engineers who understand how fluids move and exert forces. Fluid Mechanics is the branch of engineering that studies the behavior of liquids and gases, whether at rest or in motion.
In this course, you'll learn fluid mechanics fundamentals while building Python tools to solve real engineering problems.
What is a Fluid?
A fluid is any substance that deforms continuously when subjected to a shear (tangential) stress, no matter how small that stress is. This is the key distinction from a solid.
Sponsored
Harshal got placed at Fiat Chrysler as Design Engineer
Watch his video testimonial on how the program helped him
Fluid vs Solid
| Behavior | Solid | Fluid |
|---|
| Response to shear stress | Deforms by a fixed amount, then stops | Deforms continuously (flows) |
| Resists | Both normal and shear stress at rest | Only normal stress at rest |
| Recovery | Returns to original shape (elastic) | Does not recover shape |
| Examples | Steel, concrete, rubber | Water, air, oil |
A solid resists shear with a finite deformation governed by its shear modulus. A fluid simply keeps moving as long as the shear is applied — that continuous motion is what we call flow.
The Continuum Hypothesis
Fluids are made of discrete molecules separated by empty space. Tracking each molecule would be impossible. Instead, fluid mechanics treats the fluid as a continuum — a continuous medium where properties like density and velocity are defined at every point.
This assumption holds when the characteristic length of the flow is much larger than the molecular mean free path. The relevant parameter is the Knudsen number:
Sponsored
Abhishek landed his dream job at TATA ELXSI
From learning simulations to working at an industry leader
$$Kn = \frac{\lambda}{L}$$
Where $\lambda$ is the mean free path and $L$ is the characteristic length. The continuum hypothesis is valid when $Kn \ll 1$ (roughly $Kn < 0.01$). For air at sea level, $\lambda \approx 68$ nm, so almost all everyday engineering flows are continuum.
Key Fluid Properties
Density
Density is mass per unit volume:
$$\rho = \frac{m}{V}$$
Sponsored
Gaurav Jadhav is now a CAE Engineer
Practical projects and mock interviews made the difference
Where $\rho$ is density (kg/m³), $m$ is mass (kg), and $V$ is volume (m³).
| Fluid (at 20°C, 1 atm) | Density $\rho$ (kg/m³) |
|---|
| Water | 998 |
| Seawater | 1025 |
| Mercury | 13550 |
| Air | 1.204 |
| Engine oil (SAE 30) | 891 |
Specific Weight
Specific weight is weight per unit volume:
$$\gamma = \rho g$$
Where $g = 9.81$ m/s². For water, $\gamma \approx 9.79$ kN/m³.
Specific Gravity
Specific gravity (relative density) compares a fluid's density to that of water at 4°C ($\rho_{water} = 1000$ kg/m³):
$$SG = \frac{\rho}{\rho_{water}}$$
It is dimensionless. Mercury has $SG = 13.55$; gasoline has $SG \approx 0.68$.
Pressure
Pressure is the normal force exerted by a fluid per unit area:
$$p = \frac{F}{A}$$
Pressure is measured in pascals (Pa = N/m²). In a fluid at rest, pressure acts equally in all directions at a point (Pascal's law) and increases with depth.
The No-Slip Condition
When a fluid flows past a solid surface, the fluid in direct contact with the wall has zero velocity relative to the wall. This is the no-slip condition, and it is the reason velocity profiles develop and viscous drag exists. The velocity rises from zero at the wall to the free-stream value across a thin region called the boundary layer.
Lagrangian vs Eulerian Descriptions
There are two ways to describe a flow field:
- Lagrangian: Follow individual fluid particles through space and time, like tracking a specific raft floating down a river. Position is a function of the particle's identity and time.
- Eulerian: Fix attention on specific points in space and observe the fluid passing through them, like watching the water speed at a fixed bridge piling. This is the more common approach in engineering and CFD.
Most of this course uses the Eulerian viewpoint, where we define fields such as $\vec{V}(x, y, z, t)$ and $p(x, y, z, t)$.
Setting Up Python for Fluid Mechanics
Throughout this course, we'll use Python to solve fluid mechanics problems. Let's set up our environment.
Required Libraries
# Core scientific computing
import numpy as np
import matplotlib.pyplot as plt
# Scientific routines: root finding, integration, optimization
from scipy import optimize, integrate
# Optional: fluid property libraries
# pip install CoolProp -> accurate thermophysical properties
# pip install fluids -> friction factors, fittings, flow meters
CoolProp provides accurate density, viscosity, and vapor pressure for hundreds of fluids, while fluids (by Caleb Bell) offers ready-made correlations for pipe flow, friction factors, and flow measurement. We'll mention them where relevant.
Your First Fluid Mechanics Calculation
Let's calculate the pressure at the bottom of a water tank. Pressure increases linearly with depth in a static fluid:
$$p = p_0 + \rho g h$$
import numpy as np
# Problem: Find the gauge pressure at the bottom of a 12 m deep
# water reservoir.
rho = 998.0 # water density at 20 C (kg/m^3)
g = 9.81 # gravity (m/s^2)
h = 12.0 # depth (m)
# Gauge pressure (relative to atmosphere)
p_gauge = rho * g * h
print(f"Gauge pressure at 12 m: {p_gauge:.0f} Pa")
print(f"Gauge pressure at 12 m: {p_gauge/1000:.2f} kPa")
# Absolute pressure (add atmospheric)
p_atm = 101325.0 # Pa
p_abs = p_atm + p_gauge
print(f"Absolute pressure at 12 m: {p_abs/1000:.2f} kPa")
# How many atmospheres is that?
print(f"That's {p_abs/p_atm:.2f} atm")
Output:
Gauge pressure at 12 m: 117484 Pa
Gauge pressure at 12 m: 117.48 kPa
Absolute pressure at 12 m: 218.81 kPa
That's 2.16 atm
Visualizing Hydrostatic Pressure vs Depth
import numpy as np
import matplotlib.pyplot as plt
rho = 998.0 # kg/m^3
g = 9.81 # m/s^2
p_atm = 101325.0 # Pa
# Depths from surface to 50 m
depth = np.linspace(0, 50, 200)
# Gauge and absolute pressure
p_gauge = rho * g * depth
p_abs = p_atm + p_gauge
plt.figure(figsize=(8, 6))
plt.plot(p_gauge / 1000, depth, 'b-', linewidth=2, label='Gauge pressure')
plt.plot(p_abs / 1000, depth, 'r--', linewidth=2, label='Absolute pressure')
plt.gca().invert_yaxis() # depth increases downward
plt.xlabel('Pressure (kPa)', fontsize=12)
plt.ylabel('Depth below surface (m)', fontsize=12)
plt.title('Hydrostatic Pressure vs Depth (Water)', fontsize=14)
plt.legend()
plt.grid(True, alpha=0.3)
plt.show()
# Print a few sample values
for d in [0, 10, 20, 50]:
print(f"Depth {d:2d} m -> gauge {rho*g*d/1000:7.2f} kPa")
Output:
Depth 0 m -> gauge 0.00 kPa
Depth 10 m -> gauge 97.90 kPa
Depth 20 m -> gauge 195.81 kPa
Depth 50 m -> gauge 489.52 kPa
Notice that pressure increases by roughly 9.8 kPa for every meter of water depth — a handy rule of thumb.
Course Roadmap
Here's what you'll learn in this course:
| Lesson | Topic | Key Python Skills |
|---|
| 1 | Introduction to Fluid Mechanics | Environment setup, hydrostatic pressure |
| 2 | Fluid Properties & Viscosity | Velocity profiles, property correlations |
| 3 | Hydrostatics & Buoyancy | Manometer solvers, force integration |
| 4 | Continuity & Bernoulli's Equation | Flow-rate solvers, Pitot/Venturi |
| 5+ | Momentum, Pipe Flow, Dimensional Analysis | CFD-style numerical methods |
Common Pitfalls
- Confusing gauge and absolute pressure. Gauge pressure is measured relative to atmosphere; absolute pressure adds $p_{atm} \approx 101.3$ kPa. Always state which one you mean.
- Mixing up specific weight and density. $\gamma = \rho g$ has units of N/m³, while $\rho$ is in kg/m³.
- Forgetting unit consistency. Keep everything in SI (m, kg, s, Pa) inside your code, then convert only for display.
- Assuming the continuum holds everywhere. In rarefied gases or microflows, $Kn$ may be large and the continuum hypothesis breaks down.
Key Takeaways
- A fluid deforms continuously under any shear stress, unlike a solid.
- The continuum hypothesis lets us treat fluids as smooth fields of $\rho$, $p$, and $\vec{V}$.
- Core properties: density $\rho$, specific weight $\gamma = \rho g$, specific gravity $SG = \rho/\rho_{water}$.
- The no-slip condition ($V=0$ at a wall) is the origin of boundary layers and viscous drag.
- Python + NumPy + Matplotlib + SciPy (plus CoolProp/fluids) form a powerful fluid mechanics toolkit.
In the next lesson, we'll dive into fluid properties and viscosity — the property that governs how fluids resist shear.