Core Types
StochParticles.ParticleSystem — Type
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 m³, 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 particlesvolume::Float64— computational volume V_comp(t)gas_phase::F— external function g(t) returning gas-phase concentrationsn_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_val — Function
species_val(sys::ParticleSystem{A}) -> Val{A}Return the compile-time species count as a Val type.
StochParticles.get_particle — Function
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_u0 — Function
make_u0(particles::Vector{SVector{A, Float64}}) -> Vector{Float64}Create flat ODE state vector from particle composition vectors.
StochParticles.total_mass — Function
total_mass(u, ::Val{A}, n_active) -> Float64Sum of all component masses across active particles.
StochParticles.ParticleProblem — Function
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 statesvolume::Float64— initial computational volumegas_phase_fn— external gas concentration function g(t)processes::NTuple— tuple of PhysicsProcess instancestspan— (tstart, tend)n_sim— target particle count (CNMC). Default: length(particles)
Returns
JumpProblemready forsolve(prob, Tsit5())