Skip to content

Particle mass precision across four size scales

See the qualification record for the associated implementation decision and reproduction gates.

The test fixture in particula/gpu/tests/mass_precision_cases_test.py defines the following cases in ascending radius order:

  1. npf_cluster — new-particle-formation cluster, target radius 1.5e-9 m
  2. five_to_ten_nm — 5-10 nm particle, target radius 7.0e-9 m
  3. accumulation_mode — accumulation mode, target radius 1.5e-7 m
  4. cloud_droplet — cloud droplet, target radius 1.0e-5 m

Each case uses deterministic np.float64 arrays with the canonical particle storage shapes:

  • masses -> (n_boxes, n_particles, n_species)
  • concentration -> (n_boxes, n_particles)
  • charge -> (n_boxes, n_particles)
  • density -> (n_species,)
  • volume -> (n_boxes,)
  • npf_cluster: 1000.0 kg/m^3
  • five_to_ten_nm: 1100.0 kg/m^3
  • accumulation_mode: species densities [1200.0, 1800.0] kg/m^3
  • cloud_droplet: species densities [1000.0, 1770.0] kg/m^3
  • npf_cluster: [1.0]
  • five_to_ten_nm: [1.0]
  • accumulation_mode: [0.65, 0.35]
  • cloud_droplet: [0.92, 0.08]

All baseline masses use the same spherical mass formula inverted by ParticleData.radii:

mass = (4.0 / 3.0) * π * radius^3 * density

Mixed-species cases split the implied total particle volume across fixed species volume fractions before converting each species volume to mass.

The regression suite reconstructs the expected radii for every deterministic case, including the mixed-species accumulation_mode and cloud_droplet baselines, from the authored total particle volume implied by those masses and densities.

All reported radii use meters, densities use kg/m^3, and volume fractions are unitless fractions.

The shipped evidence comes from the deterministic baseline fixture in particula/gpu/tests/mass_precision_cases_test.py, the comparison suite in particula/gpu/tests/mass_precision_metrics_test.py, and the fast benchmark helper coverage in particula/gpu/tests/benchmark_helpers_test.py.

  • Deterministic cases span NPF-scale through droplet-scale particles: npf_cluster, five_to_ten_nm, accumulation_mode, and cloud_droplet.
  • All baseline inputs use explicit np.float64 arrays and canonical container shapes.
  • Mixed-species baselines reconstruct expected radii from authored total volume, fixed species volume fractions, and documented densities.

The focused comparison module particula/gpu/tests/mass_precision_metrics_test.py evaluates exactly three study-only candidates against the fp64 baseline:

  1. fp32_absolute_mass
    • Store per-species masses as np.float32.
    • Reconstruct comparable analysis inputs by casting those masses back to np.float64.
  2. mixed_precision_mass_plus_density
    • Keep density at np.float64.
    • Store masses, concentration, charge, and volume as np.float32.
    • Reconstruct comparable analysis inputs by casting the candidate-side arrays back to np.float64 before checking mass and radius fidelity.
  3. fp32_total_mass_fp32_mass_fraction
    • Store per-particle total mass and per-species mass fractions as np.float32.
    • Reconstruct per-species masses in np.float64 as total_mass[..., None] * mass_fractions.
    • Zero-total-mass particles reconstruct deterministically to zeros rather than relying on divide-by-zero warnings.

For all three candidates, the study compares reconstructed per-species masses and derived radii against the baseline np.float64 fixture values with bounded numpy.testing.assert_allclose tolerances.

Candidate evaluation thresholds and conservation-sensitive checks

Section titled “Candidate evaluation thresholds and conservation-sensitive checks”

Candidate evaluation extends the same case-candidate matrix with cached executable metrics:

  • pure reconstruction error:
    • relative mass error threshold: 5e-7
    • relative radius error threshold: 2e-7
  • mixed-scale smallest-particle stress case:
    • relative mass error threshold: 6e-7
    • relative radius error threshold: 2.5e-7
  • CPU-reference mass-transfer comparison:
    • use particula.dynamics.condensation.mass_transfer.get_mass_transfer
    • build deterministic mass_rate, time_step, gas_mass, particle_mass, and particle_concentration directly from the cached baseline and reconstructed arrays
    • report both per-particle deltas and aggregate species-total deltas
    • enforce aggregate species-total relative tolerance _AGGREGATE_DELTA_RTOL = 5e-7 separately from per-particle checks

The fast candidate evaluation suite keeps representative coverage bounded to the shipped four deterministic cases plus one mixed-scale stress case where nanometer particles and droplet-scale particles coexist in the same (n_boxes, n_particles, n_species) array.

Candidate evaluation mixed-scale fidelity finding

Section titled “Candidate evaluation mixed-scale fidelity finding”

The mixed-scale stress case uses a single-species deterministic array that puts 1.5e-9 m particles in the same boxes as 8.0e-6 m to 1.5e-5 m droplets. The executable review threshold is intentionally focused on the smallest particle slice so whole-array aggregates cannot hide fragile small-particle loss.

Aggregate mixed-scale checks are tracked separately from the smallest-particle slice checks. The aggregate assertion applies to species totals over the full array, while the mixed-scale smallest-particle assertions remain the guardrail for nanometer-scale fidelity.

Candidate evaluation zero-mass and zero-volume edge handling

Section titled “Candidate evaluation zero-mass and zero-volume edge handling”
  • Zero-total-mass reconstruction remains deterministic for fp32_total_mass_fp32_mass_fraction:
    • projected total mass is exactly zero
    • projected mass fractions are exactly zero
    • reconstructed masses and derived radii are exactly zero
  • Zero-volume / zero-effective-radius paths are exercised with explicit zero particle masses and zero mass-transfer rates.
  • The fast metric suite is rerun under pytest -Werror to keep these paths divide-by-zero-warning free.

When evaporation-oriented comparisons would drive raw updated mass below zero, the study records three separate quantities:

  1. raw_updated_mass = initial_mass + raw_mass_transfer
  2. post_clamp_mass = maximum(raw_updated_mass, 0.0)
  3. clamp_delta = post_clamp_mass - raw_updated_mass

The executable metrics also report clamp frequency as the number of entries where raw_updated_mass < 0.0, and aggregate clamp delta per species. This keeps raw reconstruction error distinct from clamp-induced mass changes.

Candidate evaluation memory-footprint examples

Section titled “Candidate evaluation memory-footprint examples”

These examples use analytic shape × dtype-size accounting only.

Candidate Example shape Formula Approx. bytes
fp32_absolute_mass 10 × 100,000 × 3 masses 10 * 100000 * 3 * 4 12,000,000
mixed_precision_mass_plus_density masses + concentration + charge + volume + density with 10 boxes, 100,000 particles, 3 species (10 * 100000 * 3 * 4) + (10 * 100000 * 4) + (10 * 100000 * 4) + (10 * 4) + (3 * 8) 20,000,064
fp32_total_mass_fp32_mass_fraction total mass + mass fractions with 10 × 100,000 × 3 (10 * 100000 * 4) + (10 * 100000 * 3 * 4) 16,000,000
Baseline fp64 masses 10 × 100,000 × 3 masses 10 * 100000 * 3 * 8 24,000,000

These examples document storage tradeoffs only. They do not change production runtime schemas or default dtypes.

Candidate evaluation throughput evidence availability

Section titled “Candidate evaluation throughput evidence availability”
  • Fast default validation remains in particula/gpu/tests/mass_precision_metrics_test.py.
  • Optional throughput evidence lives on the existing benchmark surface in particula/gpu/tests/benchmark_test.py.
  • The candidate evaluation benchmark path records bounded study-only candidate-payload timings for three representative case/candidate pairs, including the full documented projection payload for each candidate rather than reconstruction-only mass casts, and still requires the explicit --benchmark opt-in plus CUDA availability.
  • On machines without Warp or CUDA support, the benchmark module skips cleanly for GPU execution, while CPU-only helper coverage remains importable and the fast metric suite remains runnable.
  • No random draws are used.
  • Arrays are rebuilt from fixed constants.
  • Case-candidate projections and CPU-reference mass-transfer comparisons are cached once per deterministic input pair and then reused across assertions.
  • Tests assert exact rerun stability and exact Warp CPU-device round trips for representative single-species and mixed-species cases.
  • Tests also assert finiteness, nonnegative masses, and malformed-input rejection.

Explore this topic: Scientific and numerical correctness