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, compilecompile#
compile(scene_or_snapshot, *, reference_frequency_hz) -> CompiledSceneConverts 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.
The world to compile.
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 SceneSnapshotCompiledScene#
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.
| Field | Type | Meaning |
|---|---|---|
source | Scene or SceneSnapshot | The world it was compiled from. |
structures | tuple | Compiled structures, in order. |
geometry, materials, assignments | Channel stores | GPU geometry, material table and triangle-to-material assignment. materials.frequency_hz is the compile frequency. |
rayd | RayD scene resource | The native ray-tracing scene. |
reference_frequency_hz | float or Tensor | Compile frequency. |
reference_frequency_revision | int or None | Revision of a tensor frequency leaf, if any. |
topology_version, geometry_version, material_version, assignment_version | int | The world's version counters at compile time. |
time_s | float, Tensor or None | Snapshot time, for reporting only. |
enumerated_penetration_scene_diagonal_m, montecarlo_penetration_scene_diagonal_m | float | Scene size used by the wall-penetration search. |
Methods and properties#
| Member | Kind | Meaning |
|---|---|---|
require_reference_frequency(reference_frequency_hz) | method | Raises if a request's frequency differs from the compile frequency. Never recompiles. |
fixed_reevaluation_tables() | method | Vertex and material tables used by fixed-topology replay. Read-only. |
kirchhoff_resources | property | Rough-surface scattering tables, built on first access. |
phase_screen_resources | property | Phase-screen resources, built on first access. |
kirchhoff_tables | property | dict[int, KirchhoffTable] keyed by material index. |
rough_material_runtimes | property | dict[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() -> NoneDrops 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.