witwin.channel.scene

API reference for scene compilation - compile, CompiledScene and clear_compile_cache.

The four solvers compile the scene for you. Use this module when you call the propagation consumer, which takes a CompiledScene, or when you manage the compile cache.

from witwin.channel.scene import CompiledScene, clear_compile_cache, compile

compile#

compile(scene_or_snapshot, *, reference_frequency_hz) -> CompiledScene

Converts the structures of a witwin.core world to triangles, builds the RayD scene and BVH on the GPU, evaluates the materials at reference_frequency_hz and records the scene's version counters. A second call with the same world and frequency returns the cached compilation.

scene_or_snapshotwitwin.core.Scene | witwin.core.SceneSnapshotrequired

The world to compile.

reference_frequency_hzfloat | torch.Tensorrequired

Frequency in hertz at which the materials are evaluated. Positive. A 0-d tensor is accepted where the consumer route supports frequency gradients.

Returns a CompiledScene.

Raises TypeError or ValueError for an invalid world or frequency, and RuntimeError when CUDA, the native extension or a required RayD capability is missing.

compiled = compile(scene, reference_frequency_hz=3.0e9)
print(compiled.materials.frequency_hz)  # 3000000000.0
print(compiled.time_s)                  # None for a Scene; the snapshot time for a SceneSnapshot

CompiledScene#

The GPU-resident form of one world at one frequency. Treat it as read-only: pass it to the consumer functions and read its version fields. Its stores belong to Channel.

FieldTypeMeaning
sourceScene or SceneSnapshotThe world it was compiled from.
structurestupleCompiled structures, in order.
geometry, materials, assignmentsChannel storesGPU geometry, material table and triangle-to-material assignment. materials.frequency_hz is the compile frequency.
raydRayD scene resourceThe native ray-tracing scene.
reference_frequency_hzfloat or TensorCompile frequency.
reference_frequency_revisionint or NoneRevision of a tensor frequency leaf, if any.
topology_version, geometry_version, material_version, assignment_versionintThe world's version counters at compile time.
time_sfloat, Tensor or NoneSnapshot time, for reporting only.
enumerated_penetration_scene_diagonal_m, montecarlo_penetration_scene_diagonal_mfloatScene size used by the wall-penetration search.

Methods and properties#

MemberKindMeaning
require_reference_frequency(reference_frequency_hz)methodRaises if a request's frequency differs from the compile frequency. Never recompiles.
fixed_reevaluation_tables()methodVertex and material tables used by fixed-topology replay. Read-only.
kirchhoff_resourcespropertyRough-surface scattering tables, built on first access.
phase_screen_resourcespropertyPhase-screen resources, built on first access.
kirchhoff_tablespropertydict[int, KirchhoffTable] keyed by material index.
rough_material_runtimespropertydict[int, RoughMaterialRuntime] keyed by material index.

The four resource members are properties: access them without parentheses (compiled.kirchhoff_tables).

clear_compile_cache#

clear_compile_cache() -> None

Drops every cached compilation in the process. CompiledScene objects you still hold stay valid. Call it in tests or after you discard a large world, to free GPU memory.