Skip to content

particula.dynamics.chemistry.resolved

Closed gas, bulk particle and collision-limited uptake in resolved boxes.

Classes

NameDescription
ResolvedChemistryCouple a version-2 mechanism across gas and resolved particle masses.
_BoxKineticsScale each particle's integrated moles by its initial volume.

ResolvedChemistryclass#

class ResolvedChemistry(bound: ResolvedBinding, solver=_DEFAULT_SOLVER, *, name='resolved_chemistry')

Bases: BoxProcess

Couple a version-2 mechanism across gas and resolved particle masses.

Bulk rates use mol/m³ of instantaneous particle material. Uptake uses a spherical collision area, prescribed net uptake probability and mean molecular speed. RK23 absolute tolerances use mol/m³ of air for gas and mol/m³ of the initial particle volume for each process interval.

_namespaceattributeclass attributeinstance attribute#

_namespace = 'resolved_chemistry'

boundattributeinstance attribute#

bound = bound

solverattributeinstance attribute#

solver = solver

__init__method#

def __init__(bound: ResolvedBinding, solver=_DEFAULT_SOLVER, *, name='resolved_chemistry')

Select the immutable layout and per-box adaptive controls.

advancemethod#

def advance(aerosol, *, time, time_step, context)

Integrate one simultaneous closed material balance within a box.

configurationmethod#

def configuration()

Return restart identity including densities, mappings and solver.

validatemethod#

def validate(aerosol)

Validate current representation, layout and inventories.

Inherited from particula.box_process.BoxProcess

extension_idattributeinstance attribute#

extension_id = extension_id or name

nameattributeinstance attribute#

name = name

parametersattributeinstance attribute#

parameters = parameters

readsattributeinstance attribute#

reads = tuple(reads)

representationsattributeinstance attribute#

representations = tuple(representations)

stochasticattributeinstance attribute#

stochastic = stochastic

versionattributeinstance attribute#

version = version

writesattributeinstance attribute#

writes = tuple(writes)

executemethod#

def execute(aerosol, time_step, sub_steps=1, *, context=None, time=0.0)

Publish a successful process substep atomically across boxes.

Inherited from particula.runnable.RunnableABC

__or__method#

def __or__(other: RunnableABC) -> RunnableSequence

Chain this Runnable with another using the ’|’ operator.

This method enables an easy way to sequence processes, so they can be executed in a defined order.

Parameters

NameTypeDescription
otherRunnableABCAnother Runnable to append after this one.

Returns

RunnableSequence
A sequence containing both processes.

Examples

Chaining two processes
combined_process = process1 | process2
final_aerosol = combined_process.execute(aerosol, time_step=1.0)

_advance_boxmethod#

def _advance_box(aerosol, time_step)

Dispatch one staged interval through the native extension seam.

_box_workermethod#

def _box_worker(box, boxes, transaction)

Create isolated hook state for a single box.

_execute_boxmethod#

def _execute_box(aerosol, time_step, sub_steps=1)

Execute the single-box numerical building block.

_is_stochasticmethod#

def _is_stochastic(aerosol)

Report whether this process requires independent box streams.

_prepare_commitmethod#

def _prepare_commit(workers, uses_context)

Prepare a non-failing diagnostics publisher before numeric writes.

_rate_boxmethod#

def _rate_box(aerosol)

Evaluate the single-box numerical building block.

_validate_batchmethod#

def _validate_batch(aerosol)

Validate process-wide controls before staging boxes.

_writer_fieldsmethod#

def _writer_fields(aerosol)

Declare numeric destinations for transactional publication.

preparemethod#

def prepare(aerosol: Aerosol, *, time_step: float, backend: Backend | None = None, device: str = 'cuda:0', root_seed: int = 0, logical_box_ids=None, process_registry=None, coagulation_work_config=None, coagulation_subcycling=None, time: float = 0.0) -> PreparedSimulation

Upload native state once and prepare supported resident GPU physics.

Parameters

NameTypeDefaultDescription
aerosolAerosolrequiredInitial native particle, gas and environment state.
time_stepfloatrequiredFixed duration of each complete process cycle [s].
backendBackend | NoneNoneBackend.WARP by default; CPU execution uses execute().
devicestr'cuda:0'Explicit Warp device, default CUDA device zero.
root_seedint0Root seed for persistent independent process/box streams.
logical_box_idsNoneOptional stable identities in physical box order.
process_registryNoneExact-type custom GPU adapter registrations.
coagulation_work_configNoneOptional coagulation resource budgets.
coagulation_subcyclingNoneOptional bounded adaptive policy.
timefloat0.0Absolute initial simulation time [s].

Returns

PreparedSimulation
An owned PreparedSimulation. Use its context manager or close().
PreparedSimulation
snapshot() returns detached CPU state for analysis and plotting.

Raises

ValueError
If process physics or state cannot be represented.
RuntimeError
If the requested runtime/device is unavailable.

ratemethod#

def rate(aerosol: Aerosol) -> Any

Evaluate detached box hooks and retain a leading box axis.

resumemethod#

def resume(checkpoint: SimulationCheckpoint, *, backend: Backend | None = None, device: str | None = None, process_registry=None, retry_subcycling=None) -> PreparedSimulation

Resume exact saved state using the same process configuration.

Parameters

NameTypeDefaultDescription
checkpointSimulationCheckpointrequiredSimulationCheckpoint from a prepared owner.
backendBackend | NoneNoneBackend.WARP by default.
devicestr | NoneNoneExact checkpoint device by default; migration rejects.
process_registryNoneCompatible caller-supplied GPU implementations.
retry_subcyclingNoneExplicitly relax a saved adaptive coagulation policy while retaining the outer timestep and random streams.

Returns

PreparedSimulation
A new owner preserving state, RNG words, timestep and counters.
PreparedSimulation
Capture is explicit again; native graph handles are never restored.

Raises

ValueError
If configuration, order, schema or device differs, or current population cannot be admitted (e.g. unequal Brownian counts after a later process injected new particles).

_BoxKineticsclass#

class _BoxKinetics(bound, aerosol)

Scale each particle’s integrated moles by its initial volume.

activeattributeinstance attribute#

active = particles.population[0] > 0

gmattributeinstance attribute#

gm = np.asarray(bound.gas_masses)

initialattributeinstance attribute#

initial = np.concatenate(
  (aerosol.gas.concentration[0] / self.gm, masses / self.pm / reference[:, None].ravel())
)

kattributeinstance attribute#

k = a * temp / t_ref ** exponent * np.exp(-energy / GAS_CONSTANT * temp)

kindsattributeinstance attribute#

kinds = bound.kinds

netattributeinstance attribute#

net = np.asarray(bound.net)

ngattributeinstance attribute#

ng = self.gm.size

ordersattributeinstance attribute#

orders = np.asarray(bound.orders)

partial_volumeattributeinstance attribute#

partial_volume = self.pm / particles.density

pmattributeinstance attribute#

pm = np.asarray(bound.particle_masses)

referenceattributeinstance attribute#

reference = masses / particles.density.sum(axis=1)

sourcesattributeinstance attribute#

sources = bound.sources

speedattributeinstance attribute#

speed = np.sqrt(8 * GAS_CONSTANT * temp / np.pi * self.gm)

weightsattributeinstance attribute#

weights = slot_density(particles)[0]

__init__method#

def __init__(bound, aerosol)

admissiblemethod#

def admissible(state)

Reject a negative concentration or an emptied active slot.

publishmethod#

def publish(aerosol, final)

Publish changed lanes and preserve inactive and inert values.

ratemethod#

def rate(time, state)

Return gas mol/m³-air/s and material mol/m³-initial-particle/s.