liveBook · Manning

Computational fluid dynamics

As explained in Digital Twins in Action

Computational fluid dynamics is the numerical modeling of fluid motion, transport, and related physical quantities by solving governing equations on a discretized spatial domain.

Computational fluid dynamics (CFD) models moving fluids by numerically solving governing equations on a spatial mesh. It can estimate velocity, pressure, and temperature where observing flow directly would be difficult or expensive. Like finite element analysis, it breaks a physical domain into smaller pieces; its focus here is fluid motion and transport. section 9.6 section 9.8

The Navier–Stokes equations describe how fluid properties evolve over space and time. Real-world geometries rarely permit analytic solutions, so a CFD solver discretizes the domain and iterates toward a converged flow field. In a digital twin, sensor readings can change the simulated conditions: a building model, for instance, can use temperature, humidity, and occupancy data to test ventilation strategies without disrupting the building. section 9.6

Cold air in a warm room

A lightweight Python example represents a 5 × 3 meter room with four two-dimensional arrays: horizontal velocity u, vertical velocity v, pressure p, and temperature T. The arrays begin with still air, zero pressure, and an initial room temperature. Solid walls and an air-conditioner outlet supply boundary conditions. Each time step moves momentum through advection and diffusion, solves a pressure Poisson equation to enforce mass conservation, corrects velocity, and transports temperature. Changing the outlet conditions lets the model explore how cooled air disperses. section 9.6.1

DT = 0.005  # time step (seconds)

@jax.jit  #1
def simulation_step(state):
    u, v, p, T = state
    u, v, T = apply_boundary_conditions(u, v, T)

    u_star = u + DT * (-advection_term(u, u, v) +  #2
      NU * laplacian(u, DX, DY))
    v_star = v + DT * (-advection_term(v, u, v) +
      NU * laplacian(v, DX, DY))

    p = pressure_poisson(p, compute_divergence(u_star, v_star))  #3
    dpdx = (jnp.roll(p, -1, axis=1) - jnp.roll(p, 1, axis=1)) / (2 * DX)
    dpdy = (jnp.roll(p, -1, axis=0) - jnp.roll(p, 1, axis=0)) / (2 * DY)

    u_new = u_star - DT * dpdx  #4
    v_new = v_star - DT * dpdy

    T_new = T + DT * (-advection_term(T, u, v) +
      ALPHA * laplacian(T, DX, DY)) #5 #5

    u_new, v_new, T_new = apply_boundary_conditions(u_new, v_new, T_new)

    return (u_new, v_new, p, T_new)

The JAX simulation step shows how boundary conditions, momentum updates, pressure correction, and heat transport fit into one repeated update. section 9.6.1

The room model is deliberately simplified and designed for interactive visualization; it is not a substitute for every industrial simulation. At another scale, Ansys Fluent has been used with Formula 1 telemetry to simulate aerodynamic changes and inform car setup before a race. section 9.6.1 section 9.6.2

How Digital Twins in Action covers it

How deep it goes
Works through a simplified two-dimensional solver's arrays, boundaries, and time-step sequence, while leaving some wall conditions out of the listing.
Examples
Models cold air from a wall-mounted air conditioner dispersing through a warm room and cites Formula 1 aerodynamic simulation.
What it assumes
Assumes enough Python familiarity to follow array-based code, while introducing the fluid state, mesh, and solver steps.
What you can do after
Build it from scratch as a simplified Python/JAX room-airflow simulation for exploring air-conditioner placement and cooling patterns.
How it connects
Connects Navier–Stokes equations, meshes, pressure correction, heat transport, finite element analysis, and sensor-driven digital twins.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Digital Twins in Action. The section links point to the parts of the book it draws on.