Utility Functions
Complex-valued tensors
- sionna.rt.utils.cpx_abs(x)[source]
Element-wise absolute value of a complex-valued tensor
The tensor is represented as a tuple of two real-valued tensors, corresponding to the real and imaginary part, respectively.
- Parameters:
x (
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]) – A tensor- Return type:
drjit.cuda.ad.TensorXf
- sionna.rt.utils.cpx_abs_square(x)[source]
Element-wise absolute squared value of a complex-valued tensor
The tensor is represented as a tuple of two real-valued tensors, corresponding to the real and imaginary part, respectively.
- Parameters:
x (
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]) – A tensor- Return type:
drjit.cuda.ad.TensorXf
- sionna.rt.utils.cpx_add(a, b)[source]
Element-wise addition of two complex-valued tensors
Each tensor is represented as a tuple of two real-valued tensors, corresponding to the real and imaginary part, respectively.
- Parameters:
a (
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]) – First tensorb (
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]) – Second tensor
- Return type:
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]
- sionna.rt.utils.cpx_convert(x, out_type)[source]
Converts a complex-valued tensor to any of the supported frameworks
The tensor is represented as a tuple of two real-valued tensors, corresponding to the real and imaginary part, respectively.
Note that the chosen framework must be installed for this function to work.
- Parameters:
x (
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]) – A tensorout_type (
typing.Literal
['numpy'
,'jax'
,'tf'
,'torch'
]) – Name of the target framework. Currently supported are Numpy (“numpy”), Jax (“jax”), TensorFlow (“tf”), and PyTorch (“torch”).
- Return type:
np.array
|jax.array
|tf.Tensor
|torch.tensor
- sionna.rt.utils.cpx_div(a, b)[source]
Element-wise division of a complex-valued tensor by another
Each tensor is represented as a tuple of two real-valued tensors, corresponding to the real and imaginary part, respectively.
- Parameters:
a (
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]) – First tensorb (
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]) – Second tensor by which the first is divided
- Return type:
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]
- sionna.rt.utils.cpx_exp(x)[source]
Element-wise exponential of a complex-valued tensor
The tensor is represented as a tuple of two real-valued tensors, corresponding to the real and imaginary part, respectively.
- Parameters:
x (
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]) – A tensor- Return type:
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]
- sionna.rt.utils.cpx_mul(a, b)[source]
Element-wise multiplication of two complex-valued tensors
Each tensor is represented as a tuple of two real-valued tensors, corresponding to the real and imaginary part, respectively.
- Parameters:
a (
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]) – First tensorb (
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]) – Second tensor
- Return type:
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]
- sionna.rt.utils.cpx_sqrt(x)[source]
Element-wise square root of a complex-valued tensor
The tensor is represented as a tuple of two real-valued tensors, corresponding to the real and imaginary part, respectively.
The following formula is implemented to compute the square roots of complex numbers: https://en.wikipedia.org/wiki/Square_root#Algebraic_formula
- Parameters:
x (
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]) – A tensor- Return type:
drjit.cuda.ad.TensorXf
- sionna.rt.utils.cpx_sub(a, b)[source]
Element-wise substraction of a complex-valued tensor from another
Each tensor is represented as a tuple of two real-valued tensors, corresponding to the real and imaginary part, respectively.
- Parameters:
a (
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]) – First tensorb (
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]) – Second tensor which is substracted from the first
- Return type:
typing.Tuple
[drjit.cuda.ad.TensorXf
,drjit.cuda.ad.TensorXf
]
Electromagnetics
- sionna.rt.utils.complex_relative_permittivity(eta_r, sigma, omega)[source]
Computes the complex relative permittivity of a material as defined in (9)
- Parameters:
eta_r (
drjit.cuda.ad.Float
) – Real component of the relative permittivitysigma (
drjit.cuda.ad.Float
) – Conductivity [S/m]omega (
drjit.cuda.ad.Float
) – Angular frequency [rad/s]
- Return type:
drjit.cuda.ad.Complex2f
- sionna.rt.utils.fresnel_reflection_coefficients_simplified(cos_theta, eta)[source]
Computes the Fresnel transverse electric and magnetic reflection coefficients assuming an incident wave propagating in vacuum (34)
- Parameters:
cos_theta (
drjit.cuda.ad.Float
) – Cosine of the angle of incidenceeta (
drjit.cuda.ad.Complex2f
) – Complex-valued relative permittivity of the medium upon which the wave is incident
- Return type:
typing.Tuple
[drjit.cuda.ad.Complex2f
,drjit.cuda.ad.Complex2f
]- Returns:
Transverse electric
and magnetic Fresnel reflection coefficients
- sionna.rt.utils.itu_coefficients_single_layer_slab(cos_theta, eta, d, wavelength)[source]
Computes the single-layer slab Fresnel transverse electric and magnetic reflection and refraction coefficients assuming the incident wave propagates in vacuum using recommendation ITU-R P.2040 [ITU_R_2040_3]
More precisely, this function implements equations (43) and (44) from [ITU_R_2040_3].
- Parameters:
cos_theta (
drjit.cuda.ad.Float
) – Cosine of the angle of incidenceeta (
drjit.cuda.ad.Complex2f
) – Complex-valued relative permittivity of the medium upon which the wave is incidentd (
drjit.cuda.ad.Float
) – Thickness of the slab [m]wavelength (
drjit.cuda.ad.Float
) – Wavelength [m]
- Return type:
typing.Tuple
[drjit.cuda.ad.Complex2f
,drjit.cuda.ad.Complex2f
,drjit.cuda.ad.Complex2f
,drjit.cuda.ad.Complex2f
]- Returns:
Transverse electric reflection coefficient
, transverse magnetic reflection coefficient , transverse electric refraction coefficient , and transverse magnetic refraction coefficient
Geometry
- sionna.rt.utils.phi_hat(phi)[source]
Computes the spherical unit vector
as defined in (1)- Parameters:
phi (
drjit.cuda.ad.Float
) – Azimuth angle [rad]- Return type:
mitsuba.Vector3f
- sionna.rt.utils.theta_hat(theta, phi)[source]
Computes the spherical unit vector
as defined in (1)- Parameters:
theta (
drjit.cuda.ad.Float
) – Zenith angle [rad]phi (
drjit.cuda.ad.Float
) – Azimuth angle [rad]
- Return type:
mitsuba.Vector3f
- sionna.rt.utils.r_hat(theta, phi)[source]
Computes the spherical unit vetor
as defined in (1)- Parameters:
theta (
drjit.cuda.ad.Float
) – Zenith angle [rad]phi (
drjit.cuda.ad.Float
) – Azimuth angle [rad]
- Return type:
mitsuba.Vector3f
- sionna.rt.utils.theta_phi_from_unit_vec(v)[source]
Computes zenith and azimuth angles (
) from unit-norm vectors as described in (2)- Parameters:
v (
mitsuba.Vector3f
) – Unit vector- Return type:
typing.Tuple
[drjit.cuda.ad.Float
,drjit.cuda.ad.Float
]- Returns:
Zenith angle
[rad] and azimuth angle [rad]
- sionna.rt.utils.rotation_matrix(angles)[source]
Computes the rotation matrix as defined in (3)
The closed-form expression in (7.1-4) [TR38901] is used.
- Parameters:
angles (
mitsuba.Point3f
) – Angles for the rotations [rad] that define rotations about the axes , respectively- Return type:
drjit.cuda.ad.Matrix3f
Jones calculus
- sionna.rt.utils.implicit_basis_vector(k)[source]
Returns a reference frame basis vector for a Jones vector, representing a transverse wave propagating in direction
k
The spherical basis vector
(1) is used as basis vector, where the zenith and azimuth angles are obtained from the unit vectork
.- Parameters:
k (
mitsuba.Vector3f
) – A unit vector corresponding to the direction of propagation of a transverse wave- Return type:
mitsuba.Vector3f
- Returns:
A basis vector orthogonal to
k
- sionna.rt.utils.jones_matrix_rotator(k, s_current, s_target)[source]
Constructs the 2D change-of-basis matrix to rotate the reference frame of a Jones vector representing a transverse wave propagating in direction
k
from basis vectors_current
to basis vectors_target
- Parameters:
k (
mitsuba.Vector3f
) – Direction of propagation as a unit vectors_current (
mitsuba.Vector3f
) – Current basis vector as a unit vectors_target (
mitsuba.Vector3f
) – Target basis vector as a unit vector
- Return type:
drjit.cuda.ad.Matrix2f
- sionna.rt.utils.jones_matrix_rotator_flip_forward(k)[source]
Constructs the 2D change-of-basis matrix that flips the direction of propagation of the reference frame of a Jones vector representing a transverse wave from the basis vector corresponding to
k
to the one corresponding to-k
This is useful to evaluate the antenna pattern of a receiver, as the pattern needs to be rotated to match the frame in which the incident wave is represented.
Note that the rotation matrix returned by this function is a diagonal matrix:
where:
and
and are the basis vectors corresponding tok
and-k
, respectively, and computed usingimplicit_basis_vector()
.- Parameters:
k (
mitsuba.Vector3f
) – Current direction of propagation as a unit vector- Return type:
drjit.cuda.ad.Matrix2f
- sionna.rt.utils.to_world_jones_rotator(to_world, k_local)[source]
Constructs the 2D change-of-basis matrix to rotate the reference frame of a Jones vector representing a transverse wave with
k_local
as direction of propagation from the local implicit frame to the world implicit frame- Parameters:
to_world (
drjit.cuda.ad.Matrix3f
) – Change-of-basis matrix from the local to the world framek_local (
mitsuba.Vector3f
) – Direction of propagation in the local frame as a unit vector
- Return type:
drjit.cuda.ad.Matrix2f
- sionna.rt.utils.jones_matrix_to_world_implicit(c1, c2, to_world, k_in_local, k_out_local)[source]
Builds the Jones matrix that models a specular reflection or a refraction
c1
andc2
are Fresnel coefficients that depend on the composition of the scatterer.k_in_local
andk_out_local
are the direction of propagation of the incident and scattered wave, respectively, represented in the local frame of the interaction. Note that in the local frame of the interaction, the z-axis vector corresponds to the normal to the scatterer surface at the interaction point.The returned matrix operates on the incident wave represented in the implicit world frame. The resulting scattered wave is also represented in the implicit world frame. This is ensured by applying a left and right rotation matrix to the 2x2 diagonal matrix containing the Fresnel coefficients, which operates on the local frame having the transverse electric component as basis vector:
where:
and
( ) is the change-of-basis matrix from the local frame using the transverse electric direction as basis vector to the world implicit frame for the incident (scattered) wave.This function returns the
real-valued matrix equivalent to :where
is the returned matrix and and the real and imaginary components of , respectively.- Parameters:
c1 (
drjit.cuda.ad.Complex2f
) – First complex-valued Fresnel coefficientc2 (
drjit.cuda.ad.Complex2f
) – Second complex-valued Fresnel coefficientto_world (
drjit.cuda.ad.Matrix3f
) – Change-of-basis matrix from the local to the world framek_in_local (
mitsuba.Vector3f
) – Direction of propagation of the incident wave in the local frame as a unit vectork_out_local (
mitsuba.Vector3f
) – Direction of propagation of the scattered wave in the local frame as a unit vector
- Return type:
drjit.cuda.ad.Matrix4f
- sionna.rt.utils.jones_vec_dot(u, v)[source]
Computes the dot product of two Jones vectors
andA Jones vector is assumed to be represented by a real-valued vector of four dimensions, obtained by concatenating its real and imaginary components. The returned array is complex-valued.
More precisely, the following formula is implemented:
- Parameters:
u (
mitsuba.Vector4f
) – First input vectorv (
mitsuba.Vector4f
) – Second input vector
- Return type:
drjit.cuda.ad.Complex2f
Miscellaneous
- sionna.rt.utils.complex_sqrt(x)[source]
Computes the square root of a complex number
The following formula is implemented to compute the square roots of complex numbers: https://en.wikipedia.org/wiki/Square_root#Algebraic_formula
- Parameters:
x (
drjit.cuda.ad.Complex2f
) – Complex number- Return type:
drjit.cuda.ad.Complex2f
- sionna.rt.utils.dbm_to_watt(x)[source]
Converts dBm to Watt
Implements the following formula:
- Parameters:
x (
drjit.cuda.ad.Float
) – Power [dBm]- Return type:
drjit.cuda.ad.Float
- sionna.rt.utils.isclose(a, b, rtol=1e-05, atol=1e-08)[source]
Returns an array of boolean in which an element is set to True if the corresponding entries in
a
andb
are equal within a toleranceMore precisely, this function returns True for the
element if:- Parameters:
a (
drjit.cuda.ad.Float
) – First input array to compareb (
drjit.cuda.ad.Float
) – Second input array to comparertol (
drjit.cuda.ad.Float
) – Relative error thresholdatol (
drjit.cuda.ad.Float
) – Absolute error threshold
- Return type:
drjit.cuda.ad.Bool
- sionna.rt.utils.log10(x)[source]
Evaluates the base-10 logarithm
- Parameters:
x (
drjit.cuda.ad.Float
) – Input value- Return type:
drjit.cuda.ad.Float
- sionna.rt.utils.sigmoid(x)[source]
Evaluates the sigmoid of
x
- Parameters:
x (
drjit.cuda.ad.Float
) – Input value- Return type:
drjit.cuda.ad.Float
- sionna.rt.utils.sinc(x)[source]
Evaluates the normalized sinc function
The sinc function is defined as
for any and equals for .- Return type:
drjit.cuda.ad.Float
- Parameters:
x (Float)
- sionna.rt.utils.subcarrier_frequencies(num_subcarriers, subcarrier_spacing)[source]
Compute the baseband frequencies of
num_subcarrier
subcarriers spaced bysubcarrier_spacing
, i.e.,>>> # If num_subcarrier is even: >>> frequencies = [-num_subcarrier/2, ..., 0, ..., num_subcarrier/2-1] * subcarrier_spacing >>> >>> # If num_subcarrier is odd: >>> frequencies = [-(num_subcarrier-1)/2, ..., 0, ..., (num_subcarrier-1)/2] * subcarrier_spacing
- Parameters:
num_subcarriers (
int
) – Number of subcarrierssubcarrier_spacing (
float
) – Subcarrier spacing [Hz]
- Return type:
drjit.cuda.ad.Float
- Returns:
Baseband frequencies of subcarriers
Ray tracing
- sionna.rt.utils.fibonacci_lattice(num_points)[source]
Generates a Fibonacci lattice of size
num_points
on the unit square- Parameters:
num_points (
int
) – Size of the lattice- Return type:
mitsuba.Point2f
- sionna.rt.utils.spawn_ray_from_sources(lattice, samples_per_src, src_positions)[source]
Spawns
samples_per_src
rays for each source at the positions specified bysrc_positions
, oriented in the directions defined by thelattice
The spawned rays are ordered samples-first.
- Parameters:
lattice (
typing.Callable
[[int
],mitsuba.Point2f
]) – Callable that generates the lattice used as directions for the rayssamples_per_src (
int
) – Number of rays per source to spawnsrc_positions (
mitsuba.Point3f
) – Positions of the sources
- Return type:
mitsuba.Ray3f
- sionna.rt.utils.offset_p(p, d, n)[source]
Adds a small offset to
along such thatMore precisely, this function returns
such that:where
depends on the numerical precision and .- Parameters:
p (
mitsuba.Point3f
) – Point to offsetd (
mitsuba.Vector3f
) – Direction toward which to offset alongn
n (
mitsuba.Vector3f
) – Direction along which to offset
- Return type:
mitsuba.Point3f
- sionna.rt.utils.spawn_ray_towards(p, t, n=None)[source]
Spawns a ray with infinite length from
towardIf
is notNone
, then a small offset is added to along in the direction of .- Parameters:
p (
mitsuba.Point3f
) – Origin of the rayt (
mitsuba.Point3f
) – Point towards which to spawn the rayn (
typing.Optional
[mitsuba.Vector3f
]) – (Optional) Direction along which to offset
- Return type:
mitsuba.Ray3f
- sionna.rt.utils.spawn_ray_to(p, t, n=None)[source]
Spawns a finite ray from
toThe length of the ray is set to
.If
is notNone
, then a small offset is added to along in the direction of .- Parameters:
p (
mitsuba.Point3f
) – Origin of the rayt (
mitsuba.Point3f
) – Point towards which to spawn the rayn (
typing.Optional
[mitsuba.Vector3f
]) – (Optional) Direction along which to offset
- Return type:
mitsuba.Ray3f
- References:
- [ITU_R_2040_3]
Recommendation ITU-R P.2040-3, “Effects of building materials and structures on radiowave propagation above about 100 MHz”
[TR38901]3GPP TR 38.901, “Study on channel model for frequencies from 0.5 to 100 GHz”, Release 18.0