differt 0.10.0__tar.gz → 0.12.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.10.0 → differt-0.12.0}/.gitignore +2 -0
- {differt-0.10.0 → differt-0.12.0}/PKG-INFO +5 -5
- {differt-0.10.0 → differt-0.12.0}/README.md +1 -1
- {differt-0.10.0 → differt-0.12.0}/pyproject.toml +3 -3
- differt-0.12.0/src/differt/__init__.py +71 -0
- differt-0.12.0/src/differt/em/__init__.py +119 -0
- {differt-0.10.0 → differt-0.12.0}/src/differt/em/_antenna.py +135 -31
- differt-0.12.0/src/differt/em/_fields.py +281 -0
- {differt-0.10.0 → differt-0.12.0}/src/differt/em/_fresnel.py +68 -2
- differt-0.12.0/src/differt/em/_interaction_type.py +31 -0
- differt-0.12.0/src/differt/em/_material.py +775 -0
- differt-0.12.0/src/differt/em/_pipeline.py +375 -0
- differt-0.12.0/src/differt/em/_solvers.py +1542 -0
- differt-0.12.0/src/differt/em/_utd.py +409 -0
- {differt-0.10.0 → differt-0.12.0}/src/differt/em/_utils.py +34 -43
- differt-0.12.0/src/differt/em/_wavefront.py +447 -0
- {differt-0.10.0 → differt-0.12.0}/src/differt/geometry/__init__.py +14 -15
- differt-0.12.0/src/differt/geometry/_interaction_sites.py +189 -0
- {differt-0.10.0 → differt-0.12.0}/src/differt/geometry/_mesh.py +115 -94
- {differt-0.10.0 → differt-0.12.0}/src/differt/geometry/_paths.py +288 -81
- {differt-0.10.0 → differt-0.12.0}/src/differt/geometry/_scene.py +286 -525
- {differt-0.10.0 → differt-0.12.0}/src/differt/geometry/_sionna.py +5 -5
- {differt-0.10.0 → differt-0.12.0}/src/differt/geometry/_solver_fermat.py +101 -8
- {differt-0.10.0 → differt-0.12.0}/src/differt/geometry/_solver_image_method.py +7 -3
- {differt-0.10.0 → differt-0.12.0}/src/differt/geometry/_utils.py +87 -14
- differt-0.12.0/src/differt/geometry/_warp_utils.py +156 -0
- differt-0.12.0/src/differt/geometry/solvers/__init__.py +41 -0
- differt-0.10.0/src/differt/geometry/_solvers.py → differt-0.12.0/src/differt/geometry/solvers/_base.py +492 -562
- differt-0.12.0/src/differt/geometry/solvers/_dispatch.py +342 -0
- differt-0.12.0/src/differt/geometry/solvers/_exhaustive.py +322 -0
- differt-0.12.0/src/differt/geometry/solvers/_hybrid.py +383 -0
- differt-0.12.0/src/differt/geometry/solvers/_sbr.py +555 -0
- {differt-0.10.0 → differt-0.12.0}/src/differt/plotting/_core.py +13 -11
- {differt-0.10.0 → differt-0.12.0}/src/differt/plotting/_utils.py +8 -10
- {differt-0.10.0 → differt-0.12.0}/src/differt/plugins/deepmimo.py +171 -289
- differt-0.10.0/src/differt/__init__.py +0 -8
- differt-0.10.0/src/differt/em/__init__.py +0 -61
- differt-0.10.0/src/differt/em/_interaction_type.py +0 -13
- differt-0.10.0/src/differt/em/_material.py +0 -289
- differt-0.10.0/src/differt/em/_utd.py +0 -302
- differt-0.10.0/src/differt/rt/__init__.py +0 -45
- differt-0.10.0/src/differt/scene/__init__.py +0 -45
- {differt-0.10.0 → differt-0.12.0}/LICENSE.md +0 -0
- {differt-0.10.0 → differt-0.12.0}/src/differt/_version.py +0 -0
- {differt-0.10.0 → differt-0.12.0}/src/differt/em/_constants.py +0 -0
- {differt-0.10.0 → differt-0.12.0}/src/differt/plotting/__init__.py +0 -0
- {differt-0.10.0 → differt-0.12.0}/src/differt/plugins/__init__.py +0 -0
- {differt-0.10.0 → differt-0.12.0}/src/differt/plugins/_deepmimo_types.py +0 -0
- {differt-0.10.0 → differt-0.12.0}/src/differt/py.typed +0 -0
- {differt-0.10.0 → differt-0.12.0}/src/differt/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: DiffeRT
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.12.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,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.
|
|
23
|
+
Requires-Dist: differt-core==0.12.0
|
|
24
24
|
Requires-Dist: equinox>=0.13.7
|
|
25
25
|
Requires-Dist: filelock>=3.15.4
|
|
26
|
-
Requires-Dist: fpt-jax==0.
|
|
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
|
|
@@ -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.12.0}
|
|
160
160
|
}
|
|
161
161
|
```
|
|
162
162
|
|
|
@@ -15,10 +15,10 @@ classifiers = [
|
|
|
15
15
|
]
|
|
16
16
|
dependencies = [
|
|
17
17
|
"chex>=0.1.86",
|
|
18
|
-
"differt-core==0.
|
|
18
|
+
"differt-core==0.12.0",
|
|
19
19
|
"equinox>=0.13.7",
|
|
20
20
|
"filelock>=3.15.4",
|
|
21
|
-
"fpt-jax==0.
|
|
21
|
+
"fpt-jax==0.2.0",
|
|
22
22
|
"jax>=0.8.1",
|
|
23
23
|
"jaxtyping>=0.3.11",
|
|
24
24
|
"numpy>=1.26.1",
|
|
@@ -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,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})
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"""Electromagnetic (EM) fields utilities."""
|
|
2
|
+
|
|
3
|
+
__all__ = (
|
|
4
|
+
"RIS",
|
|
5
|
+
"AbstractAntenna",
|
|
6
|
+
"AbstractFarFieldAntenna",
|
|
7
|
+
"AbstractFieldSolver",
|
|
8
|
+
"AbstractRadiationPattern",
|
|
9
|
+
"AbstractScatteringPattern",
|
|
10
|
+
"BackscatteringPattern",
|
|
11
|
+
"BaseAntenna",
|
|
12
|
+
"Diffraction",
|
|
13
|
+
"Dipole",
|
|
14
|
+
"DirectivePattern",
|
|
15
|
+
"F",
|
|
16
|
+
"FarFieldDipoleAntenna",
|
|
17
|
+
"GeometricFieldSolver",
|
|
18
|
+
"HWDipolePattern",
|
|
19
|
+
"InteractionType",
|
|
20
|
+
"L_i",
|
|
21
|
+
"LambertianPattern",
|
|
22
|
+
"Material",
|
|
23
|
+
"MaterialsDict",
|
|
24
|
+
"PathWavefront",
|
|
25
|
+
"Scattering",
|
|
26
|
+
"ShortDipole",
|
|
27
|
+
"ShortDipolePattern",
|
|
28
|
+
"SpecularReflection",
|
|
29
|
+
"TracedFields",
|
|
30
|
+
"Transmission",
|
|
31
|
+
"WavefrontState",
|
|
32
|
+
"c",
|
|
33
|
+
"compute_cir",
|
|
34
|
+
"compute_received_fields",
|
|
35
|
+
"compute_received_power",
|
|
36
|
+
"diffraction_coefficients",
|
|
37
|
+
"diffraction_matrix",
|
|
38
|
+
"epsilon_0",
|
|
39
|
+
"fresnel_coefficients",
|
|
40
|
+
"fspl",
|
|
41
|
+
"length_to_delay",
|
|
42
|
+
"materials",
|
|
43
|
+
"mu_0",
|
|
44
|
+
"path_delay",
|
|
45
|
+
"poynting_vector",
|
|
46
|
+
"propagate_wavefront",
|
|
47
|
+
"reflection_coefficients",
|
|
48
|
+
"reflection_matrix",
|
|
49
|
+
"refraction_coefficients",
|
|
50
|
+
"refractive_index",
|
|
51
|
+
"ris_matrix",
|
|
52
|
+
"scattering_matrix",
|
|
53
|
+
"slab_coefficients",
|
|
54
|
+
"sp_directions",
|
|
55
|
+
"sp_rotation_matrix",
|
|
56
|
+
"transition_matrix",
|
|
57
|
+
"transmission_matrix",
|
|
58
|
+
"z_0",
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
from ._antenna import (
|
|
62
|
+
AbstractAntenna,
|
|
63
|
+
AbstractFarFieldAntenna,
|
|
64
|
+
AbstractRadiationPattern,
|
|
65
|
+
BaseAntenna,
|
|
66
|
+
Dipole,
|
|
67
|
+
FarFieldDipoleAntenna,
|
|
68
|
+
HWDipolePattern,
|
|
69
|
+
ShortDipole,
|
|
70
|
+
ShortDipolePattern,
|
|
71
|
+
poynting_vector,
|
|
72
|
+
)
|
|
73
|
+
from ._constants import c, epsilon_0, mu_0, z_0
|
|
74
|
+
from ._fields import TracedFields
|
|
75
|
+
from ._fresnel import (
|
|
76
|
+
fresnel_coefficients,
|
|
77
|
+
reflection_coefficients,
|
|
78
|
+
refraction_coefficients,
|
|
79
|
+
refractive_index,
|
|
80
|
+
slab_coefficients,
|
|
81
|
+
)
|
|
82
|
+
from ._interaction_type import (
|
|
83
|
+
RIS,
|
|
84
|
+
Diffraction,
|
|
85
|
+
InteractionType,
|
|
86
|
+
Scattering,
|
|
87
|
+
SpecularReflection,
|
|
88
|
+
Transmission,
|
|
89
|
+
)
|
|
90
|
+
from ._material import (
|
|
91
|
+
AbstractScatteringPattern,
|
|
92
|
+
BackscatteringPattern,
|
|
93
|
+
DirectivePattern,
|
|
94
|
+
LambertianPattern,
|
|
95
|
+
Material,
|
|
96
|
+
MaterialsDict,
|
|
97
|
+
materials,
|
|
98
|
+
)
|
|
99
|
+
from ._pipeline import (
|
|
100
|
+
compute_cir,
|
|
101
|
+
compute_received_fields,
|
|
102
|
+
compute_received_power,
|
|
103
|
+
diffraction_matrix,
|
|
104
|
+
reflection_matrix,
|
|
105
|
+
ris_matrix,
|
|
106
|
+
scattering_matrix,
|
|
107
|
+
transition_matrix,
|
|
108
|
+
transmission_matrix,
|
|
109
|
+
)
|
|
110
|
+
from ._solvers import AbstractFieldSolver, GeometricFieldSolver
|
|
111
|
+
from ._utd import F, L_i, diffraction_coefficients
|
|
112
|
+
from ._utils import (
|
|
113
|
+
fspl,
|
|
114
|
+
length_to_delay,
|
|
115
|
+
path_delay,
|
|
116
|
+
sp_directions,
|
|
117
|
+
sp_rotation_matrix,
|
|
118
|
+
)
|
|
119
|
+
from ._wavefront import PathWavefront, WavefrontState, propagate_wavefront
|
|
@@ -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
|
|
|
@@ -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,
|
|
@@ -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 # ruff:ignore[non-lowercase-variable-in-function]
|
|
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
|
|
|
@@ -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( # ruff:ignore[no-self-use]
|
|
541
|
+
def directive_gain( # ruff: ignore[no-self-use]
|
|
476
542
|
self,
|
|
477
|
-
num_points: int = int(1e2), # ruff:ignore[unused-method-argument]
|
|
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)
|
|
519
585
|
|
|
520
586
|
|
|
521
|
-
class
|
|
522
|
-
"""
|
|
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
|
+
|
|
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)
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
class AbstractRadiationPattern(BaseAntenna):
|
|
633
|
+
"""Abstract base class for antenna radiation patterns."""
|
|
523
634
|
|
|
524
635
|
@abstractmethod
|
|
525
636
|
def polarization_vectors(
|
|
@@ -659,8 +770,12 @@ class RadiationPattern(BaseAntenna):
|
|
|
659
770
|
)
|
|
660
771
|
|
|
661
772
|
|
|
662
|
-
class HWDipolePattern(
|
|
663
|
-
"""
|
|
773
|
+
class HWDipolePattern(AbstractRadiationPattern):
|
|
774
|
+
"""A half-wave dipole radiation pattern.
|
|
775
|
+
|
|
776
|
+
Warning:
|
|
777
|
+
Not implemented yet.
|
|
778
|
+
"""
|
|
664
779
|
|
|
665
780
|
direction: Float[Array, "3"]
|
|
666
781
|
"""The dipole direction."""
|
|
@@ -669,22 +784,11 @@ class HWDipolePattern(RadiationPattern):
|
|
|
669
784
|
self,
|
|
670
785
|
r: Float[ArrayLike, "*#batch 3"],
|
|
671
786
|
) -> tuple[Float[Array, "*batch 3"], Float[Array, "*batch 3"]]:
|
|
672
|
-
r = jnp.asarray(r)
|
|
673
|
-
r_hat, r = normalize(r - self.center, keepdims=True)
|
|
674
|
-
|
|
675
|
-
cos_theta = jnp.sum(r_hat * self.direction, axis=-1)
|
|
676
|
-
sin_theta = jnp.sqrt(1 - cos_theta**2)
|
|
677
|
-
|
|
678
|
-
d = 1.640922376984585 # Directive gain: 4 / Cin(2*pi)
|
|
679
|
-
|
|
680
|
-
cos_theta = jnp.sum(d * d, axis=-1)
|
|
681
|
-
sin_theta = jnp.sin(d)
|
|
682
|
-
_d = safe_divide(jnp.cos(0.5 * jnp.pi * cos_theta), sin_theta)
|
|
683
787
|
raise NotImplementedError
|
|
684
788
|
|
|
685
789
|
|
|
686
|
-
class ShortDipolePattern(
|
|
687
|
-
"""
|
|
790
|
+
class ShortDipolePattern(AbstractRadiationPattern):
|
|
791
|
+
"""A short dipole radiation pattern."""
|
|
688
792
|
|
|
689
793
|
direction: Float[Array, "3"]
|
|
690
794
|
"""The dipole direction."""
|