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) -> DfrAccum

First-order Monte Carlo diffraction onto a grid.

statesDfrStates | DfrStatesADrequired

One row per wedge and source.

gridDfrGridrequired

Receiver grid.

materialDfrMaterial | DfrMaterialADrequired

Material per scene-global primitive.

optionsDfrOptionsdefault DfrOptions()

Wave and sampling parameters.

activeBooldefault True

State 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) -> DfrAccum

Higher-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) -> DfrCoherentAccum

Exact 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) -> DfrCoherentUtdStates

Builds 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) -> DfrCoherentCandidatePairs

Finds 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) -> DfrPaths

Exports explicit diffraction paths between transmitters and receivers.

tx_positionsArray3frequired

Transmitter positions.

rx_positionsArray3frequired

Receiver positions.

statesDfrStatesrequired

Wedge states.

materialDfrMaterialrequired

Material per primitive.

optionsDfrPathOptionsdefault DfrPathOptions()

Output size and wave parameters.

activeBooldefault True

Mask.

DfrStates#

Inputs: one row per wedge and source. Construct with DfrStates() and assign the fields; set count to the row count.

FieldDefaultMeaning
count0number of rows
edge_index-1edge id, for bookkeeping
edge_pos, edge_dirzerosedge line edge_pos + t * edge_dir
edge_t_min, edge_t_max0parameter range of the edge segment
n0, n1zerosnormals of the two wedge faces
prim0, prim1-1global primitive ids of the two faces, or -1
exterior_angle0wedge exterior angle in radians
src, src_powerzeros, 0source position and power illuminating the edge
wi, d0zerosincident and initial directions
prefix_depth0reflections 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#

FieldDefaultMeaning
wavelength1wavelength in scene units
k0wavenumber, 2 * pi / wavelength
seed0random seed
samples0sample count
max_order1diffraction order for accum_dfr
direct_samples, keller_samples, suffix_samples0samples per strategy
strategy_mask3RAYD_DFR_DIRECT | RAYD_DFR_KELLER | RAYD_DFR_SUFFIX_REFL bits
sample_sequence0RAYD_DFR_HASH or RAYD_DFR_SOBOL
receiver_model0RAYD_DFR_MATCHED_ISO
collect_edge_useFalsefill edge_uses
collect_debug_countsFalsefill the rejection counters

DfrCoherentOptions#

FieldDefaultMeaning
wavelength, k1, 0wave parameters
max_order1coherent chain order
receiver_model0RAYD_DFR_MATCHED_ISO
select_diffraction_pointTruechoose the diffraction point on each edge per cell
prefilter_visibilityTrueapply a visibility prefilter
collect_debug_countsFalsefill the reject counters
omega0angular frequency in rad/s
tx_pol_x, tx_pol_y, tx_pol_z1, 0, 0transmitter polarization
higher_probe_radius_scale0.6probe radius scale for higher-order candidates
higher_probe_radius_min, higher_probe_radius_max0.5, 4.0probe radius bounds
higher_filter_visibilityFalsefilter higher-order candidates by visibility

DfrPathOptions#

FieldDefaultMeaning
wavelength, k1, 0wave parameters
seed0random seed
sample_count0sample count
max_order1diffraction order
max_paths, max_rx0output buffer sizing
strategy_mask1RAYD_DFR_DIRECT
receiver_model0RAYD_DFR_MATCHED_ISO
return_geom0nonzero 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).