Core Types

StochParticles.ParticleSystemType
ParticleSystem{A, F}

Mutable parameter struct (the p in SciML's f(u, p, t)). Holds simulation metadata that changes during PDMP evolution.

Unit Convention

All masses are in kg, volumes in , temperatures in K, viscosities in Pa·s, and densities in kg/m³. Particle compositions μ in the ODE state vector u use these SI units.

Fields:

  • n_active::Int — current number of active particles
  • volume::Float64 — computational volume V_comp(t)
  • gas_phase::F — external function g(t) returning gas-phase concentrations
  • n_sim::Int — target particle count for CNMC
  • _mass_total_cache::Float64 — internal: cached total mass for CNMC volume rescale
  • _cached_majorant::Float64 — internal: cached K_max for coagulation accept/reject
StochParticles.species_valFunction
species_val(sys::ParticleSystem{A}) -> Val{A}

Return the compile-time species count as a Val type.

StochParticles.get_particleFunction
get_particle(u, i, ::Val{A}) -> SVector{A, Float64}

Extract particle i's composition from flat ODE state vector u. Type-stable: SVector is constructed via ntuple, compiler optimizes to direct load.

StochParticles.set_particle!Function
set_particle!(u, i, ::Val{A}, μ::SVector{A, Float64})

Write particle i's composition into flat ODE state vector u.

StochParticles.make_u0Function
make_u0(particles::Vector{SVector{A, Float64}}) -> Vector{Float64}

Create flat ODE state vector from particle composition vectors.

StochParticles.total_massFunction
total_mass(u, ::Val{A}, n_active) -> Float64

Sum of all component masses across active particles.

StochParticles.ParticleProblemFunction
ParticleProblem(particles, volume, gas_phase_fn, processes; tspan, n_sim)

Construct a SciML JumpProblem representing the PDMP for particle simulation.

Arguments

  • particles::Vector{SVector{A, Float64}} — initial particle states
  • volume::Float64 — initial computational volume
  • gas_phase_fn — external gas concentration function g(t)
  • processes::NTuple — tuple of PhysicsProcess instances
  • tspan — (tstart, tend)
  • n_sim — target particle count (CNMC). Default: length(particles)

Returns

  • JumpProblem ready for solve(prob, Tsit5())