FiberFusing 1.9.8__tar.gz → 1.10.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.
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/_version.py +1 -1
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/connection/connection.py +26 -50
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/generic_fiber.py +13 -3
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/geometry.py +66 -33
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/profile.py +16 -16
- fiberfusing-1.10.0/FiberFusing.egg-info/PKG-INFO +197 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing.egg-info/SOURCES.txt +1 -12
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing.egg-info/requires.txt +5 -9
- fiberfusing-1.10.0/PKG-INFO +197 -0
- fiberfusing-1.10.0/README.rst +150 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/pyproject.toml +10 -13
- fiberfusing-1.9.8/FiberFusing.egg-info/PKG-INFO +0 -280
- fiberfusing-1.9.8/PKG-INFO +0 -280
- fiberfusing-1.9.8/README.rst +0 -210
- fiberfusing-1.9.8/tests/test_boundaries.py +0 -66
- fiberfusing-1.9.8/tests/test_cooordinate_system.py +0 -535
- fiberfusing-1.9.8/tests/test_documentation_version.py +0 -19
- fiberfusing-1.9.8/tests/test_fiber.py +0 -82
- fiberfusing-1.9.8/tests/test_fused_structure.py +0 -100
- fiberfusing-1.9.8/tests/test_generic_fiber.py +0 -85
- fiberfusing-1.9.8/tests/test_geometries.py +0 -187
- fiberfusing-1.9.8/tests/test_packaging.py +0 -42
- fiberfusing-1.9.8/tests/test_plotting.py +0 -127
- fiberfusing-1.9.8/tests/test_polygon.py +0 -100
- fiberfusing-1.9.8/tests/test_profile_invariants.py +0 -213
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/__init__.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/background.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/connection/__init__.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/connection/connection_optimization.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/connection/utils.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/coordinate_system.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/directories.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/__init__.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/1550BHP.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/DCF13.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/DCF1300S_20.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/DCF1300S_26.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/DCF1300S_33.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/DCF1300S_42.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/F2028M12.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/F2028M21.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/F2028M24.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/F2058G1.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/F2058L1.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/HI1060.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/HP630.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/SM1950.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/SMF28.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/fluorine_doped_1%_capillary.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/fluorine_doped_2%_capillary.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/test_fiber.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/fiber_files/test_multimode_fiber.yaml +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/fiber/loader.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/geometries/__init__.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/geometries/base_class.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/geometries/linestring.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/geometries/point.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/geometries/polygon.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/geometries/utils.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/graded_index.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/helper.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/optical_structure.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/plottings.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/shapes/__init__.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/shapes/base.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/shapes/circle.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/shapes/ellipse.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/shapes/square.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/structures.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing/utils.py +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing.egg-info/dependency_links.txt +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/FiberFusing.egg-info/top_level.txt +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/LICENSE +0 -0
- {fiberfusing-1.9.8 → fiberfusing-1.10.0}/setup.cfg +0 -0
|
@@ -8,7 +8,8 @@ import logging
|
|
|
8
8
|
from scipy.optimize import minimize_scalar
|
|
9
9
|
from pydantic.dataclasses import dataclass
|
|
10
10
|
from pydantic import ConfigDict
|
|
11
|
-
|
|
11
|
+
from shapely import affinity
|
|
12
|
+
from shapely.geometry import box
|
|
12
13
|
import FiberFusing as ff
|
|
13
14
|
from FiberFusing import utils
|
|
14
15
|
from FiberFusing.shapes.circle import Circle
|
|
@@ -373,61 +374,36 @@ class Connection:
|
|
|
373
374
|
"""
|
|
374
375
|
logging.info("Starting core position optimization...")
|
|
375
376
|
|
|
376
|
-
result = minimize_scalar(
|
|
377
|
-
self._compute_area_mismatch_cost,
|
|
378
|
-
bounds=(0.50001, 0.99),
|
|
379
|
-
method='bounded',
|
|
380
|
-
options={'xatol': tolerance}
|
|
381
|
-
)
|
|
382
|
-
|
|
383
|
-
if result.success and np.isfinite(result.x) and np.isfinite(result.fun):
|
|
384
|
-
self._compute_area_mismatch_cost(result.x)
|
|
385
|
-
logging.info(f"Optimization successful: cost={result.fun:.2e}")
|
|
386
|
-
# Apply optimized shifts
|
|
387
|
-
if self.core_shift:
|
|
388
|
-
self.fiber0.shifted_core += self.core_shift[0]
|
|
389
|
-
self.fiber1.shifted_core += self.core_shift[1]
|
|
390
|
-
else:
|
|
391
|
-
raise RuntimeError(f"Core optimization failed: {result.message}")
|
|
392
|
-
|
|
393
|
-
def _compute_area_mismatch_cost(self, x: float) -> float:
|
|
394
|
-
"""
|
|
395
|
-
Compute area mismatch cost for optimization.
|
|
396
|
-
|
|
397
|
-
Parameters
|
|
398
|
-
----------
|
|
399
|
-
x : float
|
|
400
|
-
Optimization parameter (0 to 1).
|
|
401
|
-
|
|
402
|
-
Returns
|
|
403
|
-
-------
|
|
404
|
-
float
|
|
405
|
-
Cost value to minimize.
|
|
406
|
-
"""
|
|
407
|
-
# Get split positions
|
|
408
377
|
line = self.extended_center_line
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
small_section = self.split_geometry(
|
|
414
|
-
geometry=self.total_area,
|
|
415
|
-
position=position0,
|
|
416
|
-
return_largest=False
|
|
378
|
+
start, end = line.boundary
|
|
379
|
+
angle = np.arctan2(end.y - start.y, end.x - start.x)
|
|
380
|
+
aligned = affinity.rotate(
|
|
381
|
+
self.total_area._shapely_object, -angle, origin=(start.x, start.y), use_radians=True
|
|
417
382
|
)
|
|
383
|
+
x_min, y_min, _, y_max = aligned.bounds
|
|
384
|
+
length = line.length
|
|
385
|
+
target_area = self.fiber0.area / 2
|
|
386
|
+
|
|
387
|
+
def area_mismatch(fraction: float) -> float:
|
|
388
|
+
"""Return the absolute cap-area error in squared geometry units."""
|
|
389
|
+
cut = start.x + (1 - fraction) * length
|
|
390
|
+
# A cut may produce several pieces on the same side of a small hole.
|
|
391
|
+
# Integrate the whole cap, including every disconnected piece.
|
|
392
|
+
cap = aligned.intersection(box(min(x_min, cut), y_min, cut, y_max))
|
|
393
|
+
return abs(cap.area - target_area)
|
|
418
394
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
395
|
+
result = minimize_scalar(
|
|
396
|
+
area_mismatch, bounds=(0.50001, 0.99), method="bounded", options={"xatol": tolerance}
|
|
397
|
+
)
|
|
398
|
+
if not result.success or not np.isfinite(result.x) or not np.isfinite(result.fun):
|
|
399
|
+
raise RuntimeError(f"Core optimization failed: {result.message}")
|
|
422
400
|
|
|
423
401
|
self.core_shift = (
|
|
424
|
-
|
|
425
|
-
|
|
402
|
+
line.get_position_parametrization(1 - result.x) - self.fiber0.center,
|
|
403
|
+
line.get_position_parametrization(result.x) - self.fiber1.center,
|
|
426
404
|
)
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
return cost
|
|
405
|
+
self.fiber0.shifted_core += self.core_shift[0]
|
|
406
|
+
self.fiber1.shifted_core += self.core_shift[1]
|
|
431
407
|
|
|
432
408
|
# =============================================================================
|
|
433
409
|
# UTILITY METHODS
|
|
@@ -66,9 +66,19 @@ class GenericFiber():
|
|
|
66
66
|
return [s for s in self.structure_list if s.name not in ['air']]
|
|
67
67
|
|
|
68
68
|
@property
|
|
69
|
-
def refractive_index_list(self) -> list:
|
|
70
|
-
"""
|
|
71
|
-
|
|
69
|
+
def refractive_index_list(self) -> list[float]:
|
|
70
|
+
"""Return dimensionless layer indices in definition order, excluding air.
|
|
71
|
+
|
|
72
|
+
Graded layers contribute both their inside and outside values.
|
|
73
|
+
"""
|
|
74
|
+
indices = []
|
|
75
|
+
for layer in self.fiber_structure:
|
|
76
|
+
index = layer.refractive_index
|
|
77
|
+
if isinstance(index, GradedIndex):
|
|
78
|
+
indices.extend((index.inside, index.outside))
|
|
79
|
+
else:
|
|
80
|
+
indices.append(index)
|
|
81
|
+
return indices
|
|
72
82
|
|
|
73
83
|
@property
|
|
74
84
|
def inner_structure(self) -> list:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
|
-
from typing import List, Optional, Tuple, Union
|
|
4
|
+
from typing import TYPE_CHECKING, List, Optional, Tuple, Union
|
|
5
5
|
from enum import Enum
|
|
6
6
|
import numpy
|
|
7
7
|
from scipy.ndimage import gaussian_filter
|
|
@@ -12,12 +12,14 @@ from mpl_toolkits.axes_grid1 import make_axes_locatable
|
|
|
12
12
|
from pydantic import field_validator
|
|
13
13
|
from pydantic.dataclasses import dataclass
|
|
14
14
|
from FiberFusing.plottings import plotting
|
|
15
|
-
|
|
16
|
-
|
|
17
15
|
from FiberFusing.coordinate_system import CoordinateSystem
|
|
18
16
|
from FiberFusing.utils import config_dict
|
|
19
17
|
|
|
20
18
|
|
|
19
|
+
if TYPE_CHECKING:
|
|
20
|
+
from FiberFusing.profile import Profile
|
|
21
|
+
|
|
22
|
+
|
|
21
23
|
class DomainAlignment(Enum):
|
|
22
24
|
"""Boundary positioning modes."""
|
|
23
25
|
|
|
@@ -66,6 +68,43 @@ class Geometry:
|
|
|
66
68
|
"""Initialize geometry after model validation."""
|
|
67
69
|
self.structure_list = list()
|
|
68
70
|
|
|
71
|
+
@classmethod
|
|
72
|
+
def from_profile(
|
|
73
|
+
cls, *, profile: "Profile", fiber_name: str, background_index: float = 1.0, **geometry_options
|
|
74
|
+
) -> "Geometry":
|
|
75
|
+
"""Build an initialized mesh with one catalog fiber at each shifted core.
|
|
76
|
+
|
|
77
|
+
Parameters
|
|
78
|
+
----------
|
|
79
|
+
profile : Profile
|
|
80
|
+
Fused cladding in meters with its refractive_index already assigned.
|
|
81
|
+
fiber_name : str
|
|
82
|
+
Catalog name, for example SMF28. The profile replaces the outermost
|
|
83
|
+
catalog layer. Remaining layers retain their catalog radii in meters.
|
|
84
|
+
background_index : float, optional
|
|
85
|
+
Dimensionless background refractive index. Defaults to air (1.0).
|
|
86
|
+
**geometry_options
|
|
87
|
+
Geometry constructor options, including resolution and domain bounds.
|
|
88
|
+
|
|
89
|
+
Returns
|
|
90
|
+
-------
|
|
91
|
+
Geometry
|
|
92
|
+
Initialized geometry with a dimensionless index mesh of shape (ny, nx).
|
|
93
|
+
"""
|
|
94
|
+
from FiberFusing.fiber import FiberLoader
|
|
95
|
+
|
|
96
|
+
loader = FiberLoader()
|
|
97
|
+
catalog = loader.load_fiber_as_dict(fiber_name, clad_refractive_index=profile.refractive_index)
|
|
98
|
+
inner_layers = list(catalog["layers"].values())[1:]
|
|
99
|
+
geometry = cls(**geometry_options)
|
|
100
|
+
geometry.add_structure(FiberFusing.BackGround(refractive_index=background_index), profile)
|
|
101
|
+
if inner_layers:
|
|
102
|
+
for core in profile.cores:
|
|
103
|
+
fiber = loader.make_fiber(inner_layers, profile.refractive_index, position=(core.x, core.y))
|
|
104
|
+
geometry.add_structure(fiber)
|
|
105
|
+
geometry.initialize()
|
|
106
|
+
return geometry
|
|
107
|
+
|
|
69
108
|
def add_structure(self, *structure: object) -> None:
|
|
70
109
|
"""
|
|
71
110
|
Add a structure to the internal structure list.
|
|
@@ -106,19 +145,7 @@ class Geometry:
|
|
|
106
145
|
Initialize the geometry by generating the coordinate system and mesh.
|
|
107
146
|
This method calculates the boundaries based on the defined structures and sets up the coordinate system.
|
|
108
147
|
"""
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
self.coordinate_system = CoordinateSystem(
|
|
112
|
-
x_min=x_min,
|
|
113
|
-
x_max=x_max,
|
|
114
|
-
y_min=y_min,
|
|
115
|
-
y_max=y_max,
|
|
116
|
-
nx=self.resolution,
|
|
117
|
-
ny=self.resolution,
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
self.coordinate_system.center(factor=self.boundary_pad_factor)
|
|
121
|
-
self.apply_boundary_settings()
|
|
148
|
+
self.update_coordinate_system()
|
|
122
149
|
self.mesh = self.generate_mesh()
|
|
123
150
|
|
|
124
151
|
def update_coordinate_system(self) -> None:
|
|
@@ -254,11 +281,7 @@ class Geometry:
|
|
|
254
281
|
float
|
|
255
282
|
Maximum refractive index.
|
|
256
283
|
"""
|
|
257
|
-
return max(
|
|
258
|
-
refractive_index
|
|
259
|
-
for obj in self.structure_list
|
|
260
|
-
for refractive_index in obj.refractive_index_list
|
|
261
|
-
)
|
|
284
|
+
return max(self.get_index_range())
|
|
262
285
|
|
|
263
286
|
@property
|
|
264
287
|
def refractive_index_minimum(self) -> float:
|
|
@@ -270,23 +293,33 @@ class Geometry:
|
|
|
270
293
|
float
|
|
271
294
|
Minimum refractive index.
|
|
272
295
|
"""
|
|
273
|
-
return min(
|
|
274
|
-
refractive_index
|
|
275
|
-
for obj in self.structure_list
|
|
276
|
-
if not isinstance(obj, FiberFusing.background.BackGround)
|
|
277
|
-
for refractive_index in obj.refractive_index_list
|
|
278
|
-
)
|
|
296
|
+
return min(self.get_index_range(include_background=False))
|
|
279
297
|
|
|
280
|
-
def get_index_range(self) -> List[float]:
|
|
298
|
+
def get_index_range(self, *, include_background: bool = True) -> List[float]:
|
|
281
299
|
"""
|
|
282
|
-
|
|
300
|
+
Collect the assigned material indices in structure and layer order.
|
|
301
|
+
|
|
302
|
+
Parameters
|
|
303
|
+
----------
|
|
304
|
+
include_background : bool, optional
|
|
305
|
+
Include the surrounding medium. Defaults to True.
|
|
283
306
|
|
|
284
307
|
Returns
|
|
285
308
|
-------
|
|
286
309
|
List[float]
|
|
287
|
-
|
|
310
|
+
Dimensionless indices including both endpoints
|
|
311
|
+
of each graded layer. Repeated values are retained.
|
|
288
312
|
"""
|
|
289
|
-
|
|
313
|
+
indices = []
|
|
314
|
+
for structure in self.structure_list:
|
|
315
|
+
if not include_background and isinstance(structure, FiberFusing.BackGround):
|
|
316
|
+
continue
|
|
317
|
+
layer_indices = getattr(structure, "refractive_index_list", None)
|
|
318
|
+
if layer_indices is not None:
|
|
319
|
+
indices.extend(layer_indices)
|
|
320
|
+
else:
|
|
321
|
+
indices.append(float(structure.refractive_index))
|
|
322
|
+
return indices
|
|
290
323
|
|
|
291
324
|
def rotate(self, angle: float) -> None:
|
|
292
325
|
"""
|
|
@@ -360,9 +393,9 @@ class Geometry:
|
|
|
360
393
|
AttributeError
|
|
361
394
|
If the coordinate system has not been generated before calling this method.
|
|
362
395
|
"""
|
|
363
|
-
if
|
|
396
|
+
if self.coordinate_system is None:
|
|
364
397
|
raise AttributeError(
|
|
365
|
-
"Coordinate system has not been generated. Call
|
|
398
|
+
"Coordinate system has not been generated. Call initialize() first."
|
|
366
399
|
)
|
|
367
400
|
|
|
368
401
|
mesh = self.rasterize_polygons()
|
|
@@ -32,13 +32,13 @@ class Profile(OverlayStructureBaseClass):
|
|
|
32
32
|
Parameters
|
|
33
33
|
----------
|
|
34
34
|
tolerance_factor : float, optional
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
Optimizer position tolerance as a fraction of core spacing. None uses the
|
|
36
|
+
structure default (1e-10).
|
|
37
37
|
scale_down_position : float, optional
|
|
38
38
|
Scaling factor to adjust the overall size of the assembly. Default is 1.
|
|
39
39
|
"""
|
|
40
40
|
|
|
41
|
-
def __init__(self, tolerance_factor: Optional[float] =
|
|
41
|
+
def __init__(self, tolerance_factor: Optional[float] = None, scale_down_position: Optional[float] = 1):
|
|
42
42
|
"""
|
|
43
43
|
Initialize the fiber and core lists and other structures immediately after the dataclass fields
|
|
44
44
|
have been populated.
|
|
@@ -119,6 +119,11 @@ class Profile(OverlayStructureBaseClass):
|
|
|
119
119
|
self._clad_structure = union_geometries(*self.structure_list)
|
|
120
120
|
return self._clad_structure
|
|
121
121
|
|
|
122
|
+
@property
|
|
123
|
+
def refractive_index_list(self) -> list[float]:
|
|
124
|
+
"""Return the dimensionless index of the fused cladding as a one-item list."""
|
|
125
|
+
return [self.refractive_index]
|
|
126
|
+
|
|
122
127
|
@property
|
|
123
128
|
def structure_dictionary(self) -> Dict[str, Dict[str, object]]:
|
|
124
129
|
"""
|
|
@@ -269,7 +274,7 @@ class Profile(OverlayStructureBaseClass):
|
|
|
269
274
|
|
|
270
275
|
def add_structure(
|
|
271
276
|
self,
|
|
272
|
-
structure_type:
|
|
277
|
+
structure_type: StructureType,
|
|
273
278
|
number_of_fibers: int,
|
|
274
279
|
fiber_radius: float,
|
|
275
280
|
fusion_degree: float = 0.0,
|
|
@@ -282,8 +287,8 @@ class Profile(OverlayStructureBaseClass):
|
|
|
282
287
|
|
|
283
288
|
Parameters
|
|
284
289
|
----------
|
|
285
|
-
structure_type :
|
|
286
|
-
|
|
290
|
+
structure_type : StructureType
|
|
291
|
+
Use StructureType.CIRCULAR for a ring or StructureType.LINEAR for a line.
|
|
287
292
|
number_of_fibers : int
|
|
288
293
|
Number of fibers in the structure.
|
|
289
294
|
fiber_radius : float
|
|
@@ -295,7 +300,7 @@ class Profile(OverlayStructureBaseClass):
|
|
|
295
300
|
position_shift : list of float, optional
|
|
296
301
|
A 2D vector [x, y] to shift the entire structure. Default is [0, 0].
|
|
297
302
|
angle_shift : float, optional
|
|
298
|
-
|
|
303
|
+
Counterclockwise rotation of the arrangement in degrees. Default is 0.0.
|
|
299
304
|
|
|
300
305
|
Returns
|
|
301
306
|
-------
|
|
@@ -313,18 +318,12 @@ class Profile(OverlayStructureBaseClass):
|
|
|
313
318
|
raise ValueError("scale_position must be finite and positive.")
|
|
314
319
|
if np.shape(position_shift) != (2,) or not np.all(np.isfinite(position_shift)) or not np.isfinite(angle_shift):
|
|
315
320
|
raise ValueError("Positions and angles must be finite.")
|
|
321
|
+
options = {} if self.tolerance_factor is None else {"tolerance_factor": self.tolerance_factor}
|
|
316
322
|
match structure_type:
|
|
317
323
|
case StructureType.CIRCULAR:
|
|
318
|
-
structure = FiberRing(
|
|
319
|
-
number_of_fibers=number_of_fibers,
|
|
320
|
-
fiber_radius=fiber_radius,
|
|
321
|
-
angle_shift=angle_shift
|
|
322
|
-
)
|
|
324
|
+
structure = FiberRing(number_of_fibers, fiber_radius, angle_shift=angle_shift, **options)
|
|
323
325
|
case StructureType.LINEAR:
|
|
324
|
-
structure = FiberLine(
|
|
325
|
-
number_of_fibers=number_of_fibers,
|
|
326
|
-
fiber_radius=fiber_radius
|
|
327
|
-
)
|
|
326
|
+
structure = FiberLine(number_of_fibers, fiber_radius, rotation_angle=angle_shift, **options)
|
|
328
327
|
case _:
|
|
329
328
|
raise ValueError(f"Unsupported structure type: {structure_type}. Use 'circular' or 'linear'.")
|
|
330
329
|
|
|
@@ -355,6 +354,7 @@ class Profile(OverlayStructureBaseClass):
|
|
|
355
354
|
|
|
356
355
|
@property
|
|
357
356
|
def cores(self) -> List:
|
|
357
|
+
"""Return the shifted core points in fiber assembly order."""
|
|
358
358
|
return [fiber.shifted_core for fiber in self.fiber_list]
|
|
359
359
|
|
|
360
360
|
def get_core_positions(self) -> List[Tuple[float, float]]:
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: FiberFusing
|
|
3
|
+
Version: 1.10.0
|
|
4
|
+
Summary: Parametrized fused-fiber cross-sections and refractive-index meshes.
|
|
5
|
+
Author-email: Martin Poinsinet de Sivry-Houle <martin.poinsinet.de.sivry@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Contact, https://github.com/MartinPdeS/FiberFusing/issues
|
|
8
|
+
Project-URL: Homepage, https://github.com/MartinPdeS/FiberFusing
|
|
9
|
+
Project-URL: Documentation, https://martinpdes.github.io/FiberFusing/
|
|
10
|
+
Project-URL: Repository, https://github.com/MartinPdeS/FiberFusing.git
|
|
11
|
+
Keywords: fiber,fusing
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
20
|
+
Classifier: Development Status :: 4 - Beta
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
22
|
+
Classifier: Intended Audience :: Science/Research
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/x-rst
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: pyyaml
|
|
27
|
+
Requires-Dist: typing_extensions>=4.4
|
|
28
|
+
Requires-Dist: pydantic<3,>=2
|
|
29
|
+
Requires-Dist: scipy
|
|
30
|
+
Requires-Dist: matplotlib<4,>=3.8
|
|
31
|
+
Requires-Dist: numpy
|
|
32
|
+
Requires-Dist: shapely>=2.0
|
|
33
|
+
Provides-Extra: release
|
|
34
|
+
Requires-Dist: martinpdes-maintenance==0.2.3; extra == "release"
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: martinpdes-maintenance[quality]==0.2.3; extra == "dev"
|
|
37
|
+
Requires-Dist: twine<7,>=6; extra == "dev"
|
|
38
|
+
Requires-Dist: flake8==7.3.0; extra == "dev"
|
|
39
|
+
Provides-Extra: testing
|
|
40
|
+
Requires-Dist: martinpdes-maintenance[testing]==0.2.3; extra == "testing"
|
|
41
|
+
Requires-Dist: pytest-json-report~=1.5; extra == "testing"
|
|
42
|
+
Requires-Dist: pytest-cov<7; extra == "testing"
|
|
43
|
+
Requires-Dist: coverage~=7.6; extra == "testing"
|
|
44
|
+
Provides-Extra: documentation
|
|
45
|
+
Requires-Dist: MartinPdeS-docs<0.5,>=0.4.0; extra == "documentation"
|
|
46
|
+
Dynamic: license-file
|
|
47
|
+
|
|
48
|
+
FiberFusing
|
|
49
|
+
===========
|
|
50
|
+
|
|
51
|
+
.. image:: https://raw.githubusercontent.com/MartinPdeS/FiberFusing/HEAD/docs/images/logo.png
|
|
52
|
+
:alt: FiberFusing logo
|
|
53
|
+
:width: 100%
|
|
54
|
+
|
|
55
|
+
.. list-table::
|
|
56
|
+
:width: 100%
|
|
57
|
+
:widths: 35 65
|
|
58
|
+
:header-rows: 1
|
|
59
|
+
|
|
60
|
+
* - Badge
|
|
61
|
+
- Status
|
|
62
|
+
* - Python versions
|
|
63
|
+
- |mps-python|
|
|
64
|
+
* - Documentation
|
|
65
|
+
- |mps-docs|
|
|
66
|
+
* - Tests
|
|
67
|
+
- |mps-ci| |mps-coverage|
|
|
68
|
+
* - PyPI
|
|
69
|
+
- |mps-pypi| |mps-downloads|
|
|
70
|
+
* - Conda
|
|
71
|
+
- |mps-conda| |mps-conda-downloads| |mps-conda-release|
|
|
72
|
+
|
|
73
|
+
Parametrized fused-fiber cross-sections and refractive-index meshes.
|
|
74
|
+
|
|
75
|
+
Start with a circular or linear arrangement of optical fibers and vary the fusion
|
|
76
|
+
degree to change the cladding boundary and core positions. Place catalog fibers
|
|
77
|
+
at those positions and rasterize the cross-section to obtain a two-dimensional
|
|
78
|
+
refractive-index mesh.
|
|
79
|
+
|
|
80
|
+
Run the `Colab notebook <https://colab.research.google.com/github/MartinPdeS/FiberFusing/blob/master/notebook.ipynb>`_
|
|
81
|
+
in your browser, or explore other arrangements in the
|
|
82
|
+
`example gallery <https://martinpdes.github.io/FiberFusing/docs/latest/gallery/index.html>`_.
|
|
83
|
+
|
|
84
|
+
Installation
|
|
85
|
+
------------
|
|
86
|
+
|
|
87
|
+
Requires Python ``>=3.10``.
|
|
88
|
+
|
|
89
|
+
.. code-block:: console
|
|
90
|
+
|
|
91
|
+
$ python -m pip install FiberFusing
|
|
92
|
+
|
|
93
|
+
Install from the ``martinpdes`` Conda channel:
|
|
94
|
+
|
|
95
|
+
.. code-block:: console
|
|
96
|
+
|
|
97
|
+
$ conda install -c martinpdes fiberfusing
|
|
98
|
+
|
|
99
|
+
For an editable source installation:
|
|
100
|
+
|
|
101
|
+
.. code-block:: console
|
|
102
|
+
|
|
103
|
+
$ git clone https://github.com/MartinPdeS/FiberFusing.git
|
|
104
|
+
$ cd FiberFusing
|
|
105
|
+
$ python -m pip install -e .
|
|
106
|
+
|
|
107
|
+
Model a three-fiber ring
|
|
108
|
+
------------------------
|
|
109
|
+
|
|
110
|
+
Arrange three SMF28 fibers in air with a cladding radius of 62.5 µm and a
|
|
111
|
+
fusion degree of 0.4. The script uses meters for length and dimensionless
|
|
112
|
+
refractive indices. For headless use, ``geometry.plot(show=False)`` returns
|
|
113
|
+
the Matplotlib figure.
|
|
114
|
+
|
|
115
|
+
.. code-block:: python
|
|
116
|
+
|
|
117
|
+
"""
|
|
118
|
+
Model a 3-fiber ring
|
|
119
|
+
====================
|
|
120
|
+
Place SMF28 cores in a fused silica cladding surrounded by air.
|
|
121
|
+
"""
|
|
122
|
+
|
|
123
|
+
from FiberFusing import Geometry
|
|
124
|
+
from FiberFusing.profile import Profile, StructureType
|
|
125
|
+
|
|
126
|
+
profile = Profile().add_structure(
|
|
127
|
+
structure_type=StructureType.CIRCULAR,
|
|
128
|
+
number_of_fibers=3,
|
|
129
|
+
fusion_degree=0.4,
|
|
130
|
+
fiber_radius=62.5e-6,
|
|
131
|
+
)
|
|
132
|
+
profile.refractive_index = 1.4444
|
|
133
|
+
geometry = Geometry.from_profile(profile=profile, fiber_name="SMF28", resolution=350)
|
|
134
|
+
geometry.plot(gamma=1, figure_size=(9, 4), style={"axes.formatter.limits": (-3, 3)})
|
|
135
|
+
|
|
136
|
+
.. figure:: https://raw.githubusercontent.com/MartinPdeS/FiberFusing/HEAD/docs/images/example_3x3.png
|
|
137
|
+
|
|
138
|
+
Three-fiber fused cross-section and its refractive-index mesh.
|
|
139
|
+
|
|
140
|
+
Documentation
|
|
141
|
+
-------------
|
|
142
|
+
|
|
143
|
+
Use the `FiberFusing documentation <https://martinpdes.github.io/FiberFusing/>`__ to work through
|
|
144
|
+
examples and look up the inputs and return values of individual functions.
|
|
145
|
+
|
|
146
|
+
Contributing
|
|
147
|
+
------------
|
|
148
|
+
|
|
149
|
+
Bug reports, worked examples, and documentation corrections are welcome.
|
|
150
|
+
To set up a development checkout and run the tests, follow the `contributing guide <https://github.com/MartinPdeS/FiberFusing/blob/HEAD/CONTRIBUTING.md>`__.
|
|
151
|
+
|
|
152
|
+
Contact
|
|
153
|
+
-------
|
|
154
|
+
|
|
155
|
+
For questions, contact `Martin Poinsinet de Sivry-Houle <mailto:martin.poinsinet.de.sivry@gmail.com?subject=FiberFusing>`__.
|
|
156
|
+
Report bugs on the `issue tracker <https://github.com/MartinPdeS/FiberFusing/issues>`__.
|
|
157
|
+
|
|
158
|
+
License
|
|
159
|
+
-------
|
|
160
|
+
|
|
161
|
+
FiberFusing is licensed under `MIT <https://github.com/MartinPdeS/FiberFusing/blob/HEAD/LICENSE>`__.
|
|
162
|
+
|
|
163
|
+
.. |mps-python| image:: https://img.shields.io/pypi/pyversions/fiberfusing.svg
|
|
164
|
+
:alt: Supported Python versions
|
|
165
|
+
:target: https://pypi.org/project/fiberfusing/
|
|
166
|
+
|
|
167
|
+
.. |mps-pypi| image:: https://img.shields.io/pypi/v/fiberfusing.svg
|
|
168
|
+
:alt: PyPI version
|
|
169
|
+
:target: https://pypi.org/project/fiberfusing/
|
|
170
|
+
|
|
171
|
+
.. |mps-downloads| image:: https://img.shields.io/pypi/dm/fiberfusing.svg
|
|
172
|
+
:alt: Monthly PyPI downloads
|
|
173
|
+
:target: https://pypistats.org/packages/fiberfusing
|
|
174
|
+
|
|
175
|
+
.. |mps-docs| image:: https://github.com/MartinPdeS/FiberFusing/actions/workflows/deploy_documentation.yml/badge.svg
|
|
176
|
+
:alt: Documentation
|
|
177
|
+
:target: https://martinpdes.github.io/FiberFusing/
|
|
178
|
+
|
|
179
|
+
.. |mps-ci| image:: https://github.com/MartinPdeS/FiberFusing/actions/workflows/tests.yml/badge.svg
|
|
180
|
+
:alt: Tests
|
|
181
|
+
:target: https://github.com/MartinPdeS/FiberFusing/actions/workflows/tests.yml
|
|
182
|
+
|
|
183
|
+
.. |mps-coverage| image:: https://raw.githubusercontent.com/MartinPdeS/FiberFusing/python-coverage-comment-action-data/badge.svg
|
|
184
|
+
:alt: Test coverage
|
|
185
|
+
:target: https://htmlpreview.github.io/?https://github.com/MartinPdeS/FiberFusing/blob/python-coverage-comment-action-data/htmlcov/index.html
|
|
186
|
+
|
|
187
|
+
.. |mps-conda| image:: https://anaconda.org/martinpdes/fiberfusing/badges/version.svg
|
|
188
|
+
:alt: Anaconda version
|
|
189
|
+
:target: https://anaconda.org/martinpdes/fiberfusing
|
|
190
|
+
|
|
191
|
+
.. |mps-conda-downloads| image:: https://anaconda.org/martinpdes/fiberfusing/badges/downloads.svg
|
|
192
|
+
:alt: Anaconda downloads
|
|
193
|
+
:target: https://anaconda.org/martinpdes/fiberfusing
|
|
194
|
+
|
|
195
|
+
.. |mps-conda-release| image:: https://anaconda.org/martinpdes/fiberfusing/badges/latest_release_relative_date.svg
|
|
196
|
+
:alt: Latest Anaconda release
|
|
197
|
+
:target: https://anaconda.org/martinpdes/fiberfusing
|
|
@@ -55,15 +55,4 @@ FiberFusing/shapes/__init__.py
|
|
|
55
55
|
FiberFusing/shapes/base.py
|
|
56
56
|
FiberFusing/shapes/circle.py
|
|
57
57
|
FiberFusing/shapes/ellipse.py
|
|
58
|
-
FiberFusing/shapes/square.py
|
|
59
|
-
tests/test_boundaries.py
|
|
60
|
-
tests/test_cooordinate_system.py
|
|
61
|
-
tests/test_documentation_version.py
|
|
62
|
-
tests/test_fiber.py
|
|
63
|
-
tests/test_fused_structure.py
|
|
64
|
-
tests/test_generic_fiber.py
|
|
65
|
-
tests/test_geometries.py
|
|
66
|
-
tests/test_packaging.py
|
|
67
|
-
tests/test_plotting.py
|
|
68
|
-
tests/test_polygon.py
|
|
69
|
-
tests/test_profile_invariants.py
|
|
58
|
+
FiberFusing/shapes/square.py
|
|
@@ -7,22 +7,18 @@ numpy
|
|
|
7
7
|
shapely>=2.0
|
|
8
8
|
|
|
9
9
|
[dev]
|
|
10
|
-
|
|
11
|
-
build<2,>=1
|
|
10
|
+
martinpdes-maintenance[quality]==0.2.3
|
|
12
11
|
twine<7,>=6
|
|
12
|
+
flake8==7.3.0
|
|
13
13
|
|
|
14
14
|
[documentation]
|
|
15
15
|
MartinPdeS-docs<0.5,>=0.4.0
|
|
16
16
|
|
|
17
17
|
[release]
|
|
18
|
-
martinpdes-maintenance==0.2.
|
|
18
|
+
martinpdes-maintenance==0.2.3
|
|
19
19
|
|
|
20
20
|
[testing]
|
|
21
|
-
|
|
22
|
-
pytest-cov<7,>=2
|
|
21
|
+
martinpdes-maintenance[testing]==0.2.3
|
|
23
22
|
pytest-json-report~=1.5
|
|
24
|
-
|
|
23
|
+
pytest-cov<7
|
|
25
24
|
coverage~=7.6
|
|
26
|
-
|
|
27
|
-
[testing:python_version < "3.11"]
|
|
28
|
-
tomli>=2
|