lsurf 1.0.0__py3-none-any.whl
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.
- lsurf/__init__.py +471 -0
- lsurf/analysis/__init__.py +107 -0
- lsurf/analysis/healpix_utils.py +418 -0
- lsurf/analysis/sphere_viz.py +1280 -0
- lsurf/cli/__init__.py +48 -0
- lsurf/cli/build.py +398 -0
- lsurf/cli/config_schema.py +318 -0
- lsurf/cli/gui_cmd.py +76 -0
- lsurf/cli/interactive.py +850 -0
- lsurf/cli/main.py +81 -0
- lsurf/cli/run.py +806 -0
- lsurf/detectors/__init__.py +266 -0
- lsurf/detectors/analysis.py +289 -0
- lsurf/detectors/base.py +284 -0
- lsurf/detectors/constant_size_rings.py +485 -0
- lsurf/detectors/directional.py +45 -0
- lsurf/detectors/extended/__init__.py +73 -0
- lsurf/detectors/extended/local_sphere.py +353 -0
- lsurf/detectors/extended/recording_sphere.py +368 -0
- lsurf/detectors/planar.py +45 -0
- lsurf/detectors/protocol.py +187 -0
- lsurf/detectors/recording_spheres.py +63 -0
- lsurf/detectors/results.py +1140 -0
- lsurf/detectors/small/__init__.py +79 -0
- lsurf/detectors/small/directional.py +330 -0
- lsurf/detectors/small/planar.py +401 -0
- lsurf/detectors/small/spherical.py +450 -0
- lsurf/detectors/spherical.py +45 -0
- lsurf/geometry/__init__.py +199 -0
- lsurf/geometry/builder.py +478 -0
- lsurf/geometry/cell.py +228 -0
- lsurf/geometry/cell_geometry.py +247 -0
- lsurf/geometry/detector_arrays.py +1785 -0
- lsurf/geometry/geometry.py +222 -0
- lsurf/geometry/surface_analysis.py +375 -0
- lsurf/geometry/validation.py +91 -0
- lsurf/gui/__init__.py +51 -0
- lsurf/gui/app.py +903 -0
- lsurf/gui/core/__init__.py +39 -0
- lsurf/gui/core/scene.py +343 -0
- lsurf/gui/core/simulation.py +264 -0
- lsurf/gui/renderers/__init__.py +40 -0
- lsurf/gui/renderers/ray_renderer.py +353 -0
- lsurf/gui/renderers/source_renderer.py +505 -0
- lsurf/gui/renderers/surface_renderer.py +477 -0
- lsurf/gui/views/__init__.py +48 -0
- lsurf/gui/views/config_editor.py +3199 -0
- lsurf/gui/views/properties.py +257 -0
- lsurf/gui/views/results.py +291 -0
- lsurf/gui/views/scene_tree.py +180 -0
- lsurf/gui/views/viewport_3d.py +555 -0
- lsurf/gui/views/visualizations.py +712 -0
- lsurf/materials/__init__.py +169 -0
- lsurf/materials/base/__init__.py +64 -0
- lsurf/materials/base/full_inhomogeneous.py +208 -0
- lsurf/materials/base/grid_inhomogeneous.py +319 -0
- lsurf/materials/base/homogeneous.py +342 -0
- lsurf/materials/base/material_field.py +527 -0
- lsurf/materials/base/simple_inhomogeneous.py +418 -0
- lsurf/materials/base/spectral_inhomogeneous.py +497 -0
- lsurf/materials/implementations/__init__.py +120 -0
- lsurf/materials/implementations/data/alpha_values_typical_atmosphere_updated.txt +24 -0
- lsurf/materials/implementations/duct_atmosphere.py +390 -0
- lsurf/materials/implementations/exponential_atmosphere.py +435 -0
- lsurf/materials/implementations/gaussian_lens.py +120 -0
- lsurf/materials/implementations/interpolated_data.py +123 -0
- lsurf/materials/implementations/layered_atmosphere.py +134 -0
- lsurf/materials/implementations/linear_gradient.py +109 -0
- lsurf/materials/implementations/linsley_atmosphere.py +764 -0
- lsurf/materials/implementations/standard_materials.py +126 -0
- lsurf/materials/implementations/turbulent_atmosphere.py +135 -0
- lsurf/materials/implementations/us_standard_atmosphere.py +149 -0
- lsurf/materials/utils/__init__.py +77 -0
- lsurf/materials/utils/constants.py +45 -0
- lsurf/materials/utils/device_functions.py +117 -0
- lsurf/materials/utils/dispersion.py +160 -0
- lsurf/materials/utils/factories.py +142 -0
- lsurf/propagation/__init__.py +91 -0
- lsurf/propagation/detector_gpu.py +67 -0
- lsurf/propagation/gpu_device_rays.py +294 -0
- lsurf/propagation/kernels/__init__.py +175 -0
- lsurf/propagation/kernels/absorption/__init__.py +61 -0
- lsurf/propagation/kernels/absorption/grid.py +240 -0
- lsurf/propagation/kernels/absorption/simple.py +232 -0
- lsurf/propagation/kernels/absorption/spectral.py +410 -0
- lsurf/propagation/kernels/detection/__init__.py +64 -0
- lsurf/propagation/kernels/detection/protocol.py +102 -0
- lsurf/propagation/kernels/detection/spherical.py +255 -0
- lsurf/propagation/kernels/device_functions.py +790 -0
- lsurf/propagation/kernels/fresnel/__init__.py +64 -0
- lsurf/propagation/kernels/fresnel/protocol.py +97 -0
- lsurf/propagation/kernels/fresnel/standard.py +258 -0
- lsurf/propagation/kernels/intersection/__init__.py +79 -0
- lsurf/propagation/kernels/intersection/annular_plane.py +207 -0
- lsurf/propagation/kernels/intersection/bounded_plane.py +205 -0
- lsurf/propagation/kernels/intersection/plane.py +166 -0
- lsurf/propagation/kernels/intersection/protocol.py +95 -0
- lsurf/propagation/kernels/intersection/signed_distance.py +742 -0
- lsurf/propagation/kernels/intersection/sphere.py +190 -0
- lsurf/propagation/kernels/propagation/__init__.py +85 -0
- lsurf/propagation/kernels/propagation/grid.py +527 -0
- lsurf/propagation/kernels/propagation/protocol.py +105 -0
- lsurf/propagation/kernels/propagation/simple.py +460 -0
- lsurf/propagation/kernels/propagation/spectral.py +875 -0
- lsurf/propagation/kernels/registry.py +331 -0
- lsurf/propagation/kernels/surface/__init__.py +72 -0
- lsurf/propagation/kernels/surface/bisection.py +232 -0
- lsurf/propagation/kernels/surface/detection.py +402 -0
- lsurf/propagation/kernels/surface/reduction.py +166 -0
- lsurf/propagation/propagator_protocol.py +222 -0
- lsurf/propagation/propagators/__init__.py +101 -0
- lsurf/propagation/propagators/detector_handler.py +354 -0
- lsurf/propagation/propagators/factory.py +200 -0
- lsurf/propagation/propagators/fresnel_handler.py +305 -0
- lsurf/propagation/propagators/gpu_gradient.py +566 -0
- lsurf/propagation/propagators/gpu_surface_propagator.py +707 -0
- lsurf/propagation/propagators/gradient.py +429 -0
- lsurf/propagation/propagators/intersection_handler.py +327 -0
- lsurf/propagation/propagators/material_propagator.py +398 -0
- lsurf/propagation/propagators/signed_distance_handler.py +522 -0
- lsurf/propagation/propagators/spectral_gpu_gradient.py +553 -0
- lsurf/propagation/propagators/surface_interaction.py +616 -0
- lsurf/propagation/propagators/surface_propagator.py +719 -0
- lsurf/py.typed +1 -0
- lsurf/simulation/__init__.py +70 -0
- lsurf/simulation/config.py +164 -0
- lsurf/simulation/orchestrator.py +462 -0
- lsurf/simulation/result.py +299 -0
- lsurf/simulation/simulation.py +262 -0
- lsurf/sources/__init__.py +128 -0
- lsurf/sources/base.py +264 -0
- lsurf/sources/collimated.py +252 -0
- lsurf/sources/custom.py +409 -0
- lsurf/sources/diverging.py +228 -0
- lsurf/sources/gaussian.py +272 -0
- lsurf/sources/parallel_from_positions.py +197 -0
- lsurf/sources/point.py +172 -0
- lsurf/sources/uniform_diverging.py +258 -0
- lsurf/surfaces/__init__.py +184 -0
- lsurf/surfaces/cpu/__init__.py +50 -0
- lsurf/surfaces/cpu/curved_wave.py +463 -0
- lsurf/surfaces/cpu/gerstner_wave.py +381 -0
- lsurf/surfaces/cpu/wave_params.py +118 -0
- lsurf/surfaces/gpu/__init__.py +72 -0
- lsurf/surfaces/gpu/annular_plane.py +453 -0
- lsurf/surfaces/gpu/bounded_plane.py +390 -0
- lsurf/surfaces/gpu/curved_wave.py +483 -0
- lsurf/surfaces/gpu/gerstner_wave.py +377 -0
- lsurf/surfaces/gpu/multi_curved_wave.py +520 -0
- lsurf/surfaces/gpu/plane.py +299 -0
- lsurf/surfaces/gpu/recording_sphere.py +587 -0
- lsurf/surfaces/gpu/sphere.py +311 -0
- lsurf/surfaces/protocol.py +336 -0
- lsurf/surfaces/registry.py +373 -0
- lsurf/utilities/__init__.py +175 -0
- lsurf/utilities/detector_analysis.py +814 -0
- lsurf/utilities/fresnel.py +628 -0
- lsurf/utilities/interactions.py +1215 -0
- lsurf/utilities/propagation.py +602 -0
- lsurf/utilities/ray_data.py +532 -0
- lsurf/utilities/recording_sphere.py +745 -0
- lsurf/utilities/time_spread.py +463 -0
- lsurf/visualization/__init__.py +329 -0
- lsurf/visualization/absorption_plots.py +334 -0
- lsurf/visualization/atmospheric_plots.py +754 -0
- lsurf/visualization/common.py +348 -0
- lsurf/visualization/detector_plots.py +1350 -0
- lsurf/visualization/detector_sphere_plots.py +1173 -0
- lsurf/visualization/fresnel_plots.py +1061 -0
- lsurf/visualization/ocean_simulation_plots.py +999 -0
- lsurf/visualization/polarization_plots.py +916 -0
- lsurf/visualization/raytracing_plots.py +1521 -0
- lsurf/visualization/ring_detector_plots.py +1867 -0
- lsurf/visualization/time_spread_plots.py +531 -0
- lsurf-1.0.0.dist-info/METADATA +381 -0
- lsurf-1.0.0.dist-info/RECORD +180 -0
- lsurf-1.0.0.dist-info/WHEEL +5 -0
- lsurf-1.0.0.dist-info/entry_points.txt +2 -0
- lsurf-1.0.0.dist-info/licenses/LICENSE +32 -0
- lsurf-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
# The Clear BSD License
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2026 Tobias Heibges
|
|
4
|
+
# All rights reserved.
|
|
5
|
+
#
|
|
6
|
+
# Redistribution and use in source and binary forms, with or without
|
|
7
|
+
# modification, are permitted (subject to the limitations in the disclaimer
|
|
8
|
+
# below) provided that the following conditions are met:
|
|
9
|
+
#
|
|
10
|
+
# * Redistributions of source code must retain the above copyright notice,
|
|
11
|
+
# this list of conditions and the following disclaimer.
|
|
12
|
+
#
|
|
13
|
+
# * Redistributions in binary form must reproduce the above copyright
|
|
14
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
15
|
+
# documentation and/or other materials provided with the distribution.
|
|
16
|
+
#
|
|
17
|
+
# * Neither the name of the copyright holder nor the names of its
|
|
18
|
+
# contributors may be used to endorse or promote products derived from this
|
|
19
|
+
# software without specific prior written permission.
|
|
20
|
+
#
|
|
21
|
+
# NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
|
|
22
|
+
# THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
23
|
+
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
24
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
25
|
+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
26
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
27
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
28
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
29
|
+
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
|
30
|
+
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
31
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
32
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
33
|
+
|
|
34
|
+
"""
|
|
35
|
+
GPU Kernels for SimpleInhomogeneousModel
|
|
36
|
+
|
|
37
|
+
CUDA kernels for GPU-accelerated ray propagation through
|
|
38
|
+
radially-symmetric inhomogeneous materials using 1D lookup table interpolation.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
import math
|
|
42
|
+
|
|
43
|
+
# GPU support is optional
|
|
44
|
+
try:
|
|
45
|
+
from numba import cuda
|
|
46
|
+
|
|
47
|
+
HAS_CUDA = True
|
|
48
|
+
except ImportError:
|
|
49
|
+
|
|
50
|
+
class _FakeCuda:
|
|
51
|
+
"""Fake cuda module for when numba is not installed."""
|
|
52
|
+
|
|
53
|
+
class devicearray:
|
|
54
|
+
"""Fake devicearray submodule."""
|
|
55
|
+
|
|
56
|
+
DeviceNDArray = object
|
|
57
|
+
|
|
58
|
+
@staticmethod
|
|
59
|
+
def jit(*args, **kwargs):
|
|
60
|
+
"""Return a no-op decorator."""
|
|
61
|
+
|
|
62
|
+
def decorator(func):
|
|
63
|
+
return func
|
|
64
|
+
|
|
65
|
+
if args and callable(args[0]):
|
|
66
|
+
return args[0]
|
|
67
|
+
return decorator
|
|
68
|
+
|
|
69
|
+
@staticmethod
|
|
70
|
+
def is_available():
|
|
71
|
+
return False
|
|
72
|
+
|
|
73
|
+
@staticmethod
|
|
74
|
+
def grid(n):
|
|
75
|
+
return 0
|
|
76
|
+
|
|
77
|
+
@staticmethod
|
|
78
|
+
def synchronize():
|
|
79
|
+
pass
|
|
80
|
+
|
|
81
|
+
cuda = _FakeCuda() # type: ignore[assignment]
|
|
82
|
+
HAS_CUDA = False
|
|
83
|
+
|
|
84
|
+
from ..device_functions import device_euler_step
|
|
85
|
+
from ..registry import PropagationKernelID, register_kernel
|
|
86
|
+
|
|
87
|
+
SPEED_OF_LIGHT = 299792458.0
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@cuda.jit(device=True)
|
|
91
|
+
def _device_lut_interpolate(
|
|
92
|
+
value: float,
|
|
93
|
+
lut: cuda.devicearray.DeviceNDArray,
|
|
94
|
+
min_val: float,
|
|
95
|
+
delta: float,
|
|
96
|
+
lut_size: int,
|
|
97
|
+
) -> float:
|
|
98
|
+
"""
|
|
99
|
+
Linear interpolation in 1D lookup table.
|
|
100
|
+
|
|
101
|
+
Parameters
|
|
102
|
+
----------
|
|
103
|
+
value : float
|
|
104
|
+
Value to interpolate at
|
|
105
|
+
lut : device array
|
|
106
|
+
1D lookup table
|
|
107
|
+
min_val : float
|
|
108
|
+
Minimum value in table
|
|
109
|
+
delta : float
|
|
110
|
+
Spacing between table entries
|
|
111
|
+
lut_size : int
|
|
112
|
+
Number of entries in table
|
|
113
|
+
|
|
114
|
+
Returns
|
|
115
|
+
-------
|
|
116
|
+
float
|
|
117
|
+
Interpolated value
|
|
118
|
+
"""
|
|
119
|
+
idx_float = (value - min_val) / delta
|
|
120
|
+
|
|
121
|
+
if idx_float <= 0.0:
|
|
122
|
+
return lut[0]
|
|
123
|
+
if idx_float >= lut_size - 1:
|
|
124
|
+
return lut[lut_size - 1]
|
|
125
|
+
|
|
126
|
+
idx = int(idx_float)
|
|
127
|
+
frac = idx_float - idx
|
|
128
|
+
|
|
129
|
+
return lut[idx] + frac * (lut[idx + 1] - lut[idx])
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
@cuda.jit(device=True)
|
|
133
|
+
def _device_simple_n_and_gradient(
|
|
134
|
+
x: float,
|
|
135
|
+
y: float,
|
|
136
|
+
z: float,
|
|
137
|
+
center_x: float,
|
|
138
|
+
center_y: float,
|
|
139
|
+
center_z: float,
|
|
140
|
+
ref_radius: float,
|
|
141
|
+
min_alt: float,
|
|
142
|
+
delta_h: float,
|
|
143
|
+
lut_size: int,
|
|
144
|
+
lut_n: cuda.devicearray.DeviceNDArray,
|
|
145
|
+
lut_dn_dh: cuda.devicearray.DeviceNDArray,
|
|
146
|
+
) -> tuple[float, float, float, float]:
|
|
147
|
+
"""Compute n and gradient for SimpleInhomogeneousModel."""
|
|
148
|
+
dx = x - center_x
|
|
149
|
+
dy = y - center_y
|
|
150
|
+
dz = z - center_z
|
|
151
|
+
|
|
152
|
+
r = math.sqrt(dx * dx + dy * dy + dz * dz)
|
|
153
|
+
altitude = r - ref_radius
|
|
154
|
+
|
|
155
|
+
if altitude < 0.0:
|
|
156
|
+
altitude = 0.0
|
|
157
|
+
|
|
158
|
+
n = _device_lut_interpolate(altitude, lut_n, min_alt, delta_h, lut_size)
|
|
159
|
+
dn_dh = _device_lut_interpolate(altitude, lut_dn_dh, min_alt, delta_h, lut_size)
|
|
160
|
+
|
|
161
|
+
if r < 1e-10:
|
|
162
|
+
r_hat_x, r_hat_y, r_hat_z = 0.0, 0.0, 1.0
|
|
163
|
+
else:
|
|
164
|
+
r_hat_x = dx / r
|
|
165
|
+
r_hat_y = dy / r
|
|
166
|
+
r_hat_z = dz / r
|
|
167
|
+
|
|
168
|
+
grad_x = dn_dh * r_hat_x
|
|
169
|
+
grad_y = dn_dh * r_hat_y
|
|
170
|
+
grad_z = dn_dh * r_hat_z
|
|
171
|
+
|
|
172
|
+
return n, grad_x, grad_y, grad_z
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
@cuda.jit(device=True)
|
|
176
|
+
def _device_simple_euler_step(
|
|
177
|
+
x: float,
|
|
178
|
+
y: float,
|
|
179
|
+
z: float,
|
|
180
|
+
dir_x: float,
|
|
181
|
+
dir_y: float,
|
|
182
|
+
dir_z: float,
|
|
183
|
+
step_size: float,
|
|
184
|
+
center_x: float,
|
|
185
|
+
center_y: float,
|
|
186
|
+
center_z: float,
|
|
187
|
+
ref_radius: float,
|
|
188
|
+
min_alt: float,
|
|
189
|
+
delta_h: float,
|
|
190
|
+
lut_size: int,
|
|
191
|
+
lut_n: cuda.devicearray.DeviceNDArray,
|
|
192
|
+
lut_dn_dh: cuda.devicearray.DeviceNDArray,
|
|
193
|
+
) -> tuple[float, float, float, float, float, float, float]:
|
|
194
|
+
"""Euler step for SimpleInhomogeneousModel."""
|
|
195
|
+
n, grad_x, grad_y, grad_z = _device_simple_n_and_gradient(
|
|
196
|
+
x,
|
|
197
|
+
y,
|
|
198
|
+
z,
|
|
199
|
+
center_x,
|
|
200
|
+
center_y,
|
|
201
|
+
center_z,
|
|
202
|
+
ref_radius,
|
|
203
|
+
min_alt,
|
|
204
|
+
delta_h,
|
|
205
|
+
lut_size,
|
|
206
|
+
lut_n,
|
|
207
|
+
lut_dn_dh,
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
new_x, new_y, new_z, new_dx, new_dy, new_dz = device_euler_step(
|
|
211
|
+
x, y, z, dir_x, dir_y, dir_z, n, grad_x, grad_y, grad_z, step_size
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
return new_x, new_y, new_z, new_dx, new_dy, new_dz, n
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
@cuda.jit(device=True)
|
|
218
|
+
def _device_simple_rk4_step(
|
|
219
|
+
x: float,
|
|
220
|
+
y: float,
|
|
221
|
+
z: float,
|
|
222
|
+
dir_x: float,
|
|
223
|
+
dir_y: float,
|
|
224
|
+
dir_z: float,
|
|
225
|
+
step_size: float,
|
|
226
|
+
center_x: float,
|
|
227
|
+
center_y: float,
|
|
228
|
+
center_z: float,
|
|
229
|
+
ref_radius: float,
|
|
230
|
+
min_alt: float,
|
|
231
|
+
delta_h: float,
|
|
232
|
+
lut_size: int,
|
|
233
|
+
lut_n: cuda.devicearray.DeviceNDArray,
|
|
234
|
+
lut_dn_dh: cuda.devicearray.DeviceNDArray,
|
|
235
|
+
) -> tuple[float, float, float, float, float, float, float]:
|
|
236
|
+
"""RK4 step for SimpleInhomogeneousModel."""
|
|
237
|
+
h = step_size
|
|
238
|
+
h2 = h / 2.0
|
|
239
|
+
|
|
240
|
+
def get_n_and_kappa(px, py, pz, dx, dy, dz):
|
|
241
|
+
n, gx, gy, gz = _device_simple_n_and_gradient(
|
|
242
|
+
px,
|
|
243
|
+
py,
|
|
244
|
+
pz,
|
|
245
|
+
center_x,
|
|
246
|
+
center_y,
|
|
247
|
+
center_z,
|
|
248
|
+
ref_radius,
|
|
249
|
+
min_alt,
|
|
250
|
+
delta_h,
|
|
251
|
+
lut_size,
|
|
252
|
+
lut_n,
|
|
253
|
+
lut_dn_dh,
|
|
254
|
+
)
|
|
255
|
+
dot = dx * gx + dy * gy + dz * gz
|
|
256
|
+
kx = (gx - dot * dx) / n
|
|
257
|
+
ky = (gy - dot * dy) / n
|
|
258
|
+
kz = (gz - dot * dz) / n
|
|
259
|
+
return n, kx, ky, kz
|
|
260
|
+
|
|
261
|
+
def normalize(dx, dy, dz):
|
|
262
|
+
norm = math.sqrt(dx * dx + dy * dy + dz * dz)
|
|
263
|
+
if norm < 1e-12:
|
|
264
|
+
norm = 1.0
|
|
265
|
+
return dx / norm, dy / norm, dz / norm
|
|
266
|
+
|
|
267
|
+
# k1
|
|
268
|
+
n0, kx1, ky1, kz1 = get_n_and_kappa(x, y, z, dir_x, dir_y, dir_z)
|
|
269
|
+
k1_rx, k1_ry, k1_rz = dir_x, dir_y, dir_z
|
|
270
|
+
k1_dx, k1_dy, k1_dz = kx1, ky1, kz1
|
|
271
|
+
|
|
272
|
+
# k2
|
|
273
|
+
px = x + h2 * k1_rx
|
|
274
|
+
py = y + h2 * k1_ry
|
|
275
|
+
pz = z + h2 * k1_rz
|
|
276
|
+
dx, dy, dz = normalize(dir_x + h2 * k1_dx, dir_y + h2 * k1_dy, dir_z + h2 * k1_dz)
|
|
277
|
+
n1, kx2, ky2, kz2 = get_n_and_kappa(px, py, pz, dx, dy, dz)
|
|
278
|
+
k2_rx, k2_ry, k2_rz = dx, dy, dz
|
|
279
|
+
k2_dx, k2_dy, k2_dz = kx2, ky2, kz2
|
|
280
|
+
|
|
281
|
+
# k3
|
|
282
|
+
px = x + h2 * k2_rx
|
|
283
|
+
py = y + h2 * k2_ry
|
|
284
|
+
pz = z + h2 * k2_rz
|
|
285
|
+
dx, dy, dz = normalize(dir_x + h2 * k2_dx, dir_y + h2 * k2_dy, dir_z + h2 * k2_dz)
|
|
286
|
+
n2, kx3, ky3, kz3 = get_n_and_kappa(px, py, pz, dx, dy, dz)
|
|
287
|
+
k3_rx, k3_ry, k3_rz = dx, dy, dz
|
|
288
|
+
k3_dx, k3_dy, k3_dz = kx3, ky3, kz3
|
|
289
|
+
|
|
290
|
+
# k4
|
|
291
|
+
px = x + h * k3_rx
|
|
292
|
+
py = y + h * k3_ry
|
|
293
|
+
pz = z + h * k3_rz
|
|
294
|
+
dx, dy, dz = normalize(dir_x + h * k3_dx, dir_y + h * k3_dy, dir_z + h * k3_dz)
|
|
295
|
+
n3, kx4, ky4, kz4 = get_n_and_kappa(px, py, pz, dx, dy, dz)
|
|
296
|
+
|
|
297
|
+
# Final RK4 combination
|
|
298
|
+
new_x = x + (h / 6.0) * (k1_rx + 2 * k2_rx + 2 * k3_rx + dx)
|
|
299
|
+
new_y = y + (h / 6.0) * (k1_ry + 2 * k2_ry + 2 * k3_ry + dy)
|
|
300
|
+
new_z = z + (h / 6.0) * (k1_rz + 2 * k2_rz + 2 * k3_rz + dz)
|
|
301
|
+
|
|
302
|
+
new_dx = dir_x + (h / 6.0) * (k1_dx + 2 * k2_dx + 2 * k3_dx + kx4)
|
|
303
|
+
new_dy = dir_y + (h / 6.0) * (k1_dy + 2 * k2_dy + 2 * k3_dy + ky4)
|
|
304
|
+
new_dz = dir_z + (h / 6.0) * (k1_dz + 2 * k2_dz + 2 * k3_dz + kz4)
|
|
305
|
+
|
|
306
|
+
new_dx, new_dy, new_dz = normalize(new_dx, new_dy, new_dz)
|
|
307
|
+
|
|
308
|
+
n_avg = (n0 + 4 * n1 + n2) / 6.0
|
|
309
|
+
|
|
310
|
+
return new_x, new_y, new_z, new_dx, new_dy, new_dz, n_avg
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
@register_kernel(PropagationKernelID.SIMPLE_EULER)
|
|
314
|
+
@cuda.jit
|
|
315
|
+
def _kernel_simple_inhomogeneous_euler(
|
|
316
|
+
positions,
|
|
317
|
+
directions,
|
|
318
|
+
active,
|
|
319
|
+
geo_path,
|
|
320
|
+
opt_path,
|
|
321
|
+
acc_time,
|
|
322
|
+
step_size: float,
|
|
323
|
+
num_steps: int,
|
|
324
|
+
center_x: float,
|
|
325
|
+
center_y: float,
|
|
326
|
+
center_z: float,
|
|
327
|
+
ref_radius: float,
|
|
328
|
+
min_alt: float,
|
|
329
|
+
delta_h: float,
|
|
330
|
+
lut_size: int,
|
|
331
|
+
lut_n,
|
|
332
|
+
lut_dn_dh,
|
|
333
|
+
wavelength: float,
|
|
334
|
+
):
|
|
335
|
+
"""GPU kernel for SimpleInhomogeneousModel using Euler integration."""
|
|
336
|
+
c = SPEED_OF_LIGHT
|
|
337
|
+
|
|
338
|
+
idx = cuda.grid(1)
|
|
339
|
+
if idx >= positions.shape[0]:
|
|
340
|
+
return
|
|
341
|
+
if not active[idx]:
|
|
342
|
+
return
|
|
343
|
+
|
|
344
|
+
x = positions[idx, 0]
|
|
345
|
+
y = positions[idx, 1]
|
|
346
|
+
z = positions[idx, 2]
|
|
347
|
+
dx = directions[idx, 0]
|
|
348
|
+
dy = directions[idx, 1]
|
|
349
|
+
dz = directions[idx, 2]
|
|
350
|
+
gp = geo_path[idx]
|
|
351
|
+
op = opt_path[idx]
|
|
352
|
+
at = acc_time[idx]
|
|
353
|
+
|
|
354
|
+
for _ in range(num_steps):
|
|
355
|
+
x, y, z, dx, dy, dz, n = _device_simple_euler_step(
|
|
356
|
+
x,
|
|
357
|
+
y,
|
|
358
|
+
z,
|
|
359
|
+
dx,
|
|
360
|
+
dy,
|
|
361
|
+
dz,
|
|
362
|
+
step_size,
|
|
363
|
+
center_x,
|
|
364
|
+
center_y,
|
|
365
|
+
center_z,
|
|
366
|
+
ref_radius,
|
|
367
|
+
min_alt,
|
|
368
|
+
delta_h,
|
|
369
|
+
lut_size,
|
|
370
|
+
lut_n,
|
|
371
|
+
lut_dn_dh,
|
|
372
|
+
)
|
|
373
|
+
gp += step_size
|
|
374
|
+
op += n * step_size
|
|
375
|
+
at += n * step_size / c
|
|
376
|
+
|
|
377
|
+
positions[idx, 0] = x
|
|
378
|
+
positions[idx, 1] = y
|
|
379
|
+
positions[idx, 2] = z
|
|
380
|
+
directions[idx, 0] = dx
|
|
381
|
+
directions[idx, 1] = dy
|
|
382
|
+
directions[idx, 2] = dz
|
|
383
|
+
geo_path[idx] = gp
|
|
384
|
+
opt_path[idx] = op
|
|
385
|
+
acc_time[idx] = at
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
@register_kernel(PropagationKernelID.SIMPLE_RK4)
|
|
389
|
+
@cuda.jit
|
|
390
|
+
def _kernel_simple_inhomogeneous_rk4(
|
|
391
|
+
positions,
|
|
392
|
+
directions,
|
|
393
|
+
active,
|
|
394
|
+
geo_path,
|
|
395
|
+
opt_path,
|
|
396
|
+
acc_time,
|
|
397
|
+
step_size: float,
|
|
398
|
+
num_steps: int,
|
|
399
|
+
center_x: float,
|
|
400
|
+
center_y: float,
|
|
401
|
+
center_z: float,
|
|
402
|
+
ref_radius: float,
|
|
403
|
+
min_alt: float,
|
|
404
|
+
delta_h: float,
|
|
405
|
+
lut_size: int,
|
|
406
|
+
lut_n,
|
|
407
|
+
lut_dn_dh,
|
|
408
|
+
wavelength: float,
|
|
409
|
+
):
|
|
410
|
+
"""GPU kernel for SimpleInhomogeneousModel using RK4 integration."""
|
|
411
|
+
c = SPEED_OF_LIGHT
|
|
412
|
+
|
|
413
|
+
idx = cuda.grid(1)
|
|
414
|
+
if idx >= positions.shape[0]:
|
|
415
|
+
return
|
|
416
|
+
if not active[idx]:
|
|
417
|
+
return
|
|
418
|
+
|
|
419
|
+
x = positions[idx, 0]
|
|
420
|
+
y = positions[idx, 1]
|
|
421
|
+
z = positions[idx, 2]
|
|
422
|
+
dx = directions[idx, 0]
|
|
423
|
+
dy = directions[idx, 1]
|
|
424
|
+
dz = directions[idx, 2]
|
|
425
|
+
gp = geo_path[idx]
|
|
426
|
+
op = opt_path[idx]
|
|
427
|
+
at = acc_time[idx]
|
|
428
|
+
|
|
429
|
+
for _ in range(num_steps):
|
|
430
|
+
x, y, z, dx, dy, dz, n_avg = _device_simple_rk4_step(
|
|
431
|
+
x,
|
|
432
|
+
y,
|
|
433
|
+
z,
|
|
434
|
+
dx,
|
|
435
|
+
dy,
|
|
436
|
+
dz,
|
|
437
|
+
step_size,
|
|
438
|
+
center_x,
|
|
439
|
+
center_y,
|
|
440
|
+
center_z,
|
|
441
|
+
ref_radius,
|
|
442
|
+
min_alt,
|
|
443
|
+
delta_h,
|
|
444
|
+
lut_size,
|
|
445
|
+
lut_n,
|
|
446
|
+
lut_dn_dh,
|
|
447
|
+
)
|
|
448
|
+
gp += step_size
|
|
449
|
+
op += n_avg * step_size
|
|
450
|
+
at += n_avg * step_size / c
|
|
451
|
+
|
|
452
|
+
positions[idx, 0] = x
|
|
453
|
+
positions[idx, 1] = y
|
|
454
|
+
positions[idx, 2] = z
|
|
455
|
+
directions[idx, 0] = dx
|
|
456
|
+
directions[idx, 1] = dy
|
|
457
|
+
directions[idx, 2] = dz
|
|
458
|
+
geo_path[idx] = gp
|
|
459
|
+
opt_path[idx] = op
|
|
460
|
+
acc_time[idx] = at
|