A Byte of PhysicsLogo

Introduction to CFD concepts

Computational fluid dynamics divides a domain into many locations and approximates how mass, momentum, and energy move between them. It is model-building plus numerical analysis, not only a colorful velocity map.

Think like a programmer

Design the data flow first: grid, boundary conditions, field arrays, update order, diagnostics, and render adapter. Keep the solver deterministic so a screenshot can be reproduced from its inputs.

Model checklist

Inputs
Mesh or grid, fluid properties, initial fields, boundary conditions, time step, and solver.
State
Velocity, pressure, and density arrays.
Rule
Apply conservation updates and enforce boundaries.
Output
Approximate field evolution.
Check
Grid refinement and time-step refinement preserve the intended large-scale result.

Pressure and buoyancy sampler

Change depth and displaced volume. Pressure increases with depth; buoyancy is the weight of displaced fluid.

Depth 2.0 m; pressure 120620 Pa; displaced volume 0.020 m³; buoyant force 196.2 N.

A field is an array, not a picture

Start with a square grid. A scalar such as density is one value per cell; velocity needs two arrays, one for horizontal speed and one for vertical speed. Treat each cell value as an average over a small control volume, not an exact point measurement. That decision gives every update a useful accounting question: what crossed the cell faces?

For a conserved scalar (q), the finite-volume idea is:

\[\frac{q^{n+1}_{i,j}-q^n_{i,j}}{\Delta t} = -\frac{F_{x,\mathrm{right}}-F_{x,\mathrm{left}}}{\Delta x} -\frac{F_{y,\mathrm{top}}-F_{y,\mathrm{bottom}}}{\Delta y} + S_{i,j}.\]

Read this like a state transition. The next cell value equals the old value, plus known sources, minus what leaves through faces. When the same face flux is added to one neighbor and subtracted from the other, the interior exchange cancels in the whole-grid ledger. Only sources and boundary flux can change total mass.

Make the numerical contract explicit

An implementation should name the stages rather than hide them in one giant update:

  1. Read immutable field arrays at time (n).
  2. Compute face fluxes from those arrays.
  3. Write candidate arrays for time (n+1).
  4. Apply wall, inlet, outlet, or periodic boundary rules.
  5. Run pressure or incompressibility correction if the model needs it.
  6. Record total mass, maximum speed, divergence error, and the time step used.

The small grid helper in this project demonstrates the same discipline with diffusion: a five-point neighborhood computes a Laplacian, then a fresh array receives the explicit update. It rejects a diffusion step larger than its stability limit instead of drawing plausible-looking nonsense. For unit cell spacing, that particular update requires:

\[\nu\Delta t \leq \frac14,\]

where (\nu) is the diffusion coefficient. Advection has a related CFL limit: in one update, material should not travel across more than roughly one cell. Record the chosen limit next to the solver configuration, because a stable run is evidence about the algorithm, not merely a slider restriction.

Boundaries are executable physics

A closed wall often means normal velocity is zero: fluid may slide along the wall but cannot pass through it. A periodic edge instead maps the rightmost neighbor to the leftmost cell. An inlet needs a stated velocity or flow rate; an outlet needs a rule that does not reflect arbitrary pressure waves back into the domain. These are different programs with different physical claims.

Before trusting a visualization, run small deterministic checks: a uniform periodic field should remain uniform, diffusion should reduce an isolated peak without creating extra total quantity under compatible boundaries, a closed box should not leak mass, and halving cell size and time step should preserve the conclusion you plan to teach. Save the input configuration and diagnostics beside an image so a reader can reproduce the frame.

Try this experiment

Prediction: Changing a boundary condition can alter the entire flow field.

List the minimum fields for an incompressible 2D solver and name one boundary test for a closed wall.

Where this model breaks

Real CFD needs careful discretization, turbulence modeling, validation data, and convergence studies. A coarse educational grid should not be presented as engineering prediction.

Summary

CFD is a structured field solver. Treat cell values as state, face fluxes as messages between cells, boundaries as executable physical assumptions, and conservation/stability diagnostics as tests. Make the grid, boundaries, update rules, and refinement checks visible to the reader.

Glossary

Self-check

  1. Which field arrays are commonly stored?
  2. Why are boundaries part of the model?
  3. What refinement checks should a solver pass?

Sources

Model contract

Treat the lesson as a small function before treating it as a fact to memorize. Give every value a unit, keep only the state needed for the next step, and make the output easy to inspect.

\[\text{observable output} = f(\text{inputs},\,\text{state})\]
Inputs
Quantities you set or measure, with units and useful bounds.
State
Values the program must retain to reproduce the next result.
Rule
The relationship or update that turns inputs and state into a result.
Check
A known limit, unit check, invariant, or measured result that can expose a bad model.

Implement the idea as a model

For Introduction to CFD Concepts, write down the quantities you can control, the values your program must retain, and the result a reader could inspect. In Fluids, the useful program is not the drawing: it is the smallest explicit model that makes a prediction you can test.

Guided experiment

Prediction: changing one declared input while holding the others fixed should change only the outputs that the model connects to that input. Choose one input, predict the direction of change, then check a limiting case such as zero, a symmetric arrangement, or a familiar low-speed or small-change approximation.

Where this model breaks

This lesson is a teaching model, not a complete simulator. Before using it outside the stated question, check which interactions, scales, uncertainties, boundary conditions, and measurement limits it leaves out.

Summary

Treat Introduction to CFD Concepts as a contract: named inputs and units enter a rule, the rule produces an observable result, and a known limit or invariant checks whether the implementation deserves trust.

Glossary

  • Input: a measured value or chosen parameter supplied to a model.
  • State: the smallest set of values needed to continue or reproduce a model.
  • Validation: comparing an output with a known result, limit, invariant, or measurement.

Self-check

  1. Which values are inputs, and which values must remain state?
  2. What observable result would tell you the model is behaving as expected?
  3. Which assumption would you test first before applying the model to a real system?

Model review: turn Introduction to CFD Concepts into a test

Plan a deterministic field solver around grids, boundary conditions, conservation updates, and convergence checks.

  1. Name the inputs and units that the fluids model needs.
  2. Separate the state you must keep from values you can calculate when needed.
  3. Write one rule that maps the current state and inputs to an observable result.
  4. Choose a limiting case, unit check, invariant, or known result before trusting an output.
  5. State one assumption you would change before using this simplified model for a real decision.

Share to: