Diffraction (Dr.Jit)
rayd.drjit diffraction API - Monte Carlo and coherent grid accumulation, explicit diffraction paths, wedge states, options, materials, and result records.
These rayd.drjit.Scene methods evaluate edge diffraction from wedge states that you supply. For a walkthrough, see Compute edge diffraction. Detached inputs return detached records; AD inputs (DfrStatesAD, DfrMaterialAD) return the ...AD records.
Scene.accum_dfr_direct#
accum_dfr_direct(states: DfrStates, grid: DfrGrid, material: DfrMaterial, options: DfrOptions = DfrOptions(), active=True) -> DfrAccumFirst-order Monte Carlo diffraction onto a grid.
One row per wedge and source.
Receiver grid.
Material per scene-global primitive.
DfrOptions()Wave and sampling parameters.
TrueState mask.
acc = scene.accum_dfr_direct(states, grid, material, options)
print(acc.power, acc.direct_count)Scene.accum_dfr#
accum_dfr(initial_states: DfrStates, recursive_states: DfrStates, grid: DfrGrid, material: DfrMaterial, options: DfrOptions = DfrOptions(), active=True) -> DfrAccumHigher-order diffraction chains (order 2 or 3, set by options.max_order). initial_states start the chains and recursive_states supply the wedges for the later orders.
Scene.accum_dfr_coherent_direct#
accum_dfr_coherent_direct(states: DfrStates, grid: DfrGrid, material: DfrMaterial, options: DfrCoherentOptions = DfrCoherentOptions(), active=True) -> DfrCoherentAccumExact coherent first-order diffraction: one diffraction point per edge and cell, complex field summed coherently. No random samples and no derivatives.
Scene.build_dfr_coherent_tx_states#
build_dfr_coherent_tx_states(edges: DfrCoherentEdge, tx_position, material: DfrMaterial, options: DfrCoherentOptions = DfrCoherentOptions(), active=True) -> DfrCoherentUtdStatesBuilds coherent diffraction states for the edges in edges, lit directly by a transmitter at tx_position.
Scene.build_dfr_coherent_higher_candidates#
build_dfr_coherent_higher_candidates(prev_states: DfrCoherentUtdStates, edges: DfrCoherentEdge, global_to_local_edge_index, options: DfrCoherentOptions = DfrCoherentOptions(), active=True) -> DfrCoherentCandidatePairsFinds candidate pairs (a previous state, a next edge) for higher-order coherent chains. global_to_local_edge_index maps scene-global edge ids to rows of edges. The higher_* options set the probe radius and visibility filtering.
Scene.trace_dfr_paths#
trace_dfr_paths(tx_positions: Array3f, rx_positions: Array3f, states: DfrStates, material: DfrMaterial, options: DfrPathOptions = DfrPathOptions(), active=True) -> DfrPathsExports explicit diffraction paths between transmitters and receivers.
Transmitter positions.
Receiver positions.
Wedge states.
Material per primitive.
DfrPathOptions()Output size and wave parameters.
TrueMask.
DfrStates#
Inputs: one row per wedge and source. Construct with DfrStates() and assign the fields; set count to the row count.
| Field | Default | Meaning |
|---|---|---|
count | 0 | number of rows |
edge_index | -1 | edge id, for bookkeeping |
edge_pos, edge_dir | zeros | edge line edge_pos + t * edge_dir |
edge_t_min, edge_t_max | 0 | parameter range of the edge segment |
n0, n1 | zeros | normals of the two wedge faces |
prim0, prim1 | -1 | global primitive ids of the two faces, or -1 |
exterior_angle | 0 | wedge exterior angle in radians |
src, src_power | zeros, 0 | source position and power illuminating the edge |
wi, d0 | zeros | incident and initial directions |
prefix_depth | 0 | reflections before the edge |
Every array default has one entry; assign arrays of length count.
DfrGrid#
AccumGrid fields (axis, position, coord0_min, coord0_max, coord1_min, coord1_max, resolution0, resolution1) plus cell_area (default 1). See AccumGrid.
DfrMaterial, DfrMaterialAD#
Same fields as Material: eta_r (1), sigma (0), mu_r (1), gain (1), valid (False), one entry per scene-global primitive.
DfrOptions#
| Field | Default | Meaning |
|---|---|---|
wavelength | 1 | wavelength in scene units |
k | 0 | wavenumber, 2 * pi / wavelength |
seed | 0 | random seed |
samples | 0 | sample count |
max_order | 1 | diffraction order for accum_dfr |
direct_samples, keller_samples, suffix_samples | 0 | samples per strategy |
strategy_mask | 3 | RAYD_DFR_DIRECT | RAYD_DFR_KELLER | RAYD_DFR_SUFFIX_REFL bits |
sample_sequence | 0 | RAYD_DFR_HASH or RAYD_DFR_SOBOL |
receiver_model | 0 | RAYD_DFR_MATCHED_ISO |
collect_edge_use | False | fill edge_uses |
collect_debug_counts | False | fill the rejection counters |
DfrCoherentOptions#
| Field | Default | Meaning |
|---|---|---|
wavelength, k | 1, 0 | wave parameters |
max_order | 1 | coherent chain order |
receiver_model | 0 | RAYD_DFR_MATCHED_ISO |
select_diffraction_point | True | choose the diffraction point on each edge per cell |
prefilter_visibility | True | apply a visibility prefilter |
collect_debug_counts | False | fill the reject counters |
omega | 0 | angular frequency in rad/s |
tx_pol_x, tx_pol_y, tx_pol_z | 1, 0, 0 | transmitter polarization |
higher_probe_radius_scale | 0.6 | probe radius scale for higher-order candidates |
higher_probe_radius_min, higher_probe_radius_max | 0.5, 4.0 | probe radius bounds |
higher_filter_visibility | False | filter higher-order candidates by visibility |
DfrPathOptions#
| Field | Default | Meaning |
|---|---|---|
wavelength, k | 1, 0 | wave parameters |
seed | 0 | random seed |
sample_count | 0 | sample count |
max_order | 1 | diffraction order |
max_paths, max_rx | 0 | output buffer sizing |
strategy_mask | 1 | RAYD_DFR_DIRECT |
receiver_model | 0 | RAYD_DFR_MATCHED_ISO |
return_geom | 0 | nonzero fills the geometry fields p0 to p2 |
DfrAccum#
grid_cell_count; per cell power and complex field_x, field_y, field_z; counters direct_count, keller_count, suffix_count; rejection counters vis_rejects, edge_vis_rejects, utd_rejects; and edge_uses.
DfrCoherentAccum#
grid_cell_count; per cell complex direct_field_x, direct_field_y, direct_field_z and multi_field_x, multi_field_y, multi_field_z (higher order); counters direct_count, multi_count, visibility_reject_count, utd_reject_count.
DfrPaths#
capacity (rows) and per row: count, valid, tx_id, rx_id, order, edge0, edge1, edge2 (edges used, -1 when unused), delay (seconds), complex field_x, field_y, field_z, and diffraction points p0, p1, p2 (with return_geom).
Coherent tables#
These records feed the coherent builders. Their fields are low-level and listed here for completeness.
DfrCoherentEdge:count,edge_index,edge_pos,edge_dir,edge_line_min,edge_line_max,n0,n_face_n,wedge_n,adjacent_face0,adjacent_face1,ignore_prim_ids,ignore_k.DfrCoherentCandidatePairs:count,prev_index,edge_index,visibility_filtered.DfrCoherentUtdStates:count, the edge fields above,source_pos,first_interaction_pos,incident_field,incident_jones_u,incident_jones_v,path_length_prefix,order, per-face material and operator fields (face0_*,face1_*), incident basis and derivative fields, and reflection depths (prefix_reflection_depth,intermediate_reflection_depth,suffix_reflection_depth).