differt 0.6.1__tar.gz → 0.6.2__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.6.1 → differt-0.6.2}/PKG-INFO +4 -4
- {differt-0.6.1 → differt-0.6.2}/README.md +1 -1
- {differt-0.6.1 → differt-0.6.2}/pyproject.toml +2 -2
- {differt-0.6.1 → differt-0.6.2}/src/differt/em/_utils.py +2 -13
- {differt-0.6.1 → differt-0.6.2}/src/differt/geometry/_utils.py +0 -5
- {differt-0.6.1 → differt-0.6.2}/src/differt/rt/_fermat.py +33 -93
- {differt-0.6.1 → differt-0.6.2}/.gitignore +0 -0
- {differt-0.6.1 → differt-0.6.2}/LICENSE.md +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/__init__.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/_version.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/em/__init__.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/em/_antenna.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/em/_constants.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/em/_fresnel.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/em/_interaction_type.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/em/_material.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/em/_utd.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/geometry/__init__.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/geometry/_paths.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/geometry/_triangle_mesh.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/plotting/__init__.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/plotting/_core.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/plotting/_utils.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/plugins/__init__.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/plugins/_deepmimo_types.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/plugins/deepmimo.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/py.typed +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/rt/__init__.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/rt/_image_method.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/rt/_utils.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/scene/__init__.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/scene/_sionna.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/scene/_triangle_scene.py +0 -0
- {differt-0.6.1 → differt-0.6.2}/src/differt/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: DiffeRT
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.2
|
|
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
|
|
@@ -21,13 +21,13 @@ Classifier: Programming Language :: Python :: Free Threading
|
|
|
21
21
|
Classifier: Topic :: Scientific/Engineering
|
|
22
22
|
Requires-Python: >=3.11
|
|
23
23
|
Requires-Dist: chex>=0.1.86
|
|
24
|
-
Requires-Dist: differt-core==0.6.
|
|
24
|
+
Requires-Dist: differt-core==0.6.2
|
|
25
25
|
Requires-Dist: equinox>=0.13.1
|
|
26
26
|
Requires-Dist: filelock>=3.15.4
|
|
27
|
+
Requires-Dist: fpt-jax==0.1.0
|
|
27
28
|
Requires-Dist: jax>=0.7.2
|
|
28
29
|
Requires-Dist: jaxtyping>=0.3.2
|
|
29
30
|
Requires-Dist: numpy>=1.26.1
|
|
30
|
-
Requires-Dist: optax>=0.1.7
|
|
31
31
|
Requires-Dist: requests>=2.32.0
|
|
32
32
|
Requires-Dist: tqdm>=4.66.2
|
|
33
33
|
Provides-Extra: all
|
|
@@ -141,7 +141,7 @@ If you use this software, please cite it as:
|
|
|
141
141
|
author = {Eertmans, Jérome},
|
|
142
142
|
url = {https://github.com/jeertmans/DiffeRT},
|
|
143
143
|
license = {MIT},
|
|
144
|
-
version = {v0.6.
|
|
144
|
+
version = {v0.6.2}
|
|
145
145
|
}
|
|
146
146
|
```
|
|
147
147
|
|
|
@@ -16,13 +16,13 @@ classifiers = [
|
|
|
16
16
|
]
|
|
17
17
|
dependencies = [
|
|
18
18
|
"chex>=0.1.86",
|
|
19
|
-
"differt-core==0.6.
|
|
19
|
+
"differt-core==0.6.2",
|
|
20
20
|
"equinox>=0.13.1",
|
|
21
21
|
"filelock>=3.15.4",
|
|
22
|
+
"fpt-jax==0.1.0",
|
|
22
23
|
"jax>=0.7.2",
|
|
23
24
|
"jaxtyping>=0.3.2",
|
|
24
25
|
"numpy>=1.26.1",
|
|
25
|
-
"optax>=0.1.7",
|
|
26
26
|
"requests>=2.32.0",
|
|
27
27
|
"tqdm>=4.66.2",
|
|
28
28
|
]
|
|
@@ -311,23 +311,12 @@ def transition_matrices(
|
|
|
311
311
|
interaction_types: Int[ArrayLike, "*batch path_length-2"],
|
|
312
312
|
object_normals: Float[ArrayLike, "*batch path_length 3"],
|
|
313
313
|
) -> Float[Array, "*batch 2 2"]:
|
|
314
|
-
# ruff: noqa: D417, DOC202
|
|
315
314
|
"""
|
|
316
315
|
Compute the transition matrix, ...
|
|
317
316
|
|
|
318
|
-
|
|
319
|
-
k_i: The array of propagation direction of incident fields.
|
|
320
|
-
|
|
321
|
-
Each vector must have a unit length.
|
|
322
|
-
k_r: The array of propagation direction of reflected fields.
|
|
323
|
-
|
|
324
|
-
Each vector must have a unit length.
|
|
325
|
-
normals: The array of local normals.
|
|
326
|
-
|
|
327
|
-
Each vector must have a unit length.
|
|
317
|
+
.. warning::
|
|
328
318
|
|
|
329
|
-
|
|
330
|
-
The array of s and p directions, before and after reflection.
|
|
319
|
+
Do not use this function yet, it is not implemented!
|
|
331
320
|
"""
|
|
332
321
|
vertices = jnp.asarray(vertices)
|
|
333
322
|
objects = jnp.asarray(objects)
|
|
@@ -391,11 +391,6 @@ def fibonacci_lattice(
|
|
|
391
391
|
Args:
|
|
392
392
|
n: The size of the lattice.
|
|
393
393
|
dtype: The float dtype of the vertices.
|
|
394
|
-
grid: Whether to return a grid of shape ``{n} {n} 3``
|
|
395
|
-
instead. This is mainly useful if you need to plot
|
|
396
|
-
a surface that is generated from a lattice.
|
|
397
|
-
|
|
398
|
-
Unused if ``frustum`` is passed.
|
|
399
394
|
frustum: The spatial region where to sample points.
|
|
400
395
|
|
|
401
396
|
The frustum in an array of min. and max. values for
|
|
@@ -1,88 +1,13 @@
|
|
|
1
|
-
from typing import Any
|
|
1
|
+
from typing import Any
|
|
2
2
|
|
|
3
|
-
import chex
|
|
4
3
|
import equinox as eqx
|
|
5
|
-
import
|
|
4
|
+
import fpt_jax
|
|
6
5
|
import jax.numpy as jnp
|
|
7
|
-
import optax
|
|
8
6
|
from jaxtyping import Array, ArrayLike, Float
|
|
9
7
|
|
|
10
8
|
from differt.geometry import orthogonal_basis
|
|
11
9
|
|
|
12
10
|
|
|
13
|
-
def _param_to_xyz(
|
|
14
|
-
p: Float[Array, "*batch num_object_x_num_dims"],
|
|
15
|
-
o: Float[Array, "*#batch num_objects 3"],
|
|
16
|
-
v: Float[Array, "*#batch num_objects num_dims 3"],
|
|
17
|
-
) -> Float[Array, "*batch num_objects 3"]:
|
|
18
|
-
*_, num_objects, num_dims, _ = v.shape
|
|
19
|
-
p = jnp.reshape(p, (*p.shape[:-1], num_objects, num_dims, 1))
|
|
20
|
-
return o + jnp.sum(p * v, axis=-2)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def _loss(
|
|
24
|
-
p: Float[Array, "*batch num_object_x_num_dims"],
|
|
25
|
-
from_: Float[Array, "*#batch 3"],
|
|
26
|
-
to: Float[Array, "*#batch 3"],
|
|
27
|
-
o: Float[Array, "*#batch num_objects 3"],
|
|
28
|
-
v: Float[Array, "*#batch num_objects num_dims 3"],
|
|
29
|
-
) -> Float[Array, " *batch"]:
|
|
30
|
-
chex.assert_axis_dimension_gt(p, -1, 0, exception_type=TypeError)
|
|
31
|
-
chex.assert_axis_dimension(
|
|
32
|
-
p, -1, v.shape[-2] * v.shape[-3], exception_type=TypeError
|
|
33
|
-
)
|
|
34
|
-
xyz = _param_to_xyz(p, o, v)
|
|
35
|
-
first_segment = xyz[..., 0, :] - from_
|
|
36
|
-
last_segment = to - xyz[..., -1, :]
|
|
37
|
-
other_segments = jnp.diff(xyz, axis=-2)
|
|
38
|
-
return (
|
|
39
|
-
jnp.linalg.norm(first_segment, axis=-1)
|
|
40
|
-
+ jnp.linalg.norm(last_segment, axis=-1)
|
|
41
|
-
+ jnp.sum(jnp.linalg.norm(other_segments, axis=-1), axis=-1)
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def _fermat_path_on_linear_objects(
|
|
46
|
-
from_vertex: Float[Array, "3"],
|
|
47
|
-
to_vertex: Float[Array, "3"],
|
|
48
|
-
object_origins: Float[Array, "num_objects 3"],
|
|
49
|
-
object_vectors: Float[Array, "num_objects num_dims 3"],
|
|
50
|
-
steps: int,
|
|
51
|
-
optimizer: optax.GradientTransformationExtraArgs,
|
|
52
|
-
) -> Float[Array, "num_objects 3"]:
|
|
53
|
-
dtype = jnp.result_type(from_vertex, to_vertex, object_origins, object_vectors)
|
|
54
|
-
x_0 = jnp.zeros(object_vectors.shape[0] * object_vectors.shape[1], dtype=dtype)
|
|
55
|
-
opt_state = optimizer.init(x_0)
|
|
56
|
-
value_and_grad = optax.value_and_grad_from_state(_loss)
|
|
57
|
-
|
|
58
|
-
@no_type_check
|
|
59
|
-
def update(
|
|
60
|
-
state: tuple[Float[Array, " num_unknowns"], Any],
|
|
61
|
-
_: None,
|
|
62
|
-
) -> tuple[tuple[Float[Array, " num_unknowns"], Any], float | Float[Array, " "]]:
|
|
63
|
-
x, opt_state = state
|
|
64
|
-
loss_value, grad = value_and_grad(
|
|
65
|
-
x, from_vertex, to_vertex, object_origins, object_vectors, state=opt_state
|
|
66
|
-
)
|
|
67
|
-
updates, opt_state = optimizer.update(
|
|
68
|
-
grad,
|
|
69
|
-
opt_state,
|
|
70
|
-
x,
|
|
71
|
-
value=loss_value,
|
|
72
|
-
grad=grad,
|
|
73
|
-
value_fn=_loss,
|
|
74
|
-
from_=from_vertex,
|
|
75
|
-
to=to_vertex,
|
|
76
|
-
o=object_origins,
|
|
77
|
-
v=object_vectors,
|
|
78
|
-
)
|
|
79
|
-
x = optax.apply_updates(x, updates)
|
|
80
|
-
return (x, opt_state), loss_value
|
|
81
|
-
|
|
82
|
-
(x, _), _ = jax.lax.scan(update, (x_0, opt_state), length=steps)
|
|
83
|
-
return _param_to_xyz(x, object_origins, object_vectors)
|
|
84
|
-
|
|
85
|
-
|
|
86
11
|
@eqx.filter_jit
|
|
87
12
|
def fermat_path_on_linear_objects(
|
|
88
13
|
from_vertices: Float[ArrayLike, "*#batch 3"],
|
|
@@ -91,7 +16,10 @@ def fermat_path_on_linear_objects(
|
|
|
91
16
|
object_vectors: Float[ArrayLike, "*#batch num_objects num_dims 3"],
|
|
92
17
|
*,
|
|
93
18
|
steps: int = 10,
|
|
94
|
-
|
|
19
|
+
unroll: int | bool = 1,
|
|
20
|
+
linesearch_steps: int = 1,
|
|
21
|
+
unroll_linesearch: int | bool = 1,
|
|
22
|
+
implicit_diff: bool = True,
|
|
95
23
|
) -> Float[Array, "*batch num_objects 3"]:
|
|
96
24
|
"""
|
|
97
25
|
Return the ray paths between pairs of vertices, that reflect or diffract on a given list of objects in between.
|
|
@@ -112,6 +40,14 @@ def fermat_path_on_linear_objects(
|
|
|
112
40
|
:func:`image method<differt.rt.image_method>`, choosing an appropriate origin can be important
|
|
113
41
|
as it will be used as the initial point of the minimization procedure.
|
|
114
42
|
|
|
43
|
+
.. important::
|
|
44
|
+
|
|
45
|
+
The current implementation uses the ``fpt-jax`` library
|
|
46
|
+
:cite:`fpt-eucap2026`, which defines :class:`jax.custom_vjp` functions for more
|
|
47
|
+
efficient gradient computations, see the paper for more details. The implementation
|
|
48
|
+
is not guaranteed to converge for all configurations of vertices and objects,
|
|
49
|
+
and the user may need to tune the number of steps to achieve convergence.
|
|
50
|
+
|
|
115
51
|
Args:
|
|
116
52
|
from_vertices: An array of ``from`` vertices, i.e., vertices from which the
|
|
117
53
|
ray paths start. In a radio communications context, this is usually
|
|
@@ -124,14 +60,14 @@ def fermat_path_on_linear_objects(
|
|
|
124
60
|
It is used as the initial guess of the minimization procedure.
|
|
125
61
|
object_vectors: An array of base vectors describing the objects.
|
|
126
62
|
steps: The number of optimization steps to perform.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
63
|
+
unroll: Whether to unroll the optimization loop. Can be a boolean or an integer
|
|
64
|
+
specifying the number of iterations to unroll, see :func:`jax.lax.scan`.
|
|
65
|
+
linesearch_steps: The number of line search steps to perform at each iteration.
|
|
66
|
+
unroll_linesearch: Whether to unroll the line search loop. Can be a boolean or an integer
|
|
67
|
+
specifying the number of iterations to unroll, see :func:`jax.lax.scan`.
|
|
68
|
+
implicit_diff: Whether to use implicit differentiation for computing the gradient.
|
|
69
|
+
See :cite:`fpt-eucap2026` and its
|
|
70
|
+
`GitHub page <https://github.com/jeertmans/fpt-jax/tree/v0.1.0>`_ for more details.
|
|
135
71
|
|
|
136
72
|
Returns:
|
|
137
73
|
An array of ray paths obtained based on Fermat's principle.
|
|
@@ -232,13 +168,17 @@ def fermat_path_on_linear_objects(
|
|
|
232
168
|
return jnp.empty((*batch, 0, 3), dtype=dtype)
|
|
233
169
|
return jnp.broadcast_to(object_origins, (*batch, num_objects, 3)).astype(dtype)
|
|
234
170
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
171
|
+
return fpt_jax.trace_rays(
|
|
172
|
+
from_vertices,
|
|
173
|
+
to_vertices,
|
|
174
|
+
object_origins,
|
|
175
|
+
object_vectors,
|
|
176
|
+
num_iters=steps,
|
|
177
|
+
unroll=unroll,
|
|
178
|
+
num_iters_linesearch=linesearch_steps,
|
|
179
|
+
unroll_linesearch=unroll_linesearch,
|
|
180
|
+
implicit_diff=implicit_diff,
|
|
181
|
+
)
|
|
242
182
|
|
|
243
183
|
|
|
244
184
|
@eqx.filter_jit
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|