Separate stochastic coagulation from initial-state variability
Download Python script · Download script with helper and data files (.zip)
Separate stochastic coagulation from initial-state variability
Section titled “Separate stochastic coagulation from initial-state variability”Would a second simulation tell the same physical story if only its collision seed changed? This experiment isolates process randomness from initial sampling. It teaches you to compare an ensemble spread with a proposed model effect. Start with particle-resolved coagulation for the number-loss and material-conservation distinction.
Sixteen boxes each begin with 1,024 active, mixed-material particles. Temperature, pressure and volume differ between boxes. The initial aerosol is identical across all sixteen realizations; only the process root seed changes. Every realization advances forty one-second Brownian steps.
CUDA computes exact Brownian pair maxima using bounded scratch storage, then follows the original sequential selection and random-stream semantics. Pair work remains quadratic in active particles per box. Each realization must conserve species mass and charge, decrease particle number, and produce nonzero collisions. The seed ensemble must contain distinct trajectories. Download the ZIP to include the shared study and plotting helpers.
Python · section 1
"""Manually refreshed sixteen-seed CUDA particle-resolved coagulation study."""
import matplotlib.pyplot as pltimport warp as wpfrom scripts.docs_gpu_figures import stochastic_figuresfrom scripts.gpu_studies.cases import StudyCase, build_case, radius_histogramfrom scripts.gpu_studies.trajectories import run_trajectory
def run_example(): """Run all sixteen seeds and retain their complete number histories.""" case = StudyCase( "stochastic-16-seeds", "brownian", 16, 1024, time_step=1.0, steps=40, heterogeneous=True, experiment="stochastic", ) initial, process, processes = build_case(case) _, histogram = radius_histogram(initial) report = run_trajectory(case, initial, process, processes) stochastic_figures( report, histogram, "Brownian particle histories · " + wp.get_device("cuda:0").name, ) plt.show() return reportRead the shaded bands correctly
Section titled “Read the shaded bands correctly”Lines show seed means; shading spans the 5th–95th percentiles of these sixteen realizations. It describes stochastic spread, not a confidence interval or measurement uncertainty. The left panel compares number loss in selected boxes, normalized by each box’s own initial concentration. The right panel shows how collisions move number toward larger radii in the middle box.
Stable logical box identities keep random streams attached to boxes when a prepared simulation is segmented or checkpointed. CPU and CUDA algorithms need not consume identical random streams, so cross-backend byte equality is not claimed. This manual CUDA workload does not run in routine CI.
Python · section 2
if __name__ == "__main__": run_example()Explicit cuda invocation
result = run_example()Warp 1.11.1 initialized:
CUDA Toolkit 12.9, Driver 13.4
Devices:
"cpu" : "CPU"
"cuda:0" : "NVIDIA GeForce RTX 5060" (8 GiB, sm_120, mempool enabled)
Kernel cache:
~/.cache/warp/1.11.1
Module particula.gpu.kernels.environment e11375e load on device 'cuda:0' took 2.69 ms (cached)
Module particula.gpu.kernels.coagulation 9ee9d75 load on device 'cuda:0' took 2.03 ms (cached)
Module particula.gpu.kernels._coagulation_native f93a244 load on device 'cuda:0' took 1.65 ms (cached)
Module warp.utils f35afd3 load on device 'cuda:0' took 2.16 ms (cached)
Module warp.math edde159 load on device 'cuda:0' took 2.16 ms (cached)
Module warp.marching_cubes fb6e712 load on device 'cuda:0' took 2.31 ms (cached)
Module particula.execution.communication 2909959 load on device 'cuda:0' took 1.49 ms (cached)
Module particula.gpu.kernels._population_validation edde159 load on device 'cuda:0' took 2.19 ms (cached)
Module particula.gpu.kernels.communication ac9b2a2 load on device 'cuda:0' took 2.13 ms (cached)
Module particula.gpu.properties.gas_properties edde159 load on device 'cuda:0' took 2.12 ms (cached)
Module particula.gpu.properties.particle_properties edde159 load on device 'cuda:0' took 2.18 ms (cached)
Module particula.gpu.dynamics.coagulation_funcs edde159 load on device 'cuda:0' took 2.20 ms (cached)
Module particula.gpu.dynamics.condensation_funcs edde159 load on device 'cuda:0' took 2.14 ms (cached)
Module particula.gpu.kernels._condensation_native edde159 load on device 'cuda:0' took 2.16 ms (cached)
Module particula.gpu.kernels._condensation_parallel edde159 load on device 'cuda:0' took 2.17 ms (cached)
Module particula.gpu.kernels.thermodynamics edde159 load on device 'cuda:0' took 2.20 ms (cached)
Module particula.gpu.kernels.condensation edde159 load on device 'cuda:0' took 2.16 ms (cached)
Module particula.gpu.kernels.exhaustion ccbadfa load on device 'cuda:0' took 3.65 ms (cached)
Module particula.gpu.kernels.slot_management 0375e2c load on device 'cuda:0' took 0.95 ms (cached)
Module particula.gpu.kernels.nucleation 1124f09 load on device 'cuda:0' took 2.67 ms (cached)
Module particula.execution.gpu_resources 30f296c load on device 'cuda:0' took 1.97 ms (cached)
Module particula.gpu.warp_types edde159 load on device 'cuda:0' took 2.16 ms (cached)
Module particula.execution.prepared_diagnostics ca06582 load on device 'cuda:0' took 1.83 ms (cached)
Module particula.gpu.kernels._brownian_parallel 17ce68f load on device 'cuda:0' took 1.68 ms (cached)
Module particula.execution.prepared_guards e16d312 load on device 'cuda:0' took 1.12 ms (cached)
Module particula.gpu.kernels._brownian_parallel 326c699 load on device 'cuda:0' took 2.57 ms (cached)
Module particula.gpu.kernels.coagulation 2ead52b load on device 'cuda:0' took 3.33 ms (cached)
Module particula.gpu.kernels.coagulation fed17be load on device 'cuda:0' took 1.06 ms (cached)
16 independent stream seeds; ensemble spread, not a confidence interval
Distinct final trajectories: 16

Compare a proposed effect with the spread
Section titled “Compare a proposed effect with the spread”Changing only process seeds produces a distribution of number and size outcomes from the same starting state. The shaded bands summarize these sixteen runs; they do not quantify uncertainty in concentration, material properties, or the collision model, and sixteen seeds may poorly resolve rare tails.
To test a small environmental effect, repeat both conditions over a larger seed ensemble while holding initial populations controlled. Compare effect size with seed-to-seed variation and verify that conclusions persist under timestep and sample-size refinement. The lucky-few study extends this idea to the much more demanding question of uncommon large-particle growth.
Explore this topic: Prepared simulations