Skip to content

Live Integration

Demonstrates live=True mode, which prints a z/T/S diagnostic table after each integration chunk — replicating the interactive output of the v1 CVode integrator. Useful for watching long runs or debugging initial conditions.

Script: examples/live_run.py

python examples/live_run.py
python examples/live_run.py --chunk-dt 5 --no-console

Usage

import pyrcel as pm

model = pm.ParcelModel([aerosol], V=1.0, T0=283.15, S0=-0.02, P0=85000.0)

out = model.run(
    t_end=300.0,
    output_dt=1.0,
    live=True,           # print z/T/S after each chunk
    live_chunk_dt=10.0,  # chunk length in simulation seconds
)

Each chunk completes one JAX solve covering live_chunk_dt seconds of simulation time, then prints a summary row before starting the next chunk.

Console output

pyrcel v2 — live integration run
─────────────────────────────────────────────────────────────────
chunk   z (m)     T (K)    S (%)
  1     10.0    282.99   -1.983
  2     20.0    282.83   -1.804
  3     30.0    282.66   -1.538
  4     40.0    282.50   -1.160
  5     50.0    282.33   -0.637
  6     60.0    282.16    0.062
  7     70.0    281.99    0.298
  8     80.0    281.82    0.421
  9     90.0    281.65    0.474
 10    100.0    281.48    0.481  ← S_max
 11    110.0    281.31    0.468
─────────────────────────────────────────────────────────────────
Integration terminated at z = 103.4 m  (10 m past S_max)
S_max = 0.481 %  at t = 93.4 s

Output figure

Live integration trajectory

The figure shows the same supersaturation and temperature profile as the basic run, confirming that chunked live mode produces an identical trajectory to a single compiled solve.

When to use live vs. progress

Mode How it works Best for
live=True Python loop over chunks; prints after each Watching long runs; debugging
progress=True diffrax text meter; single compiled call Interactive sessions wanting a progress bar
Neither Silent single call Production / jax.vmap / jax.grad

live mode is not differentiable

Because live=True splits the solve across Python-level chunk boundaries, it is incompatible with jax.grad and jax.vmap. Use the low-level max_supersaturation or nd_from_parcel functions for the differentiable path.