differt 0.11.0__tar.gz → 0.12.1__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.
Files changed (47) hide show
  1. {differt-0.11.0 → differt-0.12.1}/PKG-INFO +22 -13
  2. {differt-0.11.0 → differt-0.12.1}/README.md +16 -7
  3. {differt-0.11.0 → differt-0.12.1}/pyproject.toml +6 -6
  4. differt-0.12.1/src/differt/__init__.py +71 -0
  5. {differt-0.11.0 → differt-0.12.1}/src/differt/em/__init__.py +17 -3
  6. {differt-0.11.0 → differt-0.12.1}/src/differt/em/_antenna.py +6 -6
  7. {differt-0.11.0 → differt-0.12.1}/src/differt/em/_fields.py +20 -58
  8. {differt-0.11.0 → differt-0.12.1}/src/differt/em/_fresnel.py +4 -6
  9. {differt-0.11.0 → differt-0.12.1}/src/differt/em/_interaction_type.py +12 -0
  10. {differt-0.11.0 → differt-0.12.1}/src/differt/em/_material.py +93 -4
  11. {differt-0.11.0 → differt-0.12.1}/src/differt/em/_pipeline.py +72 -60
  12. {differt-0.11.0 → differt-0.12.1}/src/differt/em/_solvers.py +546 -399
  13. {differt-0.11.0 → differt-0.12.1}/src/differt/em/_utd.py +14 -11
  14. {differt-0.11.0 → differt-0.12.1}/src/differt/em/_utils.py +32 -1
  15. differt-0.12.1/src/differt/em/_wavefront.py +447 -0
  16. {differt-0.11.0 → differt-0.12.1}/src/differt/geometry/__init__.py +11 -16
  17. differt-0.12.1/src/differt/geometry/_interaction_sites.py +189 -0
  18. {differt-0.11.0 → differt-0.12.1}/src/differt/geometry/_mesh.py +97 -79
  19. {differt-0.11.0 → differt-0.12.1}/src/differt/geometry/_paths.py +253 -81
  20. {differt-0.11.0 → differt-0.12.1}/src/differt/geometry/_scene.py +126 -481
  21. {differt-0.11.0 → differt-0.12.1}/src/differt/geometry/_sionna.py +3 -3
  22. {differt-0.11.0 → differt-0.12.1}/src/differt/geometry/_solver_fermat.py +101 -8
  23. {differt-0.11.0 → differt-0.12.1}/src/differt/geometry/_solver_image_method.py +8 -4
  24. {differt-0.11.0 → differt-0.12.1}/src/differt/geometry/_utils.py +23 -20
  25. {differt-0.11.0 → differt-0.12.1}/src/differt/geometry/_warp_utils.py +4 -50
  26. differt-0.12.1/src/differt/geometry/solvers/__init__.py +41 -0
  27. differt-0.12.1/src/differt/geometry/solvers/_base.py +1193 -0
  28. differt-0.12.1/src/differt/geometry/solvers/_dispatch.py +342 -0
  29. differt-0.12.1/src/differt/geometry/solvers/_exhaustive.py +322 -0
  30. differt-0.12.1/src/differt/geometry/solvers/_hybrid.py +383 -0
  31. differt-0.12.1/src/differt/geometry/solvers/_sbr.py +555 -0
  32. {differt-0.11.0 → differt-0.12.1}/src/differt/plotting/__init__.py +3 -3
  33. {differt-0.11.0 → differt-0.12.1}/src/differt/plotting/_core.py +15 -13
  34. {differt-0.11.0 → differt-0.12.1}/src/differt/plotting/_utils.py +16 -16
  35. {differt-0.11.0 → differt-0.12.1}/src/differt/plugins/deepmimo.py +49 -282
  36. {differt-0.11.0 → differt-0.12.1}/src/differt/utils.py +2 -2
  37. differt-0.11.0/src/differt/__init__.py +0 -8
  38. differt-0.11.0/src/differt/geometry/_solvers.py +0 -1914
  39. differt-0.11.0/src/differt/rt/__init__.py +0 -45
  40. differt-0.11.0/src/differt/scene/__init__.py +0 -47
  41. {differt-0.11.0 → differt-0.12.1}/.gitignore +0 -0
  42. {differt-0.11.0 → differt-0.12.1}/LICENSE.md +0 -0
  43. {differt-0.11.0 → differt-0.12.1}/src/differt/_version.py +0 -0
  44. {differt-0.11.0 → differt-0.12.1}/src/differt/em/_constants.py +0 -0
  45. {differt-0.11.0 → differt-0.12.1}/src/differt/plugins/__init__.py +0 -0
  46. {differt-0.11.0 → differt-0.12.1}/src/differt/plugins/_deepmimo_types.py +0 -0
  47. {differt-0.11.0 → differt-0.12.1}/src/differt/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: DiffeRT
3
- Version: 0.11.0
3
+ Version: 0.12.1
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,10 +20,10 @@ 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.11.0
23
+ Requires-Dist: differt-core==0.12.1
24
24
  Requires-Dist: equinox>=0.13.7
25
- Requires-Dist: filelock>=3.15.4
26
- Requires-Dist: fpt-jax==0.1.0
25
+ Requires-Dist: filelock>=4.2.1
26
+ Requires-Dist: fpt-jax==0.2.0
27
27
  Requires-Dist: jax>=0.8.1
28
28
  Requires-Dist: jaxtyping>=0.3.11
29
29
  Requires-Dist: numpy>=1.26.1
@@ -35,7 +35,7 @@ Requires-Dist: ipykernel<7; extra == 'all'
35
35
  Requires-Dist: ipympl>=0.9.4; extra == 'all'
36
36
  Requires-Dist: jupyter-rfb>=0.4.2; extra == 'all'
37
37
  Requires-Dist: matplotlib>=3.8.1; extra == 'all'
38
- Requires-Dist: notebook>5; extra == 'all'
38
+ Requires-Dist: notebook>=7.6.3; extra == 'all'
39
39
  Requires-Dist: plotly>=5.18.0; extra == 'all'
40
40
  Requires-Dist: pyqt6>=6.6.1; extra == 'all'
41
41
  Requires-Dist: vispy>=0.14.1; extra == 'all'
@@ -43,7 +43,7 @@ Provides-Extra: jupyter
43
43
  Requires-Dist: ipykernel<7; extra == 'jupyter'
44
44
  Requires-Dist: ipympl>=0.9.4; extra == 'jupyter'
45
45
  Requires-Dist: jupyter-rfb>=0.4.2; extra == 'jupyter'
46
- Requires-Dist: notebook>5; extra == 'jupyter'
46
+ Requires-Dist: notebook>=7.6.3; extra == 'jupyter'
47
47
  Provides-Extra: matplotlib
48
48
  Requires-Dist: matplotlib>=3.8.1; extra == 'matplotlib'
49
49
  Provides-Extra: plotly
@@ -62,7 +62,8 @@ Description-Content-Type: text/markdown
62
62
 
63
63
  # DiffeRT
64
64
 
65
- Differentiable Ray Tracing toolbox for Radio Propagation powered by the [JAX ecosystem](https://github.com/jax-ml/jax).
65
+ Differentiable Ray Tracing toolbox for Radio Propagation powered by the
66
+ [JAX ecosystem](https://github.com/jax-ml/jax).
66
67
 
67
68
  [![Latest Release][pypi-version-badge]][pypi-version-url]
68
69
  [![Python version][pypi-python-version-badge]][pypi-version-url]
@@ -75,10 +76,11 @@ Differentiable Ray Tracing toolbox for Radio Propagation powered by the [JAX eco
75
76
  ## Usage
76
77
 
77
78
  > **WARNING:**
78
- > This package is still under important development, see
79
- > the [v1.0.0](https://github.com/jeertmans/DiffeRT/milestone/2) milestone for future
80
- > features, and the [CHANGELOG](https://github.com/jeertmans/DiffeRT/blob/main/CHANGELOG.md)
81
- > for versioning policy.
79
+ > This package is still under important development, see the
80
+ > [v1.0.0](https://github.com/jeertmans/DiffeRT/milestone/2) milestone for
81
+ > future features, and the
82
+ > [CHANGELOG](https://github.com/jeertmans/DiffeRT/blob/main/CHANGELOG.md) for
83
+ > versioning policy.
82
84
  >
83
85
  > If you have any suggestion regarding the development of this package,
84
86
  > please open an [issue](https://github.com/jeertmans/DiffeRT/issues).
@@ -135,6 +137,7 @@ for a detailed step-by-step procedure.
135
137
 
136
138
  If you use this software, please cite it as (**preferred**):
137
139
 
140
+ <!-- rumdl-disable -->
138
141
  ```bibtex
139
142
  @inproceedings{Eertmans_DiffeRT_ICMLCN_2025,
140
143
  title = {Demonstrating {DiffeRT}: An Open-Source Library for Optimizing Radio Networks with Differentiable Ray Tracing},
@@ -147,20 +150,26 @@ If you use this software, please cite it as (**preferred**):
147
150
  doi = {10.1109/ICMLCN64995.2025.11139997}
148
151
  }
149
152
  ```
153
+ <!-- rumdl-enable -->
150
154
 
151
155
  or:
152
156
 
157
+ <!-- rumdl-disable -->
153
158
  ```bibtex
154
159
  @software{Eertmans_DiffeRT_GitHub,
155
160
  title = {{DiffeRT}: A Differentiable Ray Tracing Toolbox for Radio Propagation Simulations},
156
161
  author = {Eertmans, Jérome},
157
162
  url = {https://github.com/jeertmans/DiffeRT},
158
163
  license = {MIT},
159
- version = {v0.11.0}
164
+ version = {v0.12.1}
160
165
  }
161
166
  ```
167
+ <!-- rumdl-enable -->
162
168
 
163
- For other citation formats, please refer to the [*Cite this repository*](https://github.com/jeertmans/DiffeRT) button the main page of our GitHub repository or to our [Zenodo records](https://doi.org/10.5281/zenodo.11386432).
169
+ For other citation formats, please refer to the
170
+ [*Cite this repository*](https://github.com/jeertmans/DiffeRT) button the main
171
+ page of our GitHub repository or to our
172
+ [Zenodo records](https://doi.org/10.5281/zenodo.11386432).
164
173
 
165
174
  Thank you for using this software and helping us!
166
175
 
@@ -6,7 +6,8 @@
6
6
 
7
7
  # DiffeRT
8
8
 
9
- Differentiable Ray Tracing toolbox for Radio Propagation powered by the [JAX ecosystem](https://github.com/jax-ml/jax).
9
+ Differentiable Ray Tracing toolbox for Radio Propagation powered by the
10
+ [JAX ecosystem](https://github.com/jax-ml/jax).
10
11
 
11
12
  [![Latest Release][pypi-version-badge]][pypi-version-url]
12
13
  [![Python version][pypi-python-version-badge]][pypi-version-url]
@@ -19,10 +20,11 @@ Differentiable Ray Tracing toolbox for Radio Propagation powered by the [JAX eco
19
20
  ## Usage
20
21
 
21
22
  > [!WARNING]
22
- > This package is still under important development, see
23
- > the [v1.0.0](https://github.com/jeertmans/DiffeRT/milestone/2) milestone for future
24
- > features, and the [CHANGELOG](https://github.com/jeertmans/DiffeRT/blob/main/CHANGELOG.md)
25
- > for versioning policy.
23
+ > This package is still under important development, see the
24
+ > [v1.0.0](https://github.com/jeertmans/DiffeRT/milestone/2) milestone for
25
+ > future features, and the
26
+ > [CHANGELOG](https://github.com/jeertmans/DiffeRT/blob/main/CHANGELOG.md) for
27
+ > versioning policy.
26
28
  >
27
29
  > If you have any suggestion regarding the development of this package,
28
30
  > please open an [issue](https://github.com/jeertmans/DiffeRT/issues).
@@ -79,6 +81,7 @@ for a detailed step-by-step procedure.
79
81
 
80
82
  If you use this software, please cite it as (**preferred**):
81
83
 
84
+ <!-- rumdl-disable -->
82
85
  ```bibtex
83
86
  @inproceedings{Eertmans_DiffeRT_ICMLCN_2025,
84
87
  title = {Demonstrating {DiffeRT}: An Open-Source Library for Optimizing Radio Networks with Differentiable Ray Tracing},
@@ -91,20 +94,26 @@ If you use this software, please cite it as (**preferred**):
91
94
  doi = {10.1109/ICMLCN64995.2025.11139997}
92
95
  }
93
96
  ```
97
+ <!-- rumdl-enable -->
94
98
 
95
99
  or:
96
100
 
101
+ <!-- rumdl-disable -->
97
102
  ```bibtex
98
103
  @software{Eertmans_DiffeRT_GitHub,
99
104
  title = {{DiffeRT}: A Differentiable Ray Tracing Toolbox for Radio Propagation Simulations},
100
105
  author = {Eertmans, Jérome},
101
106
  url = {https://github.com/jeertmans/DiffeRT},
102
107
  license = {MIT},
103
- version = {v0.11.0}
108
+ version = {v0.12.1}
104
109
  }
105
110
  ```
111
+ <!-- rumdl-enable -->
106
112
 
107
- For other citation formats, please refer to the [*Cite this repository*](https://github.com/jeertmans/DiffeRT) button the main page of our GitHub repository or to our [Zenodo records](https://doi.org/10.5281/zenodo.11386432).
113
+ For other citation formats, please refer to the
114
+ [*Cite this repository*](https://github.com/jeertmans/DiffeRT) button the main
115
+ page of our GitHub repository or to our
116
+ [Zenodo records](https://doi.org/10.5281/zenodo.11386432).
108
117
 
109
118
  Thank you for using this software and helping us!
110
119
 
@@ -3,7 +3,7 @@ build-backend = "hatchling.build"
3
3
  requires = ["hatchling", "hatch-fancy-pypi-readme"]
4
4
 
5
5
  [project]
6
- authors = [{name = "Jérome Eertmans", email = "jeertmans@icloud.com"}]
6
+ authors = [{ name = "Jérome Eertmans", email = "jeertmans@icloud.com" }]
7
7
  classifiers = [
8
8
  "Programming Language :: Python :: 3",
9
9
  "Programming Language :: Python :: 3.11",
@@ -15,10 +15,10 @@ classifiers = [
15
15
  ]
16
16
  dependencies = [
17
17
  "chex>=0.1.86",
18
- "differt-core==0.11.0",
18
+ "differt-core==0.12.1",
19
19
  "equinox>=0.13.7",
20
- "filelock>=3.15.4",
21
- "fpt-jax==0.1.0",
20
+ "filelock>=4.2.1",
21
+ "fpt-jax==0.2.0",
22
22
  "jax>=0.8.1",
23
23
  "jaxtyping>=0.3.11",
24
24
  "numpy>=1.26.1",
@@ -37,7 +37,7 @@ requires-python = ">=3.11"
37
37
  all = [
38
38
  "differt[jupyter,matplotlib,plotly,vispy,vispy-backend]",
39
39
  ]
40
- jupyter = ["notebook>5", "jupyter-rfb>=0.4.2", "ipympl>=0.9.4", "ipykernel<7"]
40
+ jupyter = ["notebook>=7.6.3", "jupyter-rfb>=0.4.2", "ipympl>=0.9.4", "ipykernel<7"]
41
41
  matplotlib = ["matplotlib>=3.8.1"]
42
42
  plotly = ["plotly>=5.18.0"]
43
43
  vispy = [
@@ -93,4 +93,4 @@ path = "../differt-core/Cargo.toml"
93
93
  pattern = '^version = "(?P<version>[^"]+)'
94
94
 
95
95
  [tool.uv.sources]
96
- differt_core = {workspace = true}
96
+ differt_core = { workspace = true }
@@ -0,0 +1,71 @@
1
+ """Differentiable Ray Tracing Toolbox for Radio Propagation."""
2
+
3
+ __all__ = (
4
+ "RIS",
5
+ "Diffraction",
6
+ "InteractionType",
7
+ "LaunchedPaths",
8
+ "Material",
9
+ "Mesh",
10
+ "Scattering",
11
+ "Scene",
12
+ "SpecularReflection",
13
+ "TracedPaths",
14
+ "Transmission",
15
+ "WavefrontState",
16
+ "__version__",
17
+ "__version_info__",
18
+ "propagate_wavefront",
19
+ )
20
+
21
+ import importlib
22
+ from typing import TYPE_CHECKING
23
+
24
+ from ._version import __version__, __version_info__
25
+
26
+ if TYPE_CHECKING:
27
+ from .em import (
28
+ RIS,
29
+ Diffraction,
30
+ InteractionType,
31
+ Material,
32
+ Scattering,
33
+ SpecularReflection,
34
+ Transmission,
35
+ WavefrontState,
36
+ propagate_wavefront,
37
+ )
38
+ from .geometry import LaunchedPaths, Mesh, Scene, TracedPaths
39
+
40
+ # Lazily re-export the most commonly used names from 'differt.geometry' and
41
+ # 'differt.em' at the top level (PEP 562), so 'import differt' stays cheap:
42
+ # neither submodule (and none of their heavy dependencies, e.g. 'warp' or
43
+ # 'fpt_jax') is imported until one of these names is actually accessed.
44
+ # This also sidesteps the geometry <-> em circular import (see
45
+ # 'Scene.load_xml'/'Scene.trace_fields' for its existing occurrences).
46
+ _LAZY = {
47
+ "Scene": ".geometry",
48
+ "Mesh": ".geometry",
49
+ "TracedPaths": ".geometry",
50
+ "LaunchedPaths": ".geometry",
51
+ "Material": ".em",
52
+ "InteractionType": ".em",
53
+ "SpecularReflection": ".em",
54
+ "Diffraction": ".em",
55
+ "Scattering": ".em",
56
+ "Transmission": ".em",
57
+ "RIS": ".em",
58
+ "WavefrontState": ".em",
59
+ "propagate_wavefront": ".em",
60
+ }
61
+
62
+
63
+ def __getattr__(name: str) -> object:
64
+ if mod := _LAZY.get(name):
65
+ return getattr(importlib.import_module(mod, __name__), name)
66
+ msg = f"module {__name__!r} has no attribute {name!r}"
67
+ raise AttributeError(msg)
68
+
69
+
70
+ def __dir__() -> list[str]:
71
+ return sorted({*globals(), *_LAZY})
@@ -1,6 +1,7 @@
1
1
  """Electromagnetic (EM) fields utilities."""
2
2
 
3
3
  __all__ = (
4
+ "RIS",
4
5
  "AbstractAntenna",
5
6
  "AbstractFarFieldAntenna",
6
7
  "AbstractFieldSolver",
@@ -8,6 +9,7 @@ __all__ = (
8
9
  "AbstractScatteringPattern",
9
10
  "BackscatteringPattern",
10
11
  "BaseAntenna",
12
+ "Diffraction",
11
13
  "Dipole",
12
14
  "DirectivePattern",
13
15
  "F",
@@ -19,9 +21,14 @@ __all__ = (
19
21
  "LambertianPattern",
20
22
  "Material",
21
23
  "MaterialsDict",
24
+ "PathWavefront",
25
+ "Scattering",
22
26
  "ShortDipole",
23
27
  "ShortDipolePattern",
28
+ "SpecularReflection",
24
29
  "TracedFields",
30
+ "Transmission",
31
+ "WavefrontState",
25
32
  "c",
26
33
  "compute_cir",
27
34
  "compute_received_fields",
@@ -36,6 +43,7 @@ __all__ = (
36
43
  "mu_0",
37
44
  "path_delay",
38
45
  "poynting_vector",
46
+ "propagate_wavefront",
39
47
  "reflection_coefficients",
40
48
  "reflection_matrix",
41
49
  "refraction_coefficients",
@@ -45,7 +53,6 @@ __all__ = (
45
53
  "slab_coefficients",
46
54
  "sp_directions",
47
55
  "sp_rotation_matrix",
48
- "transition_matrices",
49
56
  "transition_matrix",
50
57
  "transmission_matrix",
51
58
  "z_0",
@@ -72,7 +79,14 @@ from ._fresnel import (
72
79
  refractive_index,
73
80
  slab_coefficients,
74
81
  )
75
- from ._interaction_type import InteractionType
82
+ from ._interaction_type import (
83
+ RIS,
84
+ Diffraction,
85
+ InteractionType,
86
+ Scattering,
87
+ SpecularReflection,
88
+ Transmission,
89
+ )
76
90
  from ._material import (
77
91
  AbstractScatteringPattern,
78
92
  BackscatteringPattern,
@@ -90,7 +104,6 @@ from ._pipeline import (
90
104
  reflection_matrix,
91
105
  ris_matrix,
92
106
  scattering_matrix,
93
- transition_matrices,
94
107
  transition_matrix,
95
108
  transmission_matrix,
96
109
  )
@@ -103,3 +116,4 @@ from ._utils import (
103
116
  sp_directions,
104
117
  sp_rotation_matrix,
105
118
  )
119
+ from ._wavefront import PathWavefront, WavefrontState, propagate_wavefront
@@ -113,7 +113,7 @@ class AbstractAntenna(BaseAntenna):
113
113
  Fields can be either real or complex-valued.
114
114
  """
115
115
 
116
- def wavefront_radii( # ruff:ignore[no-self-use]
116
+ def wavefront_radii( # ruff: ignore[no-self-use]
117
117
  self,
118
118
  k_hat: Float[ArrayLike, "*#batch 3"],
119
119
  ) -> (
@@ -247,7 +247,7 @@ class AbstractAntenna(BaseAntenna):
247
247
  ds = du * dv
248
248
 
249
249
  # Power per unit solid angle
250
- U = p / ds # ruff:ignore[non-lowercase-variable-in-function]
250
+ U = p / ds # ruff: ignore[non-lowercase-variable-in-function]
251
251
  p_tot = jnp.sum(p * jnp.sin(v)) / (4 * jnp.pi)
252
252
 
253
253
  return u, v, U / p_tot
@@ -538,9 +538,9 @@ class Dipole(AbstractAntenna):
538
538
 
539
539
  return u, v, 1.5 * jax.lax.integer_pow(sin_theta, 2)
540
540
 
541
- def directive_gain( # ruff:ignore[no-self-use]
541
+ def directive_gain( # ruff: ignore[no-self-use]
542
542
  self,
543
- num_points: int = int(1e2), # ruff:ignore[unused-method-argument]
543
+ num_points: int = int(1e2), # ruff: ignore[unused-method-argument]
544
544
  ) -> Float[Array, ""]:
545
545
  return jnp.array(1.5)
546
546
 
@@ -606,9 +606,9 @@ class AbstractFarFieldAntenna(AbstractAntenna):
606
606
  <differt.em.GeometricFieldSolver.spreading_factor>`.
607
607
  """
608
608
 
609
- def wavefront_radii( # ruff:ignore[no-self-use]
609
+ def wavefront_radii( # ruff: ignore[no-self-use]
610
610
  self,
611
- k_hat: Float[ # ruff:ignore[unused-method-argument]
611
+ k_hat: Float[ # ruff: ignore[unused-method-argument]
612
612
  ArrayLike, "*#batch 3"
613
613
  ],
614
614
  ) -> None:
@@ -3,15 +3,19 @@ from collections.abc import Callable, Sequence
3
3
  from typing import TYPE_CHECKING, Any, Literal
4
4
 
5
5
  import equinox as eqx
6
- import jax
7
6
  import jax.numpy as jnp
8
7
  from jaxtyping import Array, ArrayLike, Bool, Complex, Float, Int, Num
9
8
 
10
9
  from differt.geometry._mesh import Mesh
11
10
  from differt.geometry._paths import TracedPaths
12
11
 
13
- from ._constants import c, z_0
14
- from ._solvers import AbstractFieldSolver, GeometricFieldSolver
12
+ from ._constants import z_0
13
+ from ._pipeline import (
14
+ _resolve_solver_and_frequency,
15
+ compute_cir,
16
+ compute_received_power,
17
+ )
18
+ from ._solvers import AbstractFieldSolver
15
19
 
16
20
  if TYPE_CHECKING or hasattr(typing, "GENERATING_DOCS"):
17
21
  from typing import Self
@@ -19,24 +23,6 @@ else:
19
23
  Self = Any # Because runtime type checking from 'beartype' will fail when combined with 'jaxtyping'
20
24
 
21
25
 
22
- @jax.jit(static_argnames=("coherent", "axis"))
23
- def _compute_power(
24
- fields: Complex[Array, "*batch"],
25
- z_0: Float[ArrayLike, ""] | float = z_0,
26
- coherent: bool = True,
27
- axis: int | None = None,
28
- ) -> Float[Array, "..."]:
29
- if axis is not None:
30
- if coherent:
31
- summed_fields = jnp.sum(fields, axis=axis)
32
- power = jnp.abs(summed_fields) ** 2 / z_0
33
- else:
34
- power = jnp.sum(jnp.abs(fields) ** 2 / z_0, axis=axis)
35
- else:
36
- power = jnp.abs(fields) ** 2 / z_0
37
- return 10.0 * jnp.log10(power)
38
-
39
-
40
26
  class TracedFields(eqx.Module):
41
27
  """
42
28
  A convenient wrapper class around received electromagnetic fields, propagation delays, and masks.
@@ -206,7 +192,9 @@ class TracedFields(eqx.Module):
206
192
  Returns:
207
193
  The received power in dBW.
208
194
  """
209
- return _compute_power(self.fields, z_0=z_0, coherent=coherent, axis=axis)
195
+ return compute_received_power(
196
+ self.fields, z_0=z_0, coherent=coherent, axis=axis
197
+ )
210
198
 
211
199
  def cir(self) -> tuple[Float[Array, "*batch"], Complex[Array, "*batch"]]:
212
200
  """
@@ -271,44 +259,18 @@ class TracedFields(eqx.Module):
271
259
  Returns:
272
260
  A :class:`TracedFields` instance wrapping the computed fields, propagation
273
261
  delays, operating frequency, and validity mask.
274
-
275
- Raises:
276
- ValueError: If an unknown solver name is passed, if ``solver_kwargs``
277
- are supplied alongside a solver instance, or if ``frequency``
278
- is omitted and cannot be inferred from the transmitter antenna.
279
262
  """
280
- if isinstance(solver, str):
281
- if solver == "geometric":
282
- solver_instance: AbstractFieldSolver = GeometricFieldSolver(
283
- **solver_kwargs
284
- )
285
- else:
286
- msg = f"Unknown solver: {solver}"
287
- raise ValueError(msg)
288
- elif solver_kwargs:
289
- msg = "solver_kwargs cannot be used when a solver instance is provided."
290
- raise ValueError(msg)
291
- else:
292
- solver_instance = solver
293
-
294
- if frequency is None:
295
- tx_polarization = getattr(solver_instance, "tx_polarization", None)
296
- frequency_val = getattr(tx_polarization, "frequency", None)
297
- if frequency_val is None:
298
- msg = (
299
- "'frequency' must be provided explicitly, unless "
300
- "'tx_polarization' is an 'AbstractAntenna' instance."
301
- )
302
- raise ValueError(msg)
263
+ wavefront_radii = solver_kwargs.pop("wavefront_radii", None)
264
+ solver_instance, frequency_arr = _resolve_solver_and_frequency(
265
+ solver, frequency, solver_kwargs
266
+ )
267
+ if wavefront_radii is not None and hasattr(solver_instance, "compute_fields"):
268
+ fields = solver_instance.compute_fields(
269
+ paths, mesh, frequency_arr, wavefront_radii=wavefront_radii
270
+ )
303
271
  else:
304
- frequency_val = frequency
305
-
306
- frequency_arr = jnp.asarray(frequency_val)
307
- fields = solver_instance.compute_fields(paths, mesh, frequency_arr)
308
-
309
- path_segments = jnp.diff(paths.vertices, axis=-2)
310
- lengths = jnp.linalg.norm(path_segments, axis=-1).sum(axis=-1)
311
- delay = lengths / c
272
+ fields = solver_instance.compute_fields(paths, mesh, frequency_arr)
273
+ delay, fields = compute_cir(paths, fields)
312
274
 
313
275
  return cls(
314
276
  fields=fields,
@@ -186,11 +186,10 @@ def fresnel_coefficients(
186
186
  cos_theta_i_squared = jax.lax.integer_pow(cos_theta_i, 2)
187
187
  n_r_squared_cos_theta_i = n_r_squared * cos_theta_i
188
188
  dtype = jnp.result_type(n_r, cos_theta_i)
189
- n_r_cos_theta_t = jnp.sqrt(
190
- (n_r_squared + cos_theta_i_squared - 1).astype(
191
- jnp.complex128 if dtype == jnp.float64 else jnp.complex64
192
- )
189
+ c_dtype = (
190
+ jnp.complex128 if dtype in {jnp.float64, jnp.complex128} else jnp.complex64
193
191
  )
192
+ n_r_cos_theta_t = jnp.sqrt((n_r_squared + cos_theta_i_squared - 1).astype(c_dtype))
194
193
  two_cos_theta_i = 2 * cos_theta_i
195
194
 
196
195
  r_s = safe_divide(
@@ -256,8 +255,7 @@ def reflection_coefficients(
256
255
  ... reflection_coefficients,
257
256
  ... sp_directions,
258
257
  ... )
259
- >>> from differt.geometry import normalize
260
- >>> from differt.rt import image_method
258
+ >>> from differt.geometry import image_method, normalize
261
259
 
262
260
  The first step is to define the antenna and the geometry of the scene.
263
261
  Here, we place a dipole antenna above the origin, and generate a
@@ -17,3 +17,15 @@ class InteractionType(IntEnum):
17
17
  """Transmission through a surface."""
18
18
  RIS = 4
19
19
  """Interaction with a Reconfigurable Intelligent Surface (RIS)."""
20
+
21
+
22
+ SpecularReflection = InteractionType.REFLECTION
23
+ """Alias for :attr:`InteractionType.REFLECTION`."""
24
+ Diffraction = InteractionType.DIFFRACTION
25
+ """Alias for :attr:`InteractionType.DIFFRACTION`."""
26
+ Scattering = InteractionType.SCATTERING
27
+ """Alias for :attr:`InteractionType.SCATTERING`."""
28
+ Transmission = InteractionType.TRANSMISSION
29
+ """Alias for :attr:`InteractionType.TRANSMISSION`."""
30
+ RIS = InteractionType.RIS
31
+ """Alias for :attr:`InteractionType.RIS`."""
@@ -1,8 +1,9 @@
1
- # ruff:file-ignore[math-constant]
1
+ # ruff: file-ignore[math-constant]
2
2
 
3
+ import dataclasses
3
4
  import typing
4
5
  from abc import abstractmethod
5
- from collections.abc import Callable, Iterable, Mapping
6
+ from collections.abc import Callable, Iterable, Mapping, MutableMapping
6
7
  from functools import partial
7
8
  from typing import TYPE_CHECKING, Any
8
9
 
@@ -11,6 +12,9 @@ import jax
11
12
  import jax.numpy as jnp
12
13
  from jaxtyping import Array, ArrayLike, Float
13
14
 
15
+ if TYPE_CHECKING:
16
+ import differt_core.geometry
17
+
14
18
  if TYPE_CHECKING or hasattr(typing, "GENERATING_DOCS"):
15
19
  from typing import Self
16
20
  else:
@@ -244,7 +248,7 @@ class BackscatteringPattern(AbstractScatteringPattern):
244
248
 
245
249
 
246
250
  class Material(eqx.Module):
247
- """A class representing a material and it electrical properties."""
251
+ """A class representing a material and its electrical properties."""
248
252
 
249
253
  name: str = eqx.field(static=True)
250
254
  """
@@ -355,7 +359,7 @@ class Material(eqx.Module):
355
359
  Create a material from ITU properties.
356
360
 
357
361
  The ITU-R Recommendation P.2040-4 :cite:`itu-r-2040` defines the electrical properties of a material
358
- using 4 real-valued coefficients: **a**, **b**, **c**, and **c**. The :data:`materials` mapping
362
+ using 4 real-valued coefficients: **a**, **b**, **c**, and **d**. The :data:`materials` mapping
359
363
  is already populated with values from :cite:`itu-r-2040{Tab. 3}`.
360
364
 
361
365
  Args:
@@ -684,3 +688,88 @@ or by its Sionna-compatible alias (e.g., ``'itu_concrete'``).
684
688
  See :ref:`itu-materials-table` for a table of all available ITU radio materials, their aliases, and electrical properties."""
685
689
 
686
690
  del _materials
691
+
692
+
693
+ def _populate_materials(
694
+ scene_materials: Iterable["differt_core.geometry.Material"],
695
+ materials: MutableMapping[str, Material],
696
+ ) -> None:
697
+ """
698
+ Populate ``materials`` in place with the per-shape radio material overrides of a loaded XML scene.
699
+
700
+ Used by :meth:`Scene.load_xml<differt.geometry.Scene.load_xml>` so that a scene's ITU
701
+ radio materials (currently, only ``thickness``, read from a
702
+ ``<float name="thickness" value="..."/>`` child element) are ready to use, without the
703
+ caller having to build a materials mapping by hand.
704
+
705
+ Each overridden material is looked up in ``materials`` by its generic,
706
+ ITU-type-derived name (e.g., ``'itu_glass'``) to find its base electrical properties,
707
+ then stored back keyed the same way -- *unless* another material of the same type in
708
+ ``scene_materials`` disagrees on the override (e.g., two ``type="glass"`` shapes with
709
+ different ``thickness`` values), in which case each is kept under its own, unique XML id
710
+ instead, so they remain distinguishable. This matches how
711
+ :meth:`Scene.load_xml<differt.geometry.Scene.load_xml>` keys
712
+ :attr:`Mesh.material_names<differt.geometry.Mesh.material_names>`.
713
+
714
+ Args:
715
+ scene_materials: The materials of a loaded scene, e.g., the values of
716
+ ``differt_core.geometry.SionnaScene.load_xml(file).materials``.
717
+ materials: The mapping to populate, both as the source of each material's base
718
+ electrical properties (matched by :attr:`Material.name<differt.em._material.Material.name>`,
719
+ or one of its :attr:`Material.aliases<differt.em._material.Material.aliases>`) and as the
720
+ target it is updated in. A material whose name does not match any entry (e.g.,
721
+ a non-ITU, purely visual material) is skipped.
722
+
723
+ Raises:
724
+ ValueError: If a material is already present in ``materials`` with a different,
725
+ already-set ``thickness`` (e.g., from an earlier call with a conflicting scene).
726
+ """
727
+ scene_materials = list(scene_materials)
728
+
729
+ seen: dict[str, float | None] = {}
730
+ non_uniform_names: set[str] = set()
731
+ for mat in scene_materials:
732
+ if mat.name in seen:
733
+ if seen[mat.name] != mat.thickness:
734
+ non_uniform_names.add(mat.name)
735
+ else:
736
+ seen[mat.name] = mat.thickness
737
+
738
+ for mat in scene_materials:
739
+ if mat.thickness is None:
740
+ continue
741
+
742
+ base = materials.get(mat.name)
743
+ if base is None:
744
+ continue
745
+
746
+ is_non_uniform = mat.name in non_uniform_names
747
+ key = mat.id if is_non_uniform else mat.name
748
+ existing = materials.get(key)
749
+
750
+ if (
751
+ existing is not None
752
+ and existing.thickness is not None
753
+ and existing.thickness != mat.thickness
754
+ ):
755
+ msg = (
756
+ f"Material {key!r} is already present with a different 'thickness' "
757
+ f"({existing.thickness!r} != {mat.thickness!r})."
758
+ )
759
+ raise ValueError(msg)
760
+
761
+ value = existing if existing is not None else base
762
+ if is_non_uniform:
763
+ # A brand new key that does not match 'value.name' (nor any of its
764
+ # aliases) would otherwise be silently stored under 'value.name' by
765
+ # 'MaterialsDict.__setitem__', so the material must be renamed to
766
+ # its unique id to be kept distinguishable. 'name' is a static
767
+ # field, so it must be replaced via 'dataclasses.replace' rather
768
+ # than 'eqx.tree_at', which only rewrites pytree leaves.
769
+ value = dataclasses.replace(value, name=key)
770
+ materials[key] = eqx.tree_at(
771
+ lambda m: m.thickness,
772
+ value,
773
+ replace=mat.thickness,
774
+ is_leaf=lambda x: x is None,
775
+ )