differt 0.9.1__tar.gz → 0.11.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.1 → differt-0.11.0}/.gitignore +5 -2
- {differt-0.9.1 → differt-0.11.0}/PKG-INFO +5 -5
- {differt-0.9.1 → differt-0.11.0}/README.md +1 -1
- {differt-0.9.1 → differt-0.11.0}/pyproject.toml +3 -3
- differt-0.11.0/src/differt/em/__init__.py +105 -0
- {differt-0.9.1 → differt-0.11.0}/src/differt/em/_antenna.py +143 -41
- differt-0.11.0/src/differt/em/_fields.py +319 -0
- {differt-0.9.1 → differt-0.11.0}/src/differt/em/_fresnel.py +94 -27
- {differt-0.9.1 → differt-0.11.0}/src/differt/em/_interaction_type.py +7 -1
- differt-0.11.0/src/differt/em/_material.py +686 -0
- differt-0.11.0/src/differt/em/_pipeline.py +363 -0
- differt-0.11.0/src/differt/em/_solvers.py +1395 -0
- differt-0.11.0/src/differt/em/_utd.py +406 -0
- {differt-0.9.1 → differt-0.11.0}/src/differt/em/_utils.py +44 -85
- differt-0.11.0/src/differt/geometry/__init__.py +112 -0
- differt-0.9.1/src/differt/geometry/_triangle_mesh.py → differt-0.11.0/src/differt/geometry/_mesh.py +188 -374
- {differt-0.9.1 → differt-0.11.0}/src/differt/geometry/_paths.py +282 -134
- differt-0.9.1/src/differt/scene/_triangle_scene.py → differt-0.11.0/src/differt/geometry/_scene.py +516 -843
- {differt-0.9.1/src/differt/scene → differt-0.11.0/src/differt/geometry}/_sionna.py +5 -5
- differt-0.9.1/src/differt/rt/_fermat.py → differt-0.11.0/src/differt/geometry/_solver_fermat.py +59 -63
- differt-0.9.1/src/differt/rt/_image_method.py → differt-0.11.0/src/differt/geometry/_solver_image_method.py +82 -85
- differt-0.11.0/src/differt/geometry/_solvers.py +1914 -0
- differt-0.11.0/src/differt/geometry/_utils.py +2030 -0
- differt-0.11.0/src/differt/geometry/_warp_utils.py +202 -0
- {differt-0.9.1 → differt-0.11.0}/src/differt/plotting/_core.py +18 -11
- {differt-0.9.1 → differt-0.11.0}/src/differt/plotting/_utils.py +13 -11
- {differt-0.9.1 → differt-0.11.0}/src/differt/plugins/deepmimo.py +309 -196
- differt-0.11.0/src/differt/rt/__init__.py +45 -0
- differt-0.11.0/src/differt/scene/__init__.py +47 -0
- differt-0.9.1/src/differt/em/__init__.py +0 -61
- differt-0.9.1/src/differt/em/_material.py +0 -289
- differt-0.9.1/src/differt/em/_utd.py +0 -303
- differt-0.9.1/src/differt/geometry/__init__.py +0 -45
- differt-0.9.1/src/differt/geometry/_utils.py +0 -988
- differt-0.9.1/src/differt/rt/__init__.py +0 -36
- differt-0.9.1/src/differt/rt/_utils.py +0 -988
- differt-0.9.1/src/differt/scene/__init__.py +0 -11
- {differt-0.9.1 → differt-0.11.0}/LICENSE.md +0 -0
- {differt-0.9.1 → differt-0.11.0}/src/differt/__init__.py +0 -0
- {differt-0.9.1 → differt-0.11.0}/src/differt/_version.py +0 -0
- {differt-0.9.1 → differt-0.11.0}/src/differt/em/_constants.py +0 -0
- {differt-0.9.1 → differt-0.11.0}/src/differt/plotting/__init__.py +0 -0
- {differt-0.9.1 → differt-0.11.0}/src/differt/plugins/__init__.py +0 -0
- {differt-0.9.1 → differt-0.11.0}/src/differt/plugins/_deepmimo_types.py +0 -0
- {differt-0.9.1 → differt-0.11.0}/src/differt/py.typed +0 -0
- {differt-0.9.1 → differt-0.11.0}/src/differt/utils.py +0 -0
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# Python build files and cache
|
|
2
2
|
|
|
3
3
|
*.pyc
|
|
4
|
+
*.pyd
|
|
4
5
|
*.so
|
|
5
6
|
*.egg-info
|
|
6
7
|
|
|
8
|
+
.venv/
|
|
7
9
|
dist/
|
|
8
10
|
target/
|
|
11
|
+
__pycache__/
|
|
9
12
|
|
|
10
13
|
# Docs
|
|
11
14
|
|
|
@@ -15,8 +18,8 @@ docs/source/reference/_autosummary/
|
|
|
15
18
|
|
|
16
19
|
# Sionna data
|
|
17
20
|
|
|
18
|
-
differt/src/differt/
|
|
19
|
-
differt/src/differt/
|
|
21
|
+
differt/src/differt/geometry/scenes.lock
|
|
22
|
+
differt/src/differt/geometry/scenes/
|
|
20
23
|
|
|
21
24
|
# Notebooks
|
|
22
25
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: DiffeRT
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.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.11.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.11.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.11.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"]
|
|
@@ -46,7 +46,7 @@ vispy = [
|
|
|
46
46
|
vispy-backend = ["PyQt6>=6.6.1"]
|
|
47
47
|
|
|
48
48
|
[project.scripts]
|
|
49
|
-
"download-sionna-scenes" = "differt.
|
|
49
|
+
"download-sionna-scenes" = "differt.geometry._sionna:main"
|
|
50
50
|
|
|
51
51
|
[project.urls]
|
|
52
52
|
Changelog = "https://github.com/jeertmans/DiffeRT/releases"
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""Electromagnetic (EM) fields utilities."""
|
|
2
|
+
|
|
3
|
+
__all__ = (
|
|
4
|
+
"AbstractAntenna",
|
|
5
|
+
"AbstractFarFieldAntenna",
|
|
6
|
+
"AbstractFieldSolver",
|
|
7
|
+
"AbstractRadiationPattern",
|
|
8
|
+
"AbstractScatteringPattern",
|
|
9
|
+
"BackscatteringPattern",
|
|
10
|
+
"BaseAntenna",
|
|
11
|
+
"Dipole",
|
|
12
|
+
"DirectivePattern",
|
|
13
|
+
"F",
|
|
14
|
+
"FarFieldDipoleAntenna",
|
|
15
|
+
"GeometricFieldSolver",
|
|
16
|
+
"HWDipolePattern",
|
|
17
|
+
"InteractionType",
|
|
18
|
+
"L_i",
|
|
19
|
+
"LambertianPattern",
|
|
20
|
+
"Material",
|
|
21
|
+
"MaterialsDict",
|
|
22
|
+
"ShortDipole",
|
|
23
|
+
"ShortDipolePattern",
|
|
24
|
+
"TracedFields",
|
|
25
|
+
"c",
|
|
26
|
+
"compute_cir",
|
|
27
|
+
"compute_received_fields",
|
|
28
|
+
"compute_received_power",
|
|
29
|
+
"diffraction_coefficients",
|
|
30
|
+
"diffraction_matrix",
|
|
31
|
+
"epsilon_0",
|
|
32
|
+
"fresnel_coefficients",
|
|
33
|
+
"fspl",
|
|
34
|
+
"length_to_delay",
|
|
35
|
+
"materials",
|
|
36
|
+
"mu_0",
|
|
37
|
+
"path_delay",
|
|
38
|
+
"poynting_vector",
|
|
39
|
+
"reflection_coefficients",
|
|
40
|
+
"reflection_matrix",
|
|
41
|
+
"refraction_coefficients",
|
|
42
|
+
"refractive_index",
|
|
43
|
+
"ris_matrix",
|
|
44
|
+
"scattering_matrix",
|
|
45
|
+
"slab_coefficients",
|
|
46
|
+
"sp_directions",
|
|
47
|
+
"sp_rotation_matrix",
|
|
48
|
+
"transition_matrices",
|
|
49
|
+
"transition_matrix",
|
|
50
|
+
"transmission_matrix",
|
|
51
|
+
"z_0",
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
from ._antenna import (
|
|
55
|
+
AbstractAntenna,
|
|
56
|
+
AbstractFarFieldAntenna,
|
|
57
|
+
AbstractRadiationPattern,
|
|
58
|
+
BaseAntenna,
|
|
59
|
+
Dipole,
|
|
60
|
+
FarFieldDipoleAntenna,
|
|
61
|
+
HWDipolePattern,
|
|
62
|
+
ShortDipole,
|
|
63
|
+
ShortDipolePattern,
|
|
64
|
+
poynting_vector,
|
|
65
|
+
)
|
|
66
|
+
from ._constants import c, epsilon_0, mu_0, z_0
|
|
67
|
+
from ._fields import TracedFields
|
|
68
|
+
from ._fresnel import (
|
|
69
|
+
fresnel_coefficients,
|
|
70
|
+
reflection_coefficients,
|
|
71
|
+
refraction_coefficients,
|
|
72
|
+
refractive_index,
|
|
73
|
+
slab_coefficients,
|
|
74
|
+
)
|
|
75
|
+
from ._interaction_type import InteractionType
|
|
76
|
+
from ._material import (
|
|
77
|
+
AbstractScatteringPattern,
|
|
78
|
+
BackscatteringPattern,
|
|
79
|
+
DirectivePattern,
|
|
80
|
+
LambertianPattern,
|
|
81
|
+
Material,
|
|
82
|
+
MaterialsDict,
|
|
83
|
+
materials,
|
|
84
|
+
)
|
|
85
|
+
from ._pipeline import (
|
|
86
|
+
compute_cir,
|
|
87
|
+
compute_received_fields,
|
|
88
|
+
compute_received_power,
|
|
89
|
+
diffraction_matrix,
|
|
90
|
+
reflection_matrix,
|
|
91
|
+
ris_matrix,
|
|
92
|
+
scattering_matrix,
|
|
93
|
+
transition_matrices,
|
|
94
|
+
transition_matrix,
|
|
95
|
+
transmission_matrix,
|
|
96
|
+
)
|
|
97
|
+
from ._solvers import AbstractFieldSolver, GeometricFieldSolver
|
|
98
|
+
from ._utd import F, L_i, diffraction_coefficients
|
|
99
|
+
from ._utils import (
|
|
100
|
+
fspl,
|
|
101
|
+
length_to_delay,
|
|
102
|
+
path_delay,
|
|
103
|
+
sp_directions,
|
|
104
|
+
sp_rotation_matrix,
|
|
105
|
+
)
|
|
@@ -7,13 +7,12 @@ import jax
|
|
|
7
7
|
import jax.numpy as jnp
|
|
8
8
|
from jaxtyping import Array, ArrayLike, Float, Inexact
|
|
9
9
|
|
|
10
|
-
from differt.geometry import (
|
|
10
|
+
from differt.geometry._utils import (
|
|
11
11
|
cartesian_to_spherical,
|
|
12
12
|
normalize,
|
|
13
13
|
spherical_to_cartesian,
|
|
14
14
|
)
|
|
15
15
|
from differt.plotting import PlotOutput, draw_surface
|
|
16
|
-
from differt.utils import safe_divide
|
|
17
16
|
|
|
18
17
|
from ._constants import c, epsilon_0, mu_0
|
|
19
18
|
|
|
@@ -39,7 +38,7 @@ def poynting_vector(
|
|
|
39
38
|
|
|
40
39
|
|
|
41
40
|
class BaseAntenna(eqx.Module):
|
|
42
|
-
"""An antenna class, base class for :class:`
|
|
41
|
+
"""An antenna class, base class for :class:`AbstractAntenna` and :class:`AbstractRadiationPattern`."""
|
|
43
42
|
|
|
44
43
|
frequency: Float[Array, ""]
|
|
45
44
|
"""The frequency :math:`f` at which the antenna is operating."""
|
|
@@ -78,8 +77,8 @@ class BaseAntenna(eqx.Module):
|
|
|
78
77
|
return self.wavelength**2 / (4 * jnp.pi)
|
|
79
78
|
|
|
80
79
|
|
|
81
|
-
class
|
|
82
|
-
"""
|
|
80
|
+
class AbstractAntenna(BaseAntenna):
|
|
81
|
+
"""Abstract base class for antennas."""
|
|
83
82
|
|
|
84
83
|
@property
|
|
85
84
|
@abstractmethod
|
|
@@ -88,7 +87,7 @@ class Antenna(BaseAntenna):
|
|
|
88
87
|
|
|
89
88
|
This is the maximal value of the Poynting vector at a distance
|
|
90
89
|
of one meter from this antenna, multiplied by the area of the sphere
|
|
91
|
-
(:math:`4\
|
|
90
|
+
(:math:`4\pi`),
|
|
92
91
|
to obtain a power.
|
|
93
92
|
"""
|
|
94
93
|
|
|
@@ -102,8 +101,8 @@ class Antenna(BaseAntenna):
|
|
|
102
101
|
Compute electric and magnetic fields in vacuum at given position and (optional) time.
|
|
103
102
|
|
|
104
103
|
Args:
|
|
105
|
-
r:
|
|
106
|
-
t:
|
|
104
|
+
r: Position vector relative to the antenna center.
|
|
105
|
+
t: Time instant.
|
|
107
106
|
|
|
108
107
|
If not provided, initial time instant
|
|
109
108
|
is assumed.
|
|
@@ -114,6 +113,73 @@ class Antenna(BaseAntenna):
|
|
|
114
113
|
Fields can be either real or complex-valued.
|
|
115
114
|
"""
|
|
116
115
|
|
|
116
|
+
def wavefront_radii( # ruff:ignore[no-self-use]
|
|
117
|
+
self,
|
|
118
|
+
k_hat: Float[ArrayLike, "*#batch 3"],
|
|
119
|
+
) -> (
|
|
120
|
+
Float[Array, "*batch"]
|
|
121
|
+
| tuple[
|
|
122
|
+
Float[Array, "*batch"],
|
|
123
|
+
Float[Array, "*batch 3"],
|
|
124
|
+
Float[Array, "*batch"],
|
|
125
|
+
Float[Array, "*batch 3"],
|
|
126
|
+
]
|
|
127
|
+
| None
|
|
128
|
+
):
|
|
129
|
+
r"""
|
|
130
|
+
Return the radii of curvature of the wavefront this antenna emits, in the given direction(s).
|
|
131
|
+
|
|
132
|
+
This is an *offset* distance (or pair of distances) -- the same
|
|
133
|
+
quantity as, and with the same sign convention as,
|
|
134
|
+
``tx_wavefront_radii`` -- added to the geometric path length by
|
|
135
|
+
:meth:`GeometricFieldSolver.spreading_factor
|
|
136
|
+
<differt.em.GeometricFieldSolver.spreading_factor>`, rather than
|
|
137
|
+
the (generally much larger, and direction-*independent* only for
|
|
138
|
+
an isotropic source) total radius of curvature at some distant
|
|
139
|
+
observation point. :meth:`GeometricFieldSolver.compute_fields
|
|
140
|
+
<differt.em.GeometricFieldSolver.compute_fields>` calls this with
|
|
141
|
+
the direction of the first path segment (leaving the
|
|
142
|
+
transmitter) whenever ``tx_polarization`` is set to an
|
|
143
|
+
:class:`AbstractAntenna` instance, using the result *instead of* the
|
|
144
|
+
solver's own ``tx_wavefront_radii`` attribute.
|
|
145
|
+
|
|
146
|
+
A single position-like argument cannot, by itself, encode an
|
|
147
|
+
astigmatic wavefront's orientation (its two principal radii apply
|
|
148
|
+
along two specific, generally direction-dependent axes, not just
|
|
149
|
+
"the wavefront's curvature at that point"); this is why the
|
|
150
|
+
argument here is the propagation *direction* rather than a
|
|
151
|
+
position -- see the ``(rho_s, s_hat, rho_p, p_hat)`` return case
|
|
152
|
+
below.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
k_hat: The (unit-length) direction of propagation away from
|
|
156
|
+
this antenna, towards the observation point.
|
|
157
|
+
|
|
158
|
+
Returns:
|
|
159
|
+
:data:`None` for a planar wavefront (the far-field, plane-wave
|
|
160
|
+
approximation -- see :class:`AbstractFarFieldAntenna`); a single value
|
|
161
|
+
for an isotropic (spherical) wavefront, the same in every
|
|
162
|
+
direction; or a ``(rho_s, s_hat, rho_p, p_hat)`` 4-tuple for a
|
|
163
|
+
general astigmatic wavefront, where ``rho_s`` and ``rho_p``
|
|
164
|
+
are the two principal radii and ``s_hat``/``p_hat`` are unit
|
|
165
|
+
vectors (orthogonal to ``k_hat`` and to each other) giving
|
|
166
|
+
the direction each one applies along -- the same (explicit
|
|
167
|
+
vector pair, rather than a bare angle) convention used
|
|
168
|
+
elsewhere in this module for a local s-/p-plane basis, see
|
|
169
|
+
:func:`sp_directions<differt.em.sp_directions>` and
|
|
170
|
+
:func:`sp_rotation_matrix<differt.em.sp_rotation_matrix>`
|
|
171
|
+
(which a subclass reporting an astigmatic wavefront can reuse
|
|
172
|
+
to derive ``s_hat``/``p_hat`` from ``k_hat`` and its own
|
|
173
|
+
fixed reference axis, e.g. :attr:`Dipole.moment`, exactly as
|
|
174
|
+
:func:`sp_directions<differt.em.sp_directions>` derives a
|
|
175
|
+
local basis from a ray direction and a surface normal).
|
|
176
|
+
|
|
177
|
+
The default implementation returns ``0`` for every direction,
|
|
178
|
+
i.e., an ideal point source located exactly at this
|
|
179
|
+
antenna's :attr:`~BaseAntenna.center` (no offset at all).
|
|
180
|
+
"""
|
|
181
|
+
return jnp.zeros(jnp.shape(jnp.asarray(k_hat))[:-1])
|
|
182
|
+
|
|
117
183
|
@eqx.filter_jit
|
|
118
184
|
def poynting_vector(
|
|
119
185
|
self,
|
|
@@ -124,8 +190,8 @@ class Antenna(BaseAntenna):
|
|
|
124
190
|
Compute the Poynting vector in vacuum at given position and (optional) time.
|
|
125
191
|
|
|
126
192
|
Args:
|
|
127
|
-
r:
|
|
128
|
-
t:
|
|
193
|
+
r: Position vector relative to the antenna center.
|
|
194
|
+
t: Time instant.
|
|
129
195
|
|
|
130
196
|
If not provided, initial time instant
|
|
131
197
|
is assumed.
|
|
@@ -181,7 +247,7 @@ class Antenna(BaseAntenna):
|
|
|
181
247
|
ds = du * dv
|
|
182
248
|
|
|
183
249
|
# Power per unit solid angle
|
|
184
|
-
U = p / ds #
|
|
250
|
+
U = p / ds # ruff:ignore[non-lowercase-variable-in-function]
|
|
185
251
|
p_tot = jnp.sum(p * jnp.sin(v)) / (4 * jnp.pi)
|
|
186
252
|
|
|
187
253
|
return u, v, U / p_tot
|
|
@@ -263,7 +329,7 @@ class Antenna(BaseAntenna):
|
|
|
263
329
|
)
|
|
264
330
|
|
|
265
331
|
|
|
266
|
-
class Dipole(
|
|
332
|
+
class Dipole(AbstractAntenna):
|
|
267
333
|
r"""
|
|
268
334
|
A simple electrical (or Hertzian) dipole.
|
|
269
335
|
|
|
@@ -319,10 +385,10 @@ class Dipole(Antenna):
|
|
|
319
385
|
>>> ax = fig.add_subplot(
|
|
320
386
|
... projection="polar", facecolor="lightgoldenrodyellow"
|
|
321
387
|
... )
|
|
322
|
-
>>> for ratio in [0.5, 1.0, 1.25, 1.5, 2.0]:
|
|
388
|
+
>>> for ratio in [0.5, 1.0, 1.25, 1.5, 2.0]: # doctest: +SKIP
|
|
323
389
|
... ant = Dipole(1e9, ratio)
|
|
324
390
|
... power = jnp.linalg.norm(ant.poynting_vector(r), axis=-1)
|
|
325
|
-
...
|
|
391
|
+
... ax.plot(theta, power, label=rf"$\ell/\lambda = {ratio:1.2f}$")
|
|
326
392
|
>>>
|
|
327
393
|
>>> ax.tick_params(grid_color="palegoldenrod")
|
|
328
394
|
>>> ax.set_rscale("log")
|
|
@@ -468,13 +534,13 @@ class Dipole(Antenna):
|
|
|
468
534
|
|
|
469
535
|
p = self.moment / jnp.linalg.norm(self.moment)
|
|
470
536
|
|
|
471
|
-
sin_theta = jnp.cross(r, p)
|
|
537
|
+
sin_theta = jnp.linalg.norm(jnp.cross(r, p), axis=-1)
|
|
472
538
|
|
|
473
539
|
return u, v, 1.5 * jax.lax.integer_pow(sin_theta, 2)
|
|
474
540
|
|
|
475
|
-
def directive_gain( #
|
|
541
|
+
def directive_gain( # ruff:ignore[no-self-use]
|
|
476
542
|
self,
|
|
477
|
-
num_points: int = int(1e2), #
|
|
543
|
+
num_points: int = int(1e2), # ruff:ignore[unused-method-argument]
|
|
478
544
|
) -> Float[Array, ""]:
|
|
479
545
|
return jnp.array(1.5)
|
|
480
546
|
|
|
@@ -488,7 +554,7 @@ class ShortDipole(Dipole):
|
|
|
488
554
|
However, fields are only derived for far field.
|
|
489
555
|
|
|
490
556
|
Warning:
|
|
491
|
-
Not implemented
|
|
557
|
+
Not implemented yet.
|
|
492
558
|
"""
|
|
493
559
|
|
|
494
560
|
@eqx.filter_jit
|
|
@@ -508,18 +574,63 @@ class ShortDipole(Dipole):
|
|
|
508
574
|
Float[Array, "2*{num_points} {num_points}"],
|
|
509
575
|
]:
|
|
510
576
|
# Bypass Dipole's specialized implementation
|
|
511
|
-
return
|
|
577
|
+
return AbstractAntenna.directivity(self, num_points=num_points)
|
|
512
578
|
|
|
513
579
|
def directive_gain(
|
|
514
580
|
self,
|
|
515
581
|
num_points: int = int(1e2),
|
|
516
582
|
) -> Float[Array, ""]:
|
|
517
583
|
# Bypass Dipole's specialized implementation
|
|
518
|
-
return
|
|
584
|
+
return AbstractAntenna.directive_gain(self, num_points=num_points)
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
class AbstractFarFieldAntenna(AbstractAntenna):
|
|
588
|
+
"""
|
|
589
|
+
Abstract base class for antennas that are only ever used in the far field.
|
|
590
|
+
|
|
591
|
+
Subclass this (instead of :class:`AbstractAntenna`) when your antenna's
|
|
592
|
+
intended use is the far field, i.e., a locally planar wavefront:
|
|
593
|
+
:meth:`wavefront_radii` is implemented once and for all here, always
|
|
594
|
+
returning :data:`None`, so subclasses only need to implement
|
|
595
|
+
:meth:`~AbstractAntenna.fields` and :attr:`~AbstractAntenna.reference_power` (exactly
|
|
596
|
+
like a plain :class:`AbstractAntenna`).
|
|
597
|
+
|
|
598
|
+
When used as ``tx_polarization`` in
|
|
599
|
+
:meth:`GeometricFieldSolver.compute_fields
|
|
600
|
+
<differt.em.GeometricFieldSolver.compute_fields>`, this makes the
|
|
601
|
+
solver treat the source as an ideal point source infinitely far away
|
|
602
|
+
(plane-wave incidence), regardless of whatever ``tx_wavefront_radii``
|
|
603
|
+
attribute the solver was configured with -- see
|
|
604
|
+
:meth:`AbstractAntenna.wavefront_radii` and
|
|
605
|
+
:meth:`GeometricFieldSolver.spreading_factor
|
|
606
|
+
<differt.em.GeometricFieldSolver.spreading_factor>`.
|
|
607
|
+
"""
|
|
608
|
+
|
|
609
|
+
def wavefront_radii( # ruff:ignore[no-self-use]
|
|
610
|
+
self,
|
|
611
|
+
k_hat: Float[ # ruff:ignore[unused-method-argument]
|
|
612
|
+
ArrayLike, "*#batch 3"
|
|
613
|
+
],
|
|
614
|
+
) -> None:
|
|
615
|
+
"""Return :data:`None` (a planar wavefront), unconditionally."""
|
|
616
|
+
return
|
|
617
|
+
|
|
519
618
|
|
|
619
|
+
class FarFieldDipoleAntenna(AbstractFarFieldAntenna, Dipole):
|
|
620
|
+
"""
|
|
621
|
+
A :class:`Dipole` restricted to the far field (a planar, rather than spherical, wavefront).
|
|
622
|
+
|
|
623
|
+
Otherwise identical to :class:`Dipole` (same constructor, same
|
|
624
|
+
:meth:`~AbstractAntenna.fields`); only :meth:`~AbstractFarFieldAntenna.wavefront_radii`
|
|
625
|
+
differs, see :class:`AbstractFarFieldAntenna`.
|
|
626
|
+
"""
|
|
627
|
+
|
|
628
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
629
|
+
Dipole.__init__(self, *args, **kwargs)
|
|
520
630
|
|
|
521
|
-
|
|
522
|
-
|
|
631
|
+
|
|
632
|
+
class AbstractRadiationPattern(BaseAntenna):
|
|
633
|
+
"""Abstract base class for antenna radiation patterns."""
|
|
523
634
|
|
|
524
635
|
@abstractmethod
|
|
525
636
|
def polarization_vectors(
|
|
@@ -530,12 +641,10 @@ class RadiationPattern(BaseAntenna):
|
|
|
530
641
|
Compute s and p polarization vectors.
|
|
531
642
|
|
|
532
643
|
Args:
|
|
533
|
-
r:
|
|
644
|
+
r: Position vector relative to the antenna center.
|
|
534
645
|
|
|
535
646
|
Returns:
|
|
536
|
-
The
|
|
537
|
-
|
|
538
|
-
Fields can be either real or complex-valued.
|
|
647
|
+
The s and p polarization unit vectors.
|
|
539
648
|
"""
|
|
540
649
|
|
|
541
650
|
def directivity(
|
|
@@ -661,8 +770,12 @@ class RadiationPattern(BaseAntenna):
|
|
|
661
770
|
)
|
|
662
771
|
|
|
663
772
|
|
|
664
|
-
class HWDipolePattern(
|
|
665
|
-
"""
|
|
773
|
+
class HWDipolePattern(AbstractRadiationPattern):
|
|
774
|
+
"""A half-wave dipole radiation pattern.
|
|
775
|
+
|
|
776
|
+
Warning:
|
|
777
|
+
Not implemented yet.
|
|
778
|
+
"""
|
|
666
779
|
|
|
667
780
|
direction: Float[Array, "3"]
|
|
668
781
|
"""The dipole direction."""
|
|
@@ -671,22 +784,11 @@ class HWDipolePattern(RadiationPattern):
|
|
|
671
784
|
self,
|
|
672
785
|
r: Float[ArrayLike, "*#batch 3"],
|
|
673
786
|
) -> tuple[Float[Array, "*batch 3"], Float[Array, "*batch 3"]]:
|
|
674
|
-
r = jnp.asarray(r)
|
|
675
|
-
r_hat, r = normalize(r - self.center, keepdims=True)
|
|
676
|
-
|
|
677
|
-
cos_theta = jnp.sum(r_hat * self.direction, axis=-1)
|
|
678
|
-
sin_theta = jnp.sqrt(1 - cos_theta**2)
|
|
679
|
-
|
|
680
|
-
d = 1.640922376984585 # Directive gain: 4 / Cin(2*pi)
|
|
681
|
-
|
|
682
|
-
cos_theta = jnp.sum(d * d, axis=-1)
|
|
683
|
-
sin_theta = jnp.sin(d)
|
|
684
|
-
_d = safe_divide(jnp.cos(0.5 * jnp.pi * cos_theta), sin_theta)
|
|
685
787
|
raise NotImplementedError
|
|
686
788
|
|
|
687
789
|
|
|
688
|
-
class ShortDipolePattern(
|
|
689
|
-
"""
|
|
790
|
+
class ShortDipolePattern(AbstractRadiationPattern):
|
|
791
|
+
"""A short dipole radiation pattern."""
|
|
690
792
|
|
|
691
793
|
direction: Float[Array, "3"]
|
|
692
794
|
"""The dipole direction."""
|