Skip to content

Separate stochastic coagulation from initial-state variability

View code · Download Python script · Download complete ZIP

Separate stochastic coagulation from initial-state variability

Section titled “Separate stochastic coagulation from initial-state variability”

The collision sampler can divide each one-second observation interval into shorter passes. Each pass schedules the full trial demand for its duration. All boxes reach the same observation time.

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 plt
import numpy as np
from scripts.docs_gpu_figures import stochastic_figures
from scripts.gpu_studies.cases import StudyCase, build_case, radius_histogram
from 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)
report["initial_histogram"] = histogram.tolist()
plot_results(report)
plt.show()
return report
def plot_results(report):
"""Draw the measured histories from a completed CUDA run."""
return stochastic_figures(
report,
np.asarray(report["initial_histogram"]),
"Brownian particle histories",
)

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 1.79 ms  (cached)
Module particula.gpu.kernels.coagulation 84ae354 load on device 'cuda:0' took 1.24 ms  (cached)
Module particula.gpu.kernels._coagulation_native f93a244 load on device 'cuda:0' took 1.52 ms  (cached)
Module warp.utils f35afd3 load on device 'cuda:0' took 0.85 ms  (cached)
Module warp.math edde159 load on device 'cuda:0' took 0.79 ms  (cached)
Module warp.marching_cubes fb6e712 load on device 'cuda:0' took 1.47 ms  (cached)
Module particula.gpu.properties.gas_properties edde159 load on device 'cuda:0' took 2.27 ms  (cached)
Module particula.gpu.properties.particle_properties edde159 load on device 'cuda:0' took 2.81 ms  (cached)
Module particula.gpu.dynamics.coagulation_funcs edde159 load on device 'cuda:0' took 2.48 ms  (cached)
Module particula.gpu.dynamics.condensation_funcs edde159 load on device 'cuda:0' took 2.46 ms  (cached)
Module particula.gpu.dynamics.ion_pair_data edde159 load on device 'cuda:0' took 2.47 ms  (cached)
Module particula.gpu.dynamics.van_der_waals edde159 load on device 'cuda:0' took 2.46 ms  (cached)
Module particula.gpu.kernels._coagulation_budget b4a3978 load on device 'cuda:0' took 1.87 ms  (cached)
Module particula.gpu.kernels._coagulation_subcycling edde159 load on device 'cuda:0' took 2.45 ms  (cached)
Module particula.execution.communication 2909959 load on device 'cuda:0' took 1.66 ms  (cached)
Module particula.gpu.kernels._population_validation edde159 load on device 'cuda:0' took 2.45 ms  (cached)
Module particula.gpu.kernels.communication ac9b2a2 load on device 'cuda:0' took 2.42 ms  (cached)
Module particula.gpu.kernels._condensation_native edde159 load on device 'cuda:0' took 2.61 ms  (cached)
Module particula.gpu.kernels._condensation_parallel edde159 load on device 'cuda:0' took 2.45 ms  (cached)
Module particula.gpu.kernels.thermodynamics edde159 load on device 'cuda:0' took 2.45 ms  (cached)
Module particula.gpu.kernels.condensation edde159 load on device 'cuda:0' took 1.82 ms  (cached)
Module particula.gpu.kernels.exhaustion 616f81d load on device 'cuda:0' took 3.52 ms  (cached)
Module particula.gpu.kernels.slot_management 0375e2c load on device 'cuda:0' took 1.13 ms  (cached)
Module particula.gpu.kernels.nucleation 1124f09 load on device 'cuda:0' took 3.21 ms  (cached)
Module particula.execution.gpu_resources 30f296c load on device 'cuda:0' took 2.28 ms  (cached)
Module particula.gpu.warp_types edde159 load on device 'cuda:0' took 2.44 ms  (cached)
Module particula.execution.prepared_diagnostics ca06582 load on device 'cuda:0' took 2.11 ms  (cached)
Module particula.gpu.kernels._brownian_parallel 5433dfc load on device 'cuda:0' took 2.30 ms  (cached)
Module particula.execution.prepared_guards 5366864 load on device 'cuda:0' took 1.80 ms  (cached)
Module particula.gpu.kernels._brownian_parallel f84feee load on device 'cuda:0' took 2.74 ms  (cached)
Module particula.gpu.kernels._coagulation_subcycling 93efbd4 load on device 'cuda:0' took 1.33 ms  (cached)
Module particula.gpu.kernels._brownian_parallel c0acfec load on device 'cuda:0' took 4.70 ms  (cached)
Module particula.gpu.kernels.coagulation fd5b5c9 load on device 'cuda:0' took 3.05 ms  (cached)
Module particula.gpu.kernels.coagulation 79e9aa8 load on device 'cuda:0' took 1.08 ms  (cached)
Module particula.gpu.kernels._coagulation_subcycling ca6b3ba load on device 'cuda:0' took 2.95 ms  (cached)
Module particula.gpu.kernels._coagulation_subcycling a49d377 load on device 'cuda:0' took 0.54 ms  (cached)
16 independent stream seeds; ensemble spread, not a confidence interval
Distinct final trajectories: 16
Separate stochastic coagulation from initial-state variability: saved scientific figure
Separate stochastic coagulation from initial-state variability · saved execution output

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