differt 0.9.0__tar.gz → 0.10.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {differt-0.9.0 → differt-0.10.0}/.gitignore +3 -2
- {differt-0.9.0 → differt-0.10.0}/PKG-INFO +4 -4
- {differt-0.9.0 → differt-0.10.0}/README.md +1 -1
- {differt-0.9.0 → differt-0.10.0}/pyproject.toml +2 -2
- {differt-0.9.0 → differt-0.10.0}/src/differt/em/__init__.py +8 -8
- {differt-0.9.0 → differt-0.10.0}/src/differt/em/_antenna.py +11 -13
- {differt-0.9.0 → differt-0.10.0}/src/differt/em/_fresnel.py +27 -27
- {differt-0.9.0 → differt-0.10.0}/src/differt/em/_material.py +2 -2
- {differt-0.9.0 → differt-0.10.0}/src/differt/em/_utd.py +18 -19
- {differt-0.9.0 → differt-0.10.0}/src/differt/em/_utils.py +44 -45
- differt-0.10.0/src/differt/geometry/__init__.py +108 -0
- differt-0.9.0/src/differt/geometry/_triangle_mesh.py → differt-0.10.0/src/differt/geometry/_mesh.py +159 -351
- {differt-0.9.0 → differt-0.10.0}/src/differt/geometry/_paths.py +248 -140
- differt-0.9.0/src/differt/scene/_triangle_scene.py → differt-0.10.0/src/differt/geometry/_scene.py +713 -645
- {differt-0.9.0/src/differt/scene → differt-0.10.0/src/differt/geometry}/_sionna.py +3 -3
- differt-0.9.0/src/differt/rt/_fermat.py → differt-0.10.0/src/differt/geometry/_solver_fermat.py +59 -63
- differt-0.9.0/src/differt/rt/_image_method.py → differt-0.10.0/src/differt/geometry/_solver_image_method.py +82 -85
- differt-0.10.0/src/differt/geometry/_solvers.py +1262 -0
- differt-0.10.0/src/differt/geometry/_utils.py +1960 -0
- {differt-0.9.0 → differt-0.10.0}/src/differt/plotting/_core.py +126 -21
- {differt-0.9.0 → differt-0.10.0}/src/differt/plotting/_utils.py +13 -11
- {differt-0.9.0 → differt-0.10.0}/src/differt/plugins/deepmimo.py +15 -17
- differt-0.10.0/src/differt/rt/__init__.py +45 -0
- differt-0.10.0/src/differt/scene/__init__.py +45 -0
- differt-0.9.0/src/differt/geometry/__init__.py +0 -45
- differt-0.9.0/src/differt/geometry/_utils.py +0 -859
- differt-0.9.0/src/differt/rt/__init__.py +0 -36
- differt-0.9.0/src/differt/rt/_utils.py +0 -988
- differt-0.9.0/src/differt/scene/__init__.py +0 -11
- {differt-0.9.0 → differt-0.10.0}/LICENSE.md +0 -0
- {differt-0.9.0 → differt-0.10.0}/src/differt/__init__.py +0 -0
- {differt-0.9.0 → differt-0.10.0}/src/differt/_version.py +0 -0
- {differt-0.9.0 → differt-0.10.0}/src/differt/em/_constants.py +0 -0
- {differt-0.9.0 → differt-0.10.0}/src/differt/em/_interaction_type.py +0 -0
- {differt-0.9.0 → differt-0.10.0}/src/differt/plotting/__init__.py +0 -0
- {differt-0.9.0 → differt-0.10.0}/src/differt/plugins/__init__.py +0 -0
- {differt-0.9.0 → differt-0.10.0}/src/differt/plugins/_deepmimo_types.py +0 -0
- {differt-0.9.0 → differt-0.10.0}/src/differt/py.typed +0 -0
- {differt-0.9.0 → differt-0.10.0}/src/differt/utils.py +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Python build files and cache
|
|
2
2
|
|
|
3
3
|
*.pyc
|
|
4
|
+
*.pyd
|
|
4
5
|
*.so
|
|
5
6
|
*.egg-info
|
|
6
7
|
|
|
@@ -15,8 +16,8 @@ docs/source/reference/_autosummary/
|
|
|
15
16
|
|
|
16
17
|
# Sionna data
|
|
17
18
|
|
|
18
|
-
differt/src/differt/
|
|
19
|
-
differt/src/differt/
|
|
19
|
+
differt/src/differt/geometry/scenes.lock
|
|
20
|
+
differt/src/differt/geometry/scenes/
|
|
20
21
|
|
|
21
22
|
# Notebooks
|
|
22
23
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: DiffeRT
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.10.0
|
|
4
4
|
Summary: Differentiable Ray Tracing Toolbox for Radio Propagation Simulations
|
|
5
5
|
Project-URL: Changelog, https://github.com/jeertmans/DiffeRT/releases
|
|
6
6
|
Project-URL: Documentation, https://eertmans.be/DiffeRT
|
|
@@ -20,7 +20,7 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
20
20
|
Classifier: Topic :: Scientific/Engineering
|
|
21
21
|
Requires-Python: >=3.11
|
|
22
22
|
Requires-Dist: chex>=0.1.86
|
|
23
|
-
Requires-Dist: differt-core==0.
|
|
23
|
+
Requires-Dist: differt-core==0.10.0
|
|
24
24
|
Requires-Dist: equinox>=0.13.7
|
|
25
25
|
Requires-Dist: filelock>=3.15.4
|
|
26
26
|
Requires-Dist: fpt-jax==0.1.0
|
|
@@ -29,7 +29,7 @@ Requires-Dist: jaxtyping>=0.3.11
|
|
|
29
29
|
Requires-Dist: numpy>=1.26.1
|
|
30
30
|
Requires-Dist: requests>=2.32.0
|
|
31
31
|
Requires-Dist: tqdm>=4.66.2
|
|
32
|
-
Requires-Dist: warp-lang>=1.
|
|
32
|
+
Requires-Dist: warp-lang>=1.16.0
|
|
33
33
|
Provides-Extra: all
|
|
34
34
|
Requires-Dist: ipykernel<7; extra == 'all'
|
|
35
35
|
Requires-Dist: ipympl>=0.9.4; extra == 'all'
|
|
@@ -156,7 +156,7 @@ or:
|
|
|
156
156
|
author = {Eertmans, Jérome},
|
|
157
157
|
url = {https://github.com/jeertmans/DiffeRT},
|
|
158
158
|
license = {MIT},
|
|
159
|
-
version = {v0.
|
|
159
|
+
version = {v0.10.0}
|
|
160
160
|
}
|
|
161
161
|
```
|
|
162
162
|
|
|
@@ -15,7 +15,7 @@ classifiers = [
|
|
|
15
15
|
]
|
|
16
16
|
dependencies = [
|
|
17
17
|
"chex>=0.1.86",
|
|
18
|
-
"differt-core==0.
|
|
18
|
+
"differt-core==0.10.0",
|
|
19
19
|
"equinox>=0.13.7",
|
|
20
20
|
"filelock>=3.15.4",
|
|
21
21
|
"fpt-jax==0.1.0",
|
|
@@ -24,7 +24,7 @@ dependencies = [
|
|
|
24
24
|
"numpy>=1.26.1",
|
|
25
25
|
"requests>=2.32.0",
|
|
26
26
|
"tqdm>=4.66.2",
|
|
27
|
-
"warp-lang>=1.
|
|
27
|
+
"warp-lang>=1.16.0",
|
|
28
28
|
]
|
|
29
29
|
description = "Differentiable Ray Tracing Toolbox for Radio Propagation Simulations"
|
|
30
30
|
dynamic = ["readme", "version"]
|
|
@@ -17,17 +17,17 @@ __all__ = (
|
|
|
17
17
|
"epsilon_0",
|
|
18
18
|
"fresnel_coefficients",
|
|
19
19
|
"fspl",
|
|
20
|
-
"
|
|
20
|
+
"length_to_delay",
|
|
21
21
|
"materials",
|
|
22
22
|
"mu_0",
|
|
23
|
-
"
|
|
23
|
+
"path_delay",
|
|
24
24
|
"poynting_vector",
|
|
25
25
|
"reflection_coefficients",
|
|
26
26
|
"refraction_coefficients",
|
|
27
|
-
"
|
|
27
|
+
"refractive_index",
|
|
28
28
|
"sp_directions",
|
|
29
29
|
"sp_rotation_matrix",
|
|
30
|
-
"
|
|
30
|
+
"transition_matrix",
|
|
31
31
|
"z_0",
|
|
32
32
|
)
|
|
33
33
|
|
|
@@ -46,16 +46,16 @@ from ._fresnel import (
|
|
|
46
46
|
fresnel_coefficients,
|
|
47
47
|
reflection_coefficients,
|
|
48
48
|
refraction_coefficients,
|
|
49
|
-
|
|
49
|
+
refractive_index,
|
|
50
50
|
)
|
|
51
51
|
from ._interaction_type import InteractionType
|
|
52
52
|
from ._material import Material, materials
|
|
53
53
|
from ._utd import F, L_i, diffraction_coefficients
|
|
54
54
|
from ._utils import (
|
|
55
55
|
fspl,
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
length_to_delay,
|
|
57
|
+
path_delay,
|
|
58
58
|
sp_directions,
|
|
59
59
|
sp_rotation_matrix,
|
|
60
|
-
|
|
60
|
+
transition_matrix,
|
|
61
61
|
)
|
|
@@ -102,8 +102,8 @@ class Antenna(BaseAntenna):
|
|
|
102
102
|
Compute electric and magnetic fields in vacuum at given position and (optional) time.
|
|
103
103
|
|
|
104
104
|
Args:
|
|
105
|
-
r:
|
|
106
|
-
t:
|
|
105
|
+
r: Position vector relative to the antenna center.
|
|
106
|
+
t: Time instant.
|
|
107
107
|
|
|
108
108
|
If not provided, initial time instant
|
|
109
109
|
is assumed.
|
|
@@ -124,8 +124,8 @@ class Antenna(BaseAntenna):
|
|
|
124
124
|
Compute the Poynting vector in vacuum at given position and (optional) time.
|
|
125
125
|
|
|
126
126
|
Args:
|
|
127
|
-
r:
|
|
128
|
-
t:
|
|
127
|
+
r: Position vector relative to the antenna center.
|
|
128
|
+
t: Time instant.
|
|
129
129
|
|
|
130
130
|
If not provided, initial time instant
|
|
131
131
|
is assumed.
|
|
@@ -181,7 +181,7 @@ class Antenna(BaseAntenna):
|
|
|
181
181
|
ds = du * dv
|
|
182
182
|
|
|
183
183
|
# Power per unit solid angle
|
|
184
|
-
U = p / ds #
|
|
184
|
+
U = p / ds # ruff:ignore[non-lowercase-variable-in-function]
|
|
185
185
|
p_tot = jnp.sum(p * jnp.sin(v)) / (4 * jnp.pi)
|
|
186
186
|
|
|
187
187
|
return u, v, U / p_tot
|
|
@@ -319,10 +319,10 @@ class Dipole(Antenna):
|
|
|
319
319
|
>>> ax = fig.add_subplot(
|
|
320
320
|
... projection="polar", facecolor="lightgoldenrodyellow"
|
|
321
321
|
... )
|
|
322
|
-
>>> for ratio in [0.5, 1.0, 1.25, 1.5, 2.0]:
|
|
322
|
+
>>> for ratio in [0.5, 1.0, 1.25, 1.5, 2.0]: # doctest: +SKIP
|
|
323
323
|
... ant = Dipole(1e9, ratio)
|
|
324
324
|
... power = jnp.linalg.norm(ant.poynting_vector(r), axis=-1)
|
|
325
|
-
...
|
|
325
|
+
... ax.plot(theta, power, label=rf"$\ell/\lambda = {ratio:1.2f}$")
|
|
326
326
|
>>>
|
|
327
327
|
>>> ax.tick_params(grid_color="palegoldenrod")
|
|
328
328
|
>>> ax.set_rscale("log")
|
|
@@ -472,9 +472,9 @@ class Dipole(Antenna):
|
|
|
472
472
|
|
|
473
473
|
return u, v, 1.5 * jax.lax.integer_pow(sin_theta, 2)
|
|
474
474
|
|
|
475
|
-
def directive_gain( #
|
|
475
|
+
def directive_gain( # ruff:ignore[no-self-use]
|
|
476
476
|
self,
|
|
477
|
-
num_points: int = int(1e2), #
|
|
477
|
+
num_points: int = int(1e2), # ruff:ignore[unused-method-argument]
|
|
478
478
|
) -> Float[Array, ""]:
|
|
479
479
|
return jnp.array(1.5)
|
|
480
480
|
|
|
@@ -530,12 +530,10 @@ class RadiationPattern(BaseAntenna):
|
|
|
530
530
|
Compute s and p polarization vectors.
|
|
531
531
|
|
|
532
532
|
Args:
|
|
533
|
-
r:
|
|
533
|
+
r: Position vector relative to the antenna center.
|
|
534
534
|
|
|
535
535
|
Returns:
|
|
536
|
-
The
|
|
537
|
-
|
|
538
|
-
Fields can be either real or complex-valued.
|
|
536
|
+
The s and p polarization unit vectors.
|
|
539
537
|
"""
|
|
540
538
|
|
|
541
539
|
def directivity(
|
|
@@ -7,12 +7,12 @@ from differt.utils import safe_divide
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
@eqx.filter_jit
|
|
10
|
-
def
|
|
10
|
+
def refractive_index(
|
|
11
11
|
epsilon_r: Inexact[ArrayLike, " *#batch"],
|
|
12
12
|
mu_r: Inexact[ArrayLike, " *#batch"] | None = None,
|
|
13
13
|
) -> Inexact[Array, " *batch"]:
|
|
14
14
|
r"""
|
|
15
|
-
Compute the refractive
|
|
15
|
+
Compute the refractive index corresponding to relative permittivity and relative permeability.
|
|
16
16
|
|
|
17
17
|
The refractive index :math:`n` is simply defined as
|
|
18
18
|
|
|
@@ -22,12 +22,12 @@ def refractive_indices(
|
|
|
22
22
|
where :math:`\epsilon_r` is the relative permittivity, and :math:`\mu_r` is the relative permeability.
|
|
23
23
|
|
|
24
24
|
Args:
|
|
25
|
-
epsilon_r: The relative
|
|
26
|
-
mu_r: The relative
|
|
25
|
+
epsilon_r: The relative permittivity.
|
|
26
|
+
mu_r: The relative permeability. If not provided,
|
|
27
27
|
a value of 1 is used.
|
|
28
28
|
|
|
29
29
|
Returns:
|
|
30
|
-
The
|
|
30
|
+
The refractive index.
|
|
31
31
|
|
|
32
32
|
The output dtype will only be complex if any of the provided arguments
|
|
33
33
|
has a complex dtype.
|
|
@@ -54,13 +54,13 @@ def fresnel_coefficients(
|
|
|
54
54
|
r"""
|
|
55
55
|
Compute the Fresnel reflection and refraction coefficients at an interface.
|
|
56
56
|
|
|
57
|
-
The Snell's law describes the relationship between the
|
|
57
|
+
The Snell's law describes the relationship between the angle of incidence
|
|
58
58
|
and refraction:
|
|
59
59
|
|
|
60
60
|
.. math::
|
|
61
61
|
n_i\sin\theta_i = n_t\sin\theta_t,
|
|
62
62
|
|
|
63
|
-
where :math:`n` is the refraction index, :math:`\theta` is the angle
|
|
63
|
+
where :math:`n` is the refraction index, :math:`\theta` is the angle between the ray path
|
|
64
64
|
and the normal to the interface, and :math:`i` and :math:`t` indicate,
|
|
65
65
|
respectively, the first (i.e., incidence) and the second (i.e., transmission)
|
|
66
66
|
media.
|
|
@@ -99,11 +99,11 @@ def fresnel_coefficients(
|
|
|
99
99
|
n_r\cos\theta_t = \sqrt{n_r^2 + \cos^2\theta_i - 1}.
|
|
100
100
|
|
|
101
101
|
Args:
|
|
102
|
-
n_r: The relative refractive
|
|
102
|
+
n_r: The relative refractive index.
|
|
103
103
|
|
|
104
|
-
This is the
|
|
105
|
-
|
|
106
|
-
cos_theta_i: The (cosine of the)
|
|
104
|
+
This is the ratio of the refractive index of the second
|
|
105
|
+
medium over the refractive index of the first medium.
|
|
106
|
+
cos_theta_i: The (cosine of the) angle of incidence.
|
|
107
107
|
|
|
108
108
|
Returns:
|
|
109
109
|
The reflection and refraction coefficients for s and p polarizations.
|
|
@@ -114,12 +114,12 @@ def fresnel_coefficients(
|
|
|
114
114
|
|
|
115
115
|
:func:`refraction_coefficients`
|
|
116
116
|
|
|
117
|
-
:func:`
|
|
117
|
+
:func:`refractive_index`
|
|
118
118
|
|
|
119
119
|
Examples:
|
|
120
120
|
.. plot::
|
|
121
121
|
|
|
122
|
-
The following example reproduces the air-to-glass Fresnel
|
|
122
|
+
The following example reproduces the air-to-glass Fresnel coefficients.
|
|
123
123
|
The Brewster angle (defined by :math:`r_p=0`) is indicated by the vertical
|
|
124
124
|
red line.
|
|
125
125
|
|
|
@@ -222,11 +222,11 @@ def reflection_coefficients(
|
|
|
222
222
|
Compute the Fresnel reflection coefficients at an interface.
|
|
223
223
|
|
|
224
224
|
Args:
|
|
225
|
-
n_r: The relative refractive
|
|
225
|
+
n_r: The relative refractive index.
|
|
226
226
|
|
|
227
|
-
This is the
|
|
228
|
-
|
|
229
|
-
cos_theta_i: The (cosine of the)
|
|
227
|
+
This is the ratio of the refractive index of the second
|
|
228
|
+
medium over the refractive index of the first medium.
|
|
229
|
+
cos_theta_i: The (cosine of the) angle of incidence.
|
|
230
230
|
|
|
231
231
|
Returns:
|
|
232
232
|
The reflection coefficients for s and p polarizations.
|
|
@@ -237,13 +237,13 @@ def reflection_coefficients(
|
|
|
237
237
|
|
|
238
238
|
:func:`refraction_coefficients`
|
|
239
239
|
|
|
240
|
-
:func:`
|
|
240
|
+
:func:`refractive_index`
|
|
241
241
|
|
|
242
242
|
Examples:
|
|
243
243
|
.. plot::
|
|
244
244
|
:context: reset
|
|
245
245
|
|
|
246
|
-
The following example
|
|
246
|
+
The following example shows how to compute interference
|
|
247
247
|
patterns from line of sight and reflection on a glass
|
|
248
248
|
ground.
|
|
249
249
|
|
|
@@ -317,7 +317,7 @@ def reflection_coefficients(
|
|
|
317
317
|
... label="FSPL",
|
|
318
318
|
... ) # doctest: +SKIP
|
|
319
319
|
|
|
320
|
-
After, the :func:`image_method<differt.
|
|
320
|
+
After, the :func:`image_method<differt.geometry.image_method>`
|
|
321
321
|
function is used to compute the reflection points.
|
|
322
322
|
|
|
323
323
|
>>> ground_vertex = jnp.array([0.0, 0.0, 0.0])
|
|
@@ -445,7 +445,7 @@ def reflection_coefficients(
|
|
|
445
445
|
... color="green",
|
|
446
446
|
... label="Exact",
|
|
447
447
|
... ) # doctest: +SKIP
|
|
448
|
-
>>> P_tot_pw = A_e * jnp.sum(E_tot
|
|
448
|
+
>>> P_tot_pw = A_e * jnp.sum(jnp.abs(E_tot) ** 2, axis=-1) / z_0
|
|
449
449
|
>>> plt.semilogx(
|
|
450
450
|
... x,
|
|
451
451
|
... 10 * jnp.log10(P_tot_pw / ant.reference_power),
|
|
@@ -492,15 +492,15 @@ def refraction_coefficients(
|
|
|
492
492
|
n_r: Inexact[ArrayLike, " *#batch"],
|
|
493
493
|
cos_theta_i: Float[ArrayLike, " *#batch"],
|
|
494
494
|
) -> tuple[Complex[Array, " *batch"], Complex[Array, " *batch"]]:
|
|
495
|
-
"""
|
|
495
|
+
r"""
|
|
496
496
|
Compute the Fresnel refraction coefficients at an interface.
|
|
497
497
|
|
|
498
498
|
Args:
|
|
499
|
-
n_r: The relative refractive
|
|
499
|
+
n_r: The relative refractive index.
|
|
500
500
|
|
|
501
|
-
This is the
|
|
502
|
-
|
|
503
|
-
cos_theta_i: The (cosine of the)
|
|
501
|
+
This is the ratio of the refractive index of the second
|
|
502
|
+
medium over the refractive index of the first medium.
|
|
503
|
+
cos_theta_i: The (cosine of the) angle of incidence.
|
|
504
504
|
|
|
505
505
|
Returns:
|
|
506
506
|
The refraction coefficients for s and p polarizations.
|
|
@@ -511,6 +511,6 @@ def refraction_coefficients(
|
|
|
511
511
|
|
|
512
512
|
:func:`reflection_coefficients`
|
|
513
513
|
|
|
514
|
-
:func:`
|
|
514
|
+
:func:`refractive_index`
|
|
515
515
|
"""
|
|
516
516
|
return fresnel_coefficients(n_r, cos_theta_i)[1]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ruff:
|
|
1
|
+
# ruff:file-ignore[math-constant]
|
|
2
2
|
|
|
3
3
|
import operator
|
|
4
4
|
import typing
|
|
@@ -95,7 +95,7 @@ class Material(eqx.Module):
|
|
|
95
95
|
|
|
96
96
|
Args:
|
|
97
97
|
name: The name of the material.
|
|
98
|
-
itu_properties:
|
|
98
|
+
itu_properties: Material properties and corresponding frequency range.
|
|
99
99
|
|
|
100
100
|
Each tuple must contain:
|
|
101
101
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# ruff:
|
|
2
|
-
# type: ignore #
|
|
1
|
+
# ruff:file-ignore[invalid-function-name, non-lowercase-variable-in-function]
|
|
2
|
+
# type: ignore # ruff:ignore[blanket-type-ignore]
|
|
3
3
|
from typing import Any, Literal, overload
|
|
4
4
|
|
|
5
5
|
import equinox as eqx
|
|
@@ -134,7 +134,7 @@ def L_i(
|
|
|
134
134
|
If this is set, other radius parameters must be set to 'None'.
|
|
135
135
|
|
|
136
136
|
Returns:
|
|
137
|
-
|
|
137
|
+
Distance parameter :math:`L_i`.
|
|
138
138
|
|
|
139
139
|
Raises:
|
|
140
140
|
ValueError: If 's_i' was provided along at least one of the other radius parameters,
|
|
@@ -186,10 +186,10 @@ def F(z: Float[Array, " *batch"]) -> Complex[Array, " *batch"]:
|
|
|
186
186
|
With Fresnel integrals computed by :data:`jax.scipy.special.fresnel`.
|
|
187
187
|
|
|
188
188
|
Args:
|
|
189
|
-
z:
|
|
189
|
+
z: Real point to evaluate.
|
|
190
190
|
|
|
191
191
|
Returns:
|
|
192
|
-
|
|
192
|
+
Value of the transition function.
|
|
193
193
|
|
|
194
194
|
Examples:
|
|
195
195
|
.. plot::
|
|
@@ -254,38 +254,37 @@ def diffraction_coefficients(
|
|
|
254
254
|
Raises:
|
|
255
255
|
NotImplementedError: The function is not yet implemented.
|
|
256
256
|
"""
|
|
257
|
-
# ruff: noqa: F821, F841
|
|
258
257
|
raise NotImplementedError
|
|
259
258
|
|
|
260
259
|
# Ensure input vectors are normalized
|
|
261
|
-
incident_ray = incident_ray / jnp.linalg.norm(incident_ray)
|
|
262
|
-
diffracted_ray = diffracted_ray / jnp.linalg.norm(diffracted_ray)
|
|
263
|
-
edge_vector = edge_vector / jnp.linalg.norm(edge_vector)
|
|
260
|
+
incident_ray = incident_ray / jnp.linalg.norm(incident_ray) # ruff:ignore[undefined-name]
|
|
261
|
+
diffracted_ray = diffracted_ray / jnp.linalg.norm(diffracted_ray) # ruff:ignore[undefined-name]
|
|
262
|
+
edge_vector = edge_vector / jnp.linalg.norm(edge_vector) # ruff:ignore[undefined-name]
|
|
264
263
|
|
|
265
264
|
# Compute relevant angles
|
|
266
265
|
beta_0 = jnp.arccos(jnp.dot(incident_ray, edge_vector))
|
|
267
266
|
beta = jnp.arccos(jnp.dot(diffracted_ray, edge_vector))
|
|
268
|
-
phi = jnp.arccos(jnp.dot(-incident_ray, diffracted_ray))
|
|
267
|
+
phi = jnp.arccos(jnp.dot(-incident_ray, diffracted_ray)) # ruff:ignore[unused-variable]
|
|
269
268
|
|
|
270
269
|
# Compute L parameters (distance parameters)
|
|
271
|
-
L = r * jnp.sin(beta) ** 2 / (r + r_prime)
|
|
272
|
-
L_prime = r_prime * jnp.sin(beta_0) ** 2 / (r + r_prime)
|
|
270
|
+
L = r * jnp.sin(beta) ** 2 / (r + r_prime) # ruff:ignore[undefined-name, unused-variable]
|
|
271
|
+
L_prime = r_prime * jnp.sin(beta_0) ** 2 / (r + r_prime) # ruff:ignore[undefined-name, unused-variable]
|
|
273
272
|
|
|
274
|
-
phi_i = jnp.pi - (jnp.pi - jnp.arccos(dot(-s_t_i, t_o))) * _sign(dot(-s_t_i, n_o))
|
|
275
|
-
phi_d = jnp.pi - (jnp.pi - jnp.arccos(dot(+s_t_d, t_o))) * _sign(dot(+s_d_i, n_o))
|
|
273
|
+
phi_i = jnp.pi - (jnp.pi - jnp.arccos(dot(-s_t_i, t_o))) * _sign(dot(-s_t_i, n_o)) # ruff:ignore[undefined-name]
|
|
274
|
+
phi_d = jnp.pi - (jnp.pi - jnp.arccos(dot(+s_t_d, t_o))) * _sign(dot(+s_d_i, n_o)) # ruff:ignore[undefined-name]
|
|
276
275
|
|
|
277
276
|
# Compute the angle differences
|
|
278
277
|
phi_1 = phi_d - phi_i
|
|
279
278
|
phi_2 = phi_d + phi_i
|
|
280
279
|
|
|
281
280
|
# Compute the diffraction coefficients (without common mul. factor)
|
|
282
|
-
D_1 = _cot((jnp.pi + phi_1) / (2 * n)) * F(k * L_i * _a(phi_1, "+"))
|
|
283
|
-
D_2 = _cot((jnp.pi - phi_1) / (2 * n)) * F(k * L_i * _a(phi_1, "-"))
|
|
284
|
-
D_3 = _cot((jnp.pi + phi_2) / (2 * n)) * F(k * L_r_n * _a(phi_2, "+"))
|
|
285
|
-
D_4 = _cot((jnp.pi - phi_2) / (2 * n)) * F(k * L_r_o * _a(phi_2, "-"))
|
|
281
|
+
D_1 = _cot((jnp.pi + phi_1) / (2 * n)) * F(k * L_i * _a(phi_1, "+")) # ruff:ignore[undefined-name]
|
|
282
|
+
D_2 = _cot((jnp.pi - phi_1) / (2 * n)) * F(k * L_i * _a(phi_1, "-")) # ruff:ignore[undefined-name]
|
|
283
|
+
D_3 = _cot((jnp.pi + phi_2) / (2 * n)) * F(k * L_r_n * _a(phi_2, "+")) # ruff:ignore[undefined-name]
|
|
284
|
+
D_4 = _cot((jnp.pi - phi_2) / (2 * n)) * F(k * L_r_o * _a(phi_2, "-")) # ruff:ignore[undefined-name]
|
|
286
285
|
|
|
287
286
|
factor = -jnp.exp(-1j * jnp.pi / 4) / (
|
|
288
|
-
2 * n * jnp.sqrt(2 * jnp.pi * k) * sin_beta_0
|
|
287
|
+
2 * n * jnp.sqrt(2 * jnp.pi * k) * sin_beta_0 # ruff:ignore[undefined-name]
|
|
289
288
|
)
|
|
290
289
|
|
|
291
290
|
# Apply the Keller cone condition
|
|
@@ -4,82 +4,80 @@ import jax
|
|
|
4
4
|
import jax.numpy as jnp
|
|
5
5
|
from jaxtyping import Array, ArrayLike, Float, Int
|
|
6
6
|
|
|
7
|
-
from differt.geometry import normalize,
|
|
7
|
+
from differt.geometry import normalize, path_length, perpendicular_vector
|
|
8
8
|
|
|
9
9
|
from ._constants import c
|
|
10
10
|
from ._interaction_type import InteractionType
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
@jax.jit
|
|
14
|
-
def
|
|
15
|
-
|
|
14
|
+
def length_to_delay(
|
|
15
|
+
length: Float[ArrayLike, " *#batch"],
|
|
16
16
|
speed: Float[ArrayLike, " *#batch"] = c,
|
|
17
17
|
) -> Float[Array, " *batch"]:
|
|
18
18
|
"""
|
|
19
|
-
Compute the delay, in seconds, corresponding to
|
|
19
|
+
Compute the delay, in seconds, corresponding to the length.
|
|
20
20
|
|
|
21
21
|
Args:
|
|
22
|
-
|
|
23
|
-
speed:
|
|
24
|
-
|
|
25
|
-
an array of speeds. Default is the speed
|
|
26
|
-
of light in vacuum.
|
|
22
|
+
length: Input length (in meters).
|
|
23
|
+
speed: Speed (in m/s).
|
|
24
|
+
Defaults to the speed of light in vacuum.
|
|
27
25
|
|
|
28
26
|
Returns:
|
|
29
|
-
The
|
|
27
|
+
The path delay.
|
|
30
28
|
|
|
31
29
|
Examples:
|
|
32
30
|
The following example shows how to compute a delay from a length.
|
|
33
31
|
|
|
34
32
|
>>> from differt.em import c
|
|
35
33
|
>>> from differt.em import (
|
|
36
|
-
...
|
|
34
|
+
... length_to_delay,
|
|
37
35
|
... )
|
|
38
36
|
>>>
|
|
39
|
-
>>>
|
|
40
|
-
>>>
|
|
37
|
+
>>> length = jnp.array([1.0, 2.0, 4.0])
|
|
38
|
+
>>> length_to_delay(length) * c
|
|
41
39
|
Array([1., 2., 4.], dtype=float32)
|
|
42
|
-
>>>
|
|
40
|
+
>>> length_to_delay(length, speed=2.0)
|
|
43
41
|
Array([0.5, 1. , 2. ], dtype=float32)
|
|
44
42
|
"""
|
|
45
|
-
return jnp.asarray(
|
|
43
|
+
return jnp.asarray(length) / jnp.asarray(speed)
|
|
46
44
|
|
|
47
45
|
|
|
48
46
|
@jax.jit
|
|
49
|
-
def
|
|
50
|
-
|
|
47
|
+
def path_delay(
|
|
48
|
+
path: Float[ArrayLike, "*batch path_length 3"],
|
|
51
49
|
**kwargs: Any,
|
|
52
50
|
) -> Float[Array, " *batch"]:
|
|
53
51
|
"""
|
|
54
|
-
Compute the path delay, in seconds, of
|
|
52
|
+
Compute the path delay, in seconds, of the path.
|
|
55
53
|
|
|
56
|
-
|
|
54
|
+
The path is exactly made of ``path_length`` vertices.
|
|
57
55
|
|
|
58
56
|
Args:
|
|
59
|
-
|
|
57
|
+
path: Input path.
|
|
60
58
|
kwargs: Keyword arguments passed to
|
|
61
|
-
:func:`
|
|
59
|
+
:func:`length_to_delay`.
|
|
62
60
|
|
|
63
61
|
Returns:
|
|
64
|
-
The
|
|
62
|
+
The path delay.
|
|
65
63
|
|
|
66
64
|
Examples:
|
|
67
65
|
The following example shows how to compute the delay of a very simple path.
|
|
68
66
|
|
|
69
67
|
>>> from differt.em import c
|
|
70
68
|
>>> from differt.em import (
|
|
71
|
-
...
|
|
69
|
+
... path_delay,
|
|
72
70
|
... )
|
|
73
71
|
>>>
|
|
74
72
|
>>> path = jnp.array([[1.0, 0.0, 0.0], [1.0, 1.0, 0.0]])
|
|
75
|
-
>>>
|
|
73
|
+
>>> path_delay(path) * c
|
|
76
74
|
Array(1., dtype=float32)
|
|
77
|
-
>>>
|
|
75
|
+
>>> path_delay(path, speed=2.0)
|
|
78
76
|
Array(0.5, dtype=float32)
|
|
79
77
|
"""
|
|
80
|
-
|
|
78
|
+
length = path_length(path)
|
|
81
79
|
|
|
82
|
-
return
|
|
80
|
+
return length_to_delay(length, **kwargs)
|
|
83
81
|
|
|
84
82
|
|
|
85
83
|
@jax.jit
|
|
@@ -95,18 +93,18 @@ def sp_directions(
|
|
|
95
93
|
Compute the directions of the local s and p components, before and after reflection, relative to the propagation direction and a local normal.
|
|
96
94
|
|
|
97
95
|
Args:
|
|
98
|
-
k_i: The
|
|
96
|
+
k_i: The propagation direction of the incident field.
|
|
99
97
|
|
|
100
|
-
|
|
101
|
-
k_r: The
|
|
98
|
+
The vector must have a unit length.
|
|
99
|
+
k_r: The propagation direction of the reflected field.
|
|
102
100
|
|
|
103
|
-
|
|
104
|
-
normals: The
|
|
101
|
+
The vector must have a unit length.
|
|
102
|
+
normals: The local normal.
|
|
105
103
|
|
|
106
|
-
|
|
104
|
+
The vector must have a unit length.
|
|
107
105
|
|
|
108
106
|
Returns:
|
|
109
|
-
The
|
|
107
|
+
The s and p directions, before and after reflection.
|
|
110
108
|
|
|
111
109
|
Examples:
|
|
112
110
|
The following example shows how to compute and display the direction of
|
|
@@ -190,6 +188,7 @@ def sp_directions(
|
|
|
190
188
|
>>> k_i = reflection_point - tx
|
|
191
189
|
>>> k_r = rx - reflection_point
|
|
192
190
|
>>> (e_i_s, e_i_p), (e_r_s, e_r_p) = sp_directions(k_i, k_r, normal)
|
|
191
|
+
>>> # ... (lines omitted for brevity)
|
|
193
192
|
|
|
194
193
|
Finally, we draw all the vectors and markers.
|
|
195
194
|
|
|
@@ -255,7 +254,7 @@ def sp_directions(
|
|
|
255
254
|
normal_incidence = e_i_s_norm == 0.0
|
|
256
255
|
e_i_s: Array = jnp.where(
|
|
257
256
|
normal_incidence,
|
|
258
|
-
|
|
257
|
+
perpendicular_vector(k_i),
|
|
259
258
|
e_i_s,
|
|
260
259
|
)
|
|
261
260
|
e_i_p = normalize(jnp.cross(e_i_s, k_i))[0]
|
|
@@ -279,13 +278,13 @@ def sp_rotation_matrix(
|
|
|
279
278
|
The latter is equivalent to ensuring that all four vectors are coplanar.
|
|
280
279
|
|
|
281
280
|
Args:
|
|
282
|
-
e_a_s:
|
|
283
|
-
e_a_p:
|
|
284
|
-
e_b_s:
|
|
285
|
-
e_b_p:
|
|
281
|
+
e_a_s: s-component direction of the first field basis.
|
|
282
|
+
e_a_p: p-component direction of the first field basis.
|
|
283
|
+
e_b_s: s-component direction of the second field basis.
|
|
284
|
+
e_b_p: p-component direction of the second field basis.
|
|
286
285
|
|
|
287
286
|
Returns:
|
|
288
|
-
|
|
287
|
+
Rotation matrix from basis ``(e_a_s, e_a_p)`` to ``(e_b_s, e_b_p)``.
|
|
289
288
|
"""
|
|
290
289
|
e_a_s = jnp.asarray(e_a_s)
|
|
291
290
|
e_a_p = jnp.asarray(e_a_p)
|
|
@@ -304,7 +303,7 @@ def sp_rotation_matrix(
|
|
|
304
303
|
|
|
305
304
|
|
|
306
305
|
@jax.jit
|
|
307
|
-
def
|
|
306
|
+
def transition_matrix(
|
|
308
307
|
vertices: Float[ArrayLike, "*batch path_length 3"],
|
|
309
308
|
objects: Float[ArrayLike, "*batch path_length"],
|
|
310
309
|
interaction_types: Int[ArrayLike, "*batch path_length-2"],
|
|
@@ -347,7 +346,7 @@ def fspl(
|
|
|
347
346
|
d: Float[ArrayLike, " *#batch"],
|
|
348
347
|
f: Float[ArrayLike, " *#batch"],
|
|
349
348
|
*,
|
|
350
|
-
dB: bool = False, #
|
|
349
|
+
dB: bool = False, # ruff:ignore[invalid-argument-name]
|
|
351
350
|
) -> Float[Array, " *batch"]:
|
|
352
351
|
"""
|
|
353
352
|
Compute the free-space path loss (FSPL), optionally in dB.
|
|
@@ -355,12 +354,12 @@ def fspl(
|
|
|
355
354
|
See :cite:`fspl` for more information.
|
|
356
355
|
|
|
357
356
|
Args:
|
|
358
|
-
d:
|
|
359
|
-
f:
|
|
357
|
+
d: Distance (in meters).
|
|
358
|
+
f: Frequency (in Hertz).
|
|
360
359
|
dB: Whether to return the result in dB.
|
|
361
360
|
|
|
362
361
|
Returns:
|
|
363
|
-
|
|
362
|
+
Free-space path loss.
|
|
364
363
|
"""
|
|
365
364
|
if dB:
|
|
366
365
|
return 20 * jnp.log10(d) + 20 * jnp.log10(f) - 147.55221677811662
|