particula.execution.diagnostics
Write closed resident diagnostics into caller-owned Warp arrays.
This concrete direct-import-only module has no callback registration or package
export. Its shared validator performs read-only metadata checks without
constructing an executor or mutating resident state. Registrations execute in
this fixed order: gas-concentration snapshot,
saturation-ratio snapshot, total species mass, particle-number concentration,
latent heat energy, and conservation residual. Matrix operations use (B, S)
wp.float64 arrays; particle number uses a (B,) wp.float64 array.
For native resolved counts, total mass adds Σp(m * N) to V * gas
using an explicit complete material-to-gas map. PMF particle density
use V * Σp(m * c). Native mass diagnostics reject unmapped particle-only
lanes instead of dropping their inventory. Matrix lanes follow full gas order.
Resolved number concentration is Σp(N) / V; density carriers use Σp(c).
Latent energy copies signed
whole-call inventory-limited energy in J. The residual is
total_mass - baseline_total_mass - source_ledger + sink_ledger in kg;
source and sink ledgers are nonnegative accumulated extensive-mass inputs.
Execution validates caller-owned same-device bindings without host readback,
synchronization, transfer, allocation, or physics mutation. Empty matrix
operations are write-free for B == 0 or S == 0; particle number is
write-free only for B == 0. Prepared setup binds the closed plan; its
observation-free enqueue repeats no host/setup metadata validation and performs
no allocation, host readback, transfer, synchronization, lookup, or rebinding.
Retained diagnostic writers still perform device-side status and physical-state
Validation. Setup rejection is pre-writer; rollback is not promised after a
diagnostic writer launches.
Classes
| Name | Description |
|---|---|
PreparedResidentDiagnostics | Bind validated diagnostic sources and registrations for enqueue only. |
ResidentDiagnosticOperation | Enumerate the closed resident diagnostic operations in launch order. |
ResidentDiagnosticRegistration | Bind one closed diagnostic operation to caller-owned Warp arrays. |
ResidentDiagnosticsExecutor | Execute an already-bound closed diagnostics plan without transfers. |
ResidentDiagnosticsPlan | Bind ordered closed diagnostics to one resident graph and schedule. |
Functions
| Name | Description |
|---|---|
_accumulate_mapped_particle_mass | Accumulate one explicit material-to-gas extensive inventory lane. |
_accumulate_number_density | Reduce represented counts to per-volume number concentration. |
_clear_particle_number | Clear one particle-number output lane before staged accumulation. |
_conservation_residual | Write the ledger-aware residual from the already-reduced total mass. |
_copy_snapshot | Copy one resident diagnostic matrix element to its output. |
_enqueue_prepared_resident_diagnostics | Dispatch only registrations retained by prepared diagnostics setup. |
_initialize_total_species_mass | Initialize each extensive-mass lane from resident gas. |
_mass_pairs | Validate total-mass provenance without device work or inferred lanes. |
setup_prepared_resident_diagnostics | Validate a declaration diagnostics attachment and bind enqueue |
validate_resident_diagnostics_plan | Validate an exact diagnostics plan without constructing an executor. |
PreparedResidentDiagnosticsclassdataclass#
class PreparedResidentDiagnostics(plan: ResidentDiagnosticsPlan, particle_masses: object, particle_population: object, particle_volume: object, gas_concentration: object, saturation_ratio: object, device: object, dimensions: object, registrations: tuple[ResidentDiagnosticRegistration, ...], outputs: tuple[object, ...], energy_transfers: tuple[object | None, ...], baseline_total_masses: tuple[object | None, ...], source_ledgers: tuple[object | None, ...], sink_ledgers: tuple[object | None, ...], total_mass_output: object | None, particle_mass_pairs: tuple[tuple[int, int], ...] = ())Bind validated diagnostic sources and registrations for enqueue only.
This concrete-only record retains every source, output, and operation by identity. Its observation-free enqueue dispatches those retained writers only; it does not revalidate or rediscover the plan.
Attributes
| Name | Type | Description |
|---|---|---|
plan | ResidentDiagnosticsPlan | Exact diagnostics plan validated during setup. |
particle_masses | object | Bound resident particle mass array. |
particle_population | object | Bound resident extensive particle population. |
particle_volume | object | Bound resident particle volume array. |
gas_concentration | object | Bound resident gas concentration array. |
saturation_ratio | object | Bound resident saturation-ratio array. |
device | object | Device shared by bound arrays and outputs. |
dimensions | object | Exact resident dimensions used for empty-schema checks. |
registrations | tuple[ResidentDiagnosticRegistration, ...] | Canonically ordered diagnostic registrations. |
outputs | tuple[object, ...] | Registration outputs in canonical launch order. |
energy_transfers | tuple[object | None, ...] | Latent-energy inputs aligned with registrations. |
baseline_total_masses | tuple[object | None, ...] | Residual baselines aligned with registrations. |
source_ledgers | tuple[object | None, ...] | Residual source ledgers aligned with registrations. |
sink_ledgers | tuple[object | None, ...] | Residual sink ledgers aligned with registrations. |
total_mass_output | object | None | Bound total-mass output used by the residual writer. |
particle_mass_pairs | tuple[tuple[int, int], ...] | Validated gas-to-particle inventory lane pairs. |
baseline_total_massesattributeinstance attribute#
baseline_total_masses: tuple[object | None, ...]deviceattributeinstance attribute#
device: objectdimensionsattributeinstance attribute#
dimensions: objectenergy_transfersattributeinstance attribute#
energy_transfers: tuple[object | None, ...]gas_concentrationattributeinstance attribute#
gas_concentration: objectoutputsattributeinstance attribute#
outputs: tuple[object, ...]particle_mass_pairsattributeclass attributeinstance attribute#
particle_mass_pairs: tuple[tuple[int, int], ...] = ()particle_massesattributeinstance attribute#
particle_masses: objectparticle_populationattributeinstance attribute#
particle_population: objectparticle_volumeattributeinstance attribute#
particle_volume: objectplanattributeinstance attribute#
plan: ResidentDiagnosticsPlanregistrationsattributeinstance attribute#
registrations: tuple[ResidentDiagnosticRegistration, ...]saturation_ratioattributeinstance attribute#
saturation_ratio: objectsink_ledgersattributeinstance attribute#
sink_ledgers: tuple[object | None, ...]source_ledgersattributeinstance attribute#
source_ledgers: tuple[object | None, ...]total_mass_outputattributeinstance attribute#
total_mass_output: object | None__init__method#
def __init__(plan: ResidentDiagnosticsPlan, particle_masses: object, particle_population: object, particle_volume: object, gas_concentration: object, saturation_ratio: object, device: object, dimensions: object, registrations: tuple[ResidentDiagnosticRegistration, ...], outputs: tuple[object, ...], energy_transfers: tuple[object | None, ...], baseline_total_masses: tuple[object | None, ...], source_ledgers: tuple[object | None, ...], sink_ledgers: tuple[object | None, ...], total_mass_output: object | None, particle_mass_pairs: tuple[tuple[int, int], ...] = ()) -> NoneResidentDiagnosticOperationclass#
class ResidentDiagnosticOperation(str, Enum)Bases: str, Enum
Enumerate the closed resident diagnostic operations in launch order.
CONSERVATION_RESIDUALattributeclass attributeinstance attribute#
CONSERVATION_RESIDUAL = 'conservation_residual'GAS_CONCENTRATION_SNAPSHOTattributeclass attributeinstance attribute#
GAS_CONCENTRATION_SNAPSHOT = 'gas_concentration_snapshot'LATENT_HEAT_ENERGYattributeclass attributeinstance attribute#
LATENT_HEAT_ENERGY = 'latent_heat_energy'PARTICLE_NUMBER_CONCENTRATIONattributeclass attributeinstance attribute#
PARTICLE_NUMBER_CONCENTRATION = 'particle_number_concentration'SATURATION_RATIO_SNAPSHOTattributeclass attributeinstance attribute#
SATURATION_RATIO_SNAPSHOT = 'saturation_ratio_snapshot'TOTAL_SPECIES_MASSattributeclass attributeinstance attribute#
TOTAL_SPECIES_MASS = 'total_species_mass'ResidentDiagnosticRegistrationclassdataclass#
class ResidentDiagnosticRegistration(operation: ResidentDiagnosticOperation, output: object, energy_transfer: object | None = None, baseline_total_mass: object | None = None, source_ledger: object | None = None, sink_ledger: object | None = None, species_map: object | None = None)Bind one closed diagnostic operation to caller-owned Warp arrays.
Attributes
| Name | Type | Description |
|---|---|---|
operation | ResidentDiagnosticOperation | Exact closed operation that selects the diagnostic reduction. |
output | object | Caller-owned Warp float64 output validated by the executor. |
energy_transfer | object | None | Required (B, S) signed whole-call energy input in
J for latent-energy output; forbidden otherwise. |
baseline_total_mass | object | None | Required (B, S) extensive mass baseline in kg
for residual output; forbidden otherwise. |
source_ledger | object | None | Required nonnegative extensive source ledger for the residual in kg; forbidden otherwise. |
sink_ledger | object | None | Required nonnegative extensive sink ledger for residual in kg; forbidden otherwise. |
species_map | object | None | Native total-mass gas-to-particle map covering all material lanes; forbidden for other operations. |
baseline_total_massattributeclass attributeinstance attribute#
baseline_total_mass: object | None = Noneenergy_transferattributeclass attributeinstance attribute#
energy_transfer: object | None = Noneoperationattributeinstance attribute#
operation: ResidentDiagnosticOperationoutputattributeinstance attribute#
output: objectsink_ledgerattributeclass attributeinstance attribute#
sink_ledger: object | None = Nonesource_ledgerattributeclass attributeinstance attribute#
source_ledger: object | None = Nonespecies_mapattributeclass attributeinstance attribute#
species_map: object | None = None__init__method#
def __init__(operation: ResidentDiagnosticOperation, output: object, energy_transfer: object | None = None, baseline_total_mass: object | None = None, source_ledger: object | None = None, sink_ledger: object | None = None, species_map: object | None = None) -> None__post_init__method#
def __post_init__() -> NoneValidate the exact closed diagnostic operation.
Raises
TypeError- If
operationis not an exact supported operation. ValueError- If required accounting inputs are missing or forbidden
accounting inputs are supplied for
operation.
ResidentDiagnosticsExecutorclass#
class ResidentDiagnosticsExecutorExecute an already-bound closed diagnostics plan without transfers.
Validation preserves caller ownership and rejects output or accounting-input
aliases with resident primaries, published sidecars, or diagnostic outputs.
Execution dispatches the six canonical registrations without host readback,
synchronization, transfer, allocation, or physics mutation. Matrix
registrations are write-free for empty (B, S) schemas; particle number
remains writable for (B, 0).
_execute_validatedmethod#
def _execute_validated(plan: ResidentDiagnosticsPlan) -> NoneDispatch a plan already validated by its owning scheduler step.
_validatemethod#
def _validate(plan: ResidentDiagnosticsPlan) -> NoneValidate plan provenance, closed operation order, and outputs.
Parameters
| Name | Type | Description |
|---|---|---|
plan | ResidentDiagnosticsPlan | Exact diagnostics plan whose retained bindings are checked. |
Raises
ValueError- If lifecycle, graph, schedule, protocol, or output metadata validation fails.
_validate_graph_and_schedulemethod#
def _validate_graph_and_schedule(plan: ResidentDiagnosticsPlan) -> NoneValidate graph provenance, membership, and canonical order.
_validate_outputsmethod#
def _validate_outputs(plan: ResidentDiagnosticsPlan) -> NoneValidate caller-owned diagnostic outputs against resident state.
_validate_registrationsmethod#
def _validate_registrations(plan: ResidentDiagnosticsPlan) -> NoneValidate diagnostic registration ordering and uniqueness.
executemethod#
def execute(plan: object) -> NoneValidate and dispatch each registration in declared order.
Matrix schemas complete without their writer launch when B == 0 or
S == 0. Particle number still launches for (B, 0) because its
(B,) output exists. Successful launches are asynchronous; callers
synchronize before inspecting outputs on the host.
Parameters
| Name | Type | Description |
|---|---|---|
plan | object | Exact plan selecting the sources and caller-owned outputs. |
Raises
TypeError- If
planis not an exact diagnostics plan. ValueError- If its bindings or output metadata are invalid.
validatemethod#
def validate(plan: object) -> ResidentDiagnosticsPlanValidate one exact diagnostics plan without dispatching a kernel.
Parameters
| Name | Type | Description |
|---|---|---|
plan | object | Candidate concrete diagnostics plan. |
Returns
ResidentDiagnosticsPlan- The unchanged, exact validated plan.
Raises
TypeError- If
planis not an exact diagnostics plan. ValueError- If the plan’s graph, bindings, or registration protocol is invalid.
ResidentDiagnosticsPlanclassdataclass#
class ResidentDiagnosticsPlan(session: ResidentSession, registry: object, graph: ResolvedProcessGraph, schedule: ResolvedTimestepSchedule, node: ProcessNode, registrations: tuple[ResidentDiagnosticRegistration, ...])Bind ordered closed diagnostics to one resident graph and schedule.
Attributes
| Name | Type | Description |
|---|---|---|
session | ResidentSession | Exact active resident session that owns diagnostic sources. |
registry | object | Exact registry pinned to session. |
graph | ResolvedProcessGraph | Resolver-produced graph containing node by identity. |
schedule | ResolvedTimestepSchedule | Matching resolved schedule that ends with node. |
node | ProcessNode | Canonical diagnostics process node. |
registrations | tuple[ResidentDiagnosticRegistration, ...] | Exact canonical tuple of the six ordered closed operation and output bindings, validated by the executor. |
graphattributeinstance attribute#
graph: ResolvedProcessGraphnodeattributeinstance attribute#
node: ProcessNoderegistrationsattributeinstance attribute#
registrations: tuple[ResidentDiagnosticRegistration, ...]registryattributeinstance attribute#
registry: objectscheduleattributeinstance attribute#
schedule: ResolvedTimestepSchedulesessionattributeinstance attribute#
session: ResidentSession__init__method#
def __init__(session: ResidentSession, registry: object, graph: ResolvedProcessGraph, schedule: ResolvedTimestepSchedule, node: ProcessNode, registrations: tuple[ResidentDiagnosticRegistration, ...]) -> None__post_init__method#
def __post_init__() -> NoneValidate exact types for the resident diagnostics binding.
Structural graph, lifecycle, and output validation is deferred to the executor so plan construction does not inspect Warp-array metadata.
Raises
TypeError- If a carrier or registration has an inexact type.
_accumulate_mapped_particle_massfunction#
def _accumulate_mapped_particle_mass(masses: Any, population: Any, output: Any, particle_species: int, gas_species: int) -> NoneAccumulate one explicit material-to-gas extensive inventory lane.
_accumulate_number_densityfunction#
def _accumulate_number_density(concentration: Any, volume: Any, output: Any) -> NoneReduce represented counts to per-volume number concentration.
_clear_particle_numberfunction#
def _clear_particle_number(output: Any) -> NoneClear one particle-number output lane before staged accumulation.
_conservation_residualfunction#
def _conservation_residual(total_mass: Any, baseline: Any, source: Any, sink: Any, output: Any) -> NoneWrite the ledger-aware residual from the already-reduced total mass.
_copy_snapshotfunction#
def _copy_snapshot(source: Any, output: Any) -> NoneCopy one resident diagnostic matrix element to its output.
_enqueue_prepared_resident_diagnosticsfunction#
def _enqueue_prepared_resident_diagnostics(prepared: PreparedResidentDiagnostics) -> NoneDispatch only registrations retained by prepared diagnostics setup.
This private retained-reference seam performs no validation, allocation, readback, transfer, synchronization, lookup, or rebinding. Empty matrix schemas remain write-free; rollback is not promised after a writer launches.
Parameters
| Name | Type | Description |
|---|---|---|
prepared | PreparedResidentDiagnostics | Previously validated immutable diagnostics binding. |
Raises
ValueError- If residual dispatch lacks its bound total-mass output.
_initialize_total_species_massfunction#
def _initialize_total_species_mass(gas_concentration: Any, volume: Any, output: Any) -> NoneInitialize each extensive-mass lane from resident gas.
_mass_pairsfunction#
def _mass_pairs(plan: ResidentDiagnosticsPlan) -> tuple[tuple[int, int], ...]Validate total-mass provenance without device work or inferred lanes.
setup_prepared_resident_diagnosticsfunction#
def setup_prepared_resident_diagnostics(prepared_timestep: object, plan: object) -> PreparedResidentDiagnosticsValidate a declaration diagnostics attachment and bind enqueue identities.
Parameters
| Name | Type | Description |
|---|---|---|
prepared_timestep | object | Exact declaration timestep retaining plan by
identity. |
plan | object | Exact resident diagnostics plan to validate and bind. |
Returns
PreparedResidentDiagnostics- Immutable binding that dispatches the canonical registrations without
PreparedResidentDiagnostics- repeating setup validation.
Raises
TypeError- If either carrier has an unsupported exact type.
ValueError- If declaration identities, plan metadata, registrations, or primary arrays are invalid.
validate_resident_diagnostics_planfunction#
def validate_resident_diagnostics_plan(plan: object) -> ResidentDiagnosticsPlanValidate an exact diagnostics plan without constructing an executor.
This read-only shared validation seam performs no diagnostic dispatch, resource acquisition, payload inspection, transfer, synchronization, or resident-state mutation.
Parameters
| Name | Type | Description |
|---|---|---|
plan | object | Candidate concrete diagnostics plan. |
Returns
ResidentDiagnosticsPlan- The unchanged, exact validated plan.
Raises
TypeError- If
planis not an exact diagnostics plan. ValueError- If its binding, graph, or registration metadata is invalid.