Published November 1, 2026 | Version 1.0

CUDA Python code accompanying 'Thermal convection and jets produced by human exhalation dominate the indoor spreading of emitted $\mathrm{CO_2}$ and aerosols'

  • 1. ROR icon Freie Universität Berlin

Description

GPU-based finite-difference simulation (CUDA Python / Numba) of the spreading of exhaled $\mathrm{CO_2}$ in a closed, non-ventilated room: compressible Navier-Stokes equations coupled to heat transport, $\mathrm{CO_2}$ transport and periodic nasal breathing of a seated person. The code is written in CUDA Python and optimized for an NVIDIA RTX 5070 Ti; a full run takes about 12 hours. It accompanies the paper "Thermal convection and jets produced by human exhalation dominate the indoor spreading of emitted $\mathrm{CO_2}$ and aerosols" by L. A. Natusch and R. R. Netz.

The code is currently set up to simulate Model III of the paper (thermal convection + periodic breathing), with the parameters of the paper (room 5.75 m x 2.55 m x 2.85 m, grid spacing 2.5 cm, 1800 s simulated time).

Files:
- run_simulation.py: parameters, setup, and main run
- initialization.py: grid, initial fields, body and no-slip masks
- equations.py: GPU kernels (momentum, density, temperature, $\mathrm{CO_2}$) and the time loop

Other models of the paper:
- Model II (thermal convection, no breathing):
  1. run_simulation.py: set the tidal volume V_B = 0 (no breathing velocity).
  2. equations.py: activate the line "c_diff += dc / grid_num" in update_navier_stokes_gpu ($\mathrm{CO_2}$ source in front of the nostril).
  (For exactly the same no-slip mask as in the paper, also use the "Model II" variant of the mask in body() in initialization.py.)


- Model I (pure diffusion):
  1. run_simulation.py: set V_B = 0 and, in init_const() of initialization.py, scale the diffusion coefficient D (the paper shows D, 500 D, and 1000 D of $\mathrm{CO_2}$ in air).
  2. equations.py: in main_gpu(), comment out the call of update_velocity_gpu (no velocity field is computed), and activate the line "c_diff += dc / grid_num" in update_navier_stokes_gpu.

Requirements: NVIDIA GPU with CUDA support, Python 3, numpy, scipy, numba (with CUDA support). Plotting and evaluation scripts, and the experimental data, are available from the authors on request.

Files

Files (39.6 kB)

Name Size
md5:293b3aad3e3e09599ffeaccd3e20d324
27.5 kB Download
md5:64fbbe61906a39c18e03a1cd244f8afe
8.6 kB Download
md5:0844d3c09f815722a7d86c6585ada8e6
3.5 kB Download

Additional details

Software

Programming language
Python , Cuda