PyFiberModes 0.7.0__tar.gz → 0.7.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.
Files changed (105) hide show
  1. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PKG-INFO +35 -18
  2. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/__init__.py +0 -1
  3. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/_version.py +2 -2
  4. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/coordinates.py +25 -17
  5. {pyfibermodes-0.7.0/PyFiberModes/tools → pyfibermodes-0.7.2/PyFiberModes}/directories.py +0 -9
  6. pyfibermodes-0.7.2/PyFiberModes/factory.py +148 -0
  7. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber.py +177 -66
  8. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fundamentals.py +15 -13
  9. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/solver/mlsif/neff.py +8 -8
  10. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/solver/ssif/neff.py +6 -6
  11. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/solver/tlsif/cutoff.py +2 -2
  12. pyfibermodes-0.7.2/PyFiberModes/source.py +67 -0
  13. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/stepindex.py +5 -5
  14. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes.egg-info/PKG-INFO +35 -18
  15. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes.egg-info/SOURCES.txt +5 -3
  16. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/README.rst +34 -17
  17. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/source/code.rst +28 -23
  18. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/source/conf.py +1 -1
  19. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/tests/test_api.py +7 -2
  20. pyfibermodes-0.7.2/tests/test_field.py +120 -0
  21. pyfibermodes-0.7.2/tests/test_ssif.py +20 -0
  22. pyfibermodes-0.7.2/tests/test_tlsif.py +20 -0
  23. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/tests/test_validation.py +4 -1
  24. pyfibermodes-0.7.0/PyFiberModes/factory.py +0 -136
  25. pyfibermodes-0.7.0/PyFiberModes/wavelength.py +0 -137
  26. pyfibermodes-0.7.0/tests/test_wavelength.py +0 -85
  27. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/.github/dependabot.yml +0 -0
  28. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/.github/workflows/build_documentation.yml +0 -0
  29. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/.github/workflows/deploy_PyPi.yml +0 -0
  30. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/.github/workflows/deploy_anaconda.yml +0 -0
  31. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/.github/workflows/deploy_coverage.yml +0 -0
  32. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/.github/workflows/deploy_documentation.yml +0 -0
  33. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/.gitignore +0 -0
  34. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/.readthedocs.yml +0 -0
  35. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/LICENSE +0 -0
  36. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/__future__.py +0 -0
  37. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/1550BHP.yaml +0 -0
  38. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/DCF13.yaml +0 -0
  39. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/DCF1300S_20.yaml +0 -0
  40. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/DCF1300S_26.yaml +0 -0
  41. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/DCF1300S_33.yaml +0 -0
  42. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/DCF1300S_42.yaml +0 -0
  43. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/F2028M12.yaml +0 -0
  44. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/F2028M21.yaml +0 -0
  45. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/F2028M24.yaml +0 -0
  46. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/F2058G1.yaml +0 -0
  47. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/F2058L1.yaml +0 -0
  48. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/HI1060.yaml +0 -0
  49. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/HP630.yaml +0 -0
  50. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/SM1950.yaml +0 -0
  51. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/SMF28.yaml +0 -0
  52. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/fluorine_doped_1%_capillary.yaml +0 -0
  53. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/fluorine_doped_2%_capillary.yaml +0 -0
  54. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/test_fiber.yaml +0 -0
  55. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/fiber_files/test_multimode_fiber.yaml +0 -0
  56. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/field.py +0 -0
  57. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/loader.py +0 -0
  58. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/mode.py +0 -0
  59. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/mode_instances.py +0 -0
  60. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/solver/__init__.py +0 -0
  61. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/solver/base_solver.py +0 -0
  62. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/solver/mlsif/__init__.py +0 -0
  63. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/solver/ssif/__init__.py +0 -0
  64. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/solver/ssif/cutoff.py +0 -0
  65. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/solver/tlsif/__init__.py +0 -0
  66. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/tools/__init__.py +0 -0
  67. {pyfibermodes-0.7.0/PyFiberModes → pyfibermodes-0.7.2/PyFiberModes/tools}/directories.py +0 -0
  68. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes/tools/utils.py +0 -0
  69. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes.egg-info/dependency_links.txt +0 -0
  70. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes.egg-info/requires.txt +0 -0
  71. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/PyFiberModes.egg-info/top_level.txt +0 -0
  72. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/Makefile +0 -0
  73. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/DCF/README.rst +0 -0
  74. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/DCF/plot_DCF_fields.py +0 -0
  75. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/README.rst +0 -0
  76. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/SMF28/README.rst +0 -0
  77. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/SMF28/plot_smf28.py +0 -0
  78. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/SMF28/plot_smf28_dispersion_vs_wavelength.py +0 -0
  79. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/SMF28/plot_smf28_group_index_vs_wavelength.py +0 -0
  80. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/basic/README.rst +0 -0
  81. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/basic/plot_U_vs_V.py +0 -0
  82. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/basic/plot_comparison_solvers.py +0 -0
  83. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/basic/plot_dispersion.py +0 -0
  84. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/basic/plot_effective_index.py +0 -0
  85. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/basic/plot_fiber_LP_modes.py +0 -0
  86. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/basic/plot_group_index.py +0 -0
  87. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/basic/plot_mode_field.py +0 -0
  88. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/basic/plot_mode_field_1.py +0 -0
  89. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/basic/plot_mode_field_2.py +0 -0
  90. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/examples/basic/plot_neff_tapered_fiber.py +0 -0
  91. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/make.bat +0 -0
  92. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/source/_static/default.css +0 -0
  93. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/source/_static/thumbnail.png +0 -0
  94. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/source/examples.rst +0 -0
  95. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/docs/source/index.rst +0 -0
  96. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/meta.yaml +0 -0
  97. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/perso/test_1.py +0 -0
  98. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/perso/test_2.py +0 -0
  99. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/perso/test_3.py +0 -0
  100. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/pyproject.toml +0 -0
  101. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/setup.cfg +0 -0
  102. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/tests/__init__.py +0 -0
  103. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/tests/test_coordinates.py +0 -0
  104. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/tests/test_fiber.py +0 -0
  105. {pyfibermodes-0.7.0 → pyfibermodes-0.7.2}/tests/test_file_loading.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyFiberModes
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: A package for light propagation in fiber optics.
5
5
  Author-email: Martin Poinsinet de Sivry-Houle <martin.poinsinet.de.sivry@gmail.com>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -711,7 +711,6 @@ Requires-Dist: pydata-sphinx-theme==0.14.1; extra == "documentation"
711
711
  Provides-Extra: dev
712
712
  Requires-Dist: flake8==7.1.1; extra == "dev"
713
713
 
714
-
715
714
  .. list-table::
716
715
  :widths: 10 25 25
717
716
  :header-rows: 0
@@ -733,49 +732,56 @@ Requires-Dist: flake8==7.1.1; extra == "dev"
733
732
  PyFiberModes
734
733
  ============
735
734
 
736
- A numerical tool for simulating propagating modes in fiber optics, supporting all kinds of circular-symmetric geometries.
735
+ PyFiberModes is a Python package designed to simulate the propagation of modes in optical fibers. It supports all circularly symmetric geometries and provides tools for in-depth analysis of optical fiber properties and modal characteristics.
737
736
 
737
+ Key Features
738
+ ------------
739
+ - **Comprehensive Simulations**: Supports step-index fibers, multilayer fibers, and custom refractive index profiles.
740
+ - **Extensive Mode Analysis**: Calculate mode profiles, propagation constants, effective indices, and more.
741
+ - **Open Source**: Designed for customization and extensibility.
738
742
 
739
743
  ----
740
744
 
741
745
  Documentation
742
746
  **************
743
- The latest documentation is available `here <https://martinpdes.github.io/PyFiberModes/>`_ or by clicking the badge below:
747
+ The latest documentation is always available `here <https://martinpdes.github.io/PyFiberModes/>`_ or via the badge below:
744
748
 
745
749
  |docs|
746
750
 
747
-
748
751
  ----
749
752
 
750
753
 
751
754
  Installation
752
755
  ************
753
756
 
754
- Pip Installation
755
- ================
756
- PyFiberModes is available as a Python wheel for Linux and macOS. It requires Python 3.10. To install, simply run:
757
+ Using Pip
758
+ ---------
759
+
760
+ Install the PyFiberModes package directly from PyPi. Ensure you have Python 3.10 or later:
757
761
 
758
762
  .. code-block:: bash
759
763
 
760
764
  pip install PyFiberModes
761
765
 
766
+
762
767
  Manual Installation
763
- ===================
764
- For manual installation, clone the repository and install dependencies:
768
+ -------------------
769
+
770
+ To manually install the package:
765
771
 
766
772
  .. code-block:: bash
767
773
 
768
774
  git clone https://github.com/MartinPdeS/PyFiberModes.git
769
775
  cd PyFiberModes
770
- pip install -r requirements/requirements.txt
771
776
  pip install .
772
777
 
778
+
773
779
  ----
774
780
 
775
781
  Testing
776
782
  *******
777
783
 
778
- To run tests locally after cloning the repository, follow these steps:
784
+ PyFiberModes includes comprehensive tests. To run the tests locally:
779
785
 
780
786
  .. code-block:: bash
781
787
 
@@ -785,20 +791,31 @@ To run tests locally after cloning the repository, follow these steps:
785
791
  coverage run --source=PyFiberModes --module pytest --verbose tests
786
792
  coverage report --show-missing
787
793
 
788
- This ensures the package is thoroughly tested and provides a coverage report.
794
+
795
+ This will generate a coverage report detailing untested portions of the code.
789
796
 
790
797
  ----
791
798
 
792
- Coding Examples
793
- ***************
794
- Explore plenty of examples in the `examples section <https://martinpdes.github.io/PyFiberModes/docs/v0.5.9.3/gallery/index.html>`_ of the documentation.
799
+
800
+ Examples and Usage
801
+ ******************
802
+ Learn how to use PyFiberModes with detailed examples in the `Examples Section <https://martinpdes.github.io/PyFiberModes>`_ of the documentation. Examples include:
803
+ - Calculating the effective index for a given mode.
804
+ - Visualizing mode profiles in optical fibers.
805
+ - Evaluating fiber parameters like V-number and dispersion.
795
806
 
796
807
  ----
797
808
 
809
+ Get Involved
810
+ ************
811
+ PyFiberModes is an actively maintained project, and contributions are highly encouraged! Whether it's a bug fix, feature request, or enhancement, your input is valuable.
812
+
813
+ - Report issues or request features on the `GitHub Issue Tracker <https://github.com/MartinPdeS/PyFiberModes/issues>`_.
814
+ - Open pull requests to improve the codebase.
815
+
798
816
  Contact
799
817
  *******
800
-
801
- PyFiberModes is actively developed, and contributions are welcome! If you'd like to collaborate or provide feedback, please reach out.
818
+ If you would like to collaborate, please reach out:
802
819
 
803
820
  Author: `Martin Poinsinet de Sivry-Houle <https://github.com/MartinPdS>`_
804
821
 
@@ -1,4 +1,3 @@
1
- from PyFiberModes.wavelength import Wavelength
2
1
  from PyFiberModes.mode import Mode, Family # noqa: F401
3
2
  from PyFiberModes.mode_instances import * # noqa: F403
4
3
  from PyFiberModes.factory import FiberFactory
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.7.0'
16
- __version_tuple__ = version_tuple = (0, 7, 0)
15
+ __version__ = version = '0.7.2'
16
+ __version_tuple__ = version_tuple = (0, 7, 2)
@@ -1,6 +1,6 @@
1
1
  import numpy as np
2
2
  from dataclasses import dataclass
3
- from typing import Tuple, Self
3
+ from typing import Tuple
4
4
 
5
5
 
6
6
  @dataclass
@@ -34,7 +34,7 @@ class CylindricalCoordinates:
34
34
  y = self.rho * np.sin(self.phi)
35
35
  return CartesianCoordinates(x=x, y=y, z=self.z)
36
36
 
37
- def to_cylindrical(self) -> Self:
37
+ def to_cylindrical(self):
38
38
  """
39
39
  Returns self in cylindrical format (no conversion needed).
40
40
 
@@ -116,10 +116,28 @@ class CartesianCoordinates:
116
116
  """
117
117
  if self.is_structured:
118
118
  x_min, x_max = self.x_boundaries
119
- return (x_max - x_min) / self.n_x
119
+ return (x_max - x_min) / len(self.x)
120
120
  raise ValueError("dx value cannot be inferred from an unstructured mesh.")
121
121
 
122
- # Similar implementations for dy and dz...
122
+ @property
123
+ def dy(self) -> float:
124
+ """
125
+ Calculates the grid spacing in the x-direction.
126
+
127
+ Returns
128
+ -------
129
+ float
130
+ Grid spacing in the x-direction.
131
+
132
+ Raises
133
+ ------
134
+ ValueError
135
+ If the mesh is unstructured.
136
+ """
137
+ if self.is_structured:
138
+ y_min, y_max = self.y_boundaries
139
+ return (y_max - y_min) / len(self.y)
140
+ raise ValueError("dx value cannot be inferred from an unstructured mesh.")
123
141
 
124
142
  @classmethod
125
143
  def generate_from_boundaries(cls, x_limits, y_limits, z_limits, x_points, y_points, z_points) -> 'CartesianCoordinates':
@@ -166,25 +184,15 @@ class CartesianCoordinates:
166
184
  length : float
167
185
  The length of the square's side.
168
186
  center : Tuple[float, float], optional
169
- The coordinates of the square's center (x0, y0).
170
- Default is (0.0, 0.0).
187
+ The coordinates of the square's center (x0, y0). Default is (0.0, 0.0).
171
188
  n_points : int, optional
172
- The number of points along each dimension (x, y).
173
- Default is 100.
189
+ The number of points along each dimension (x, y). Default is 100.
174
190
 
175
191
  Returns
176
192
  -------
177
193
  CartesianCoordinates
178
194
  Cartesian coordinate system with x, y mesh grids and z set to 0.
179
195
 
180
- Examples
181
- --------
182
- >>> coords = CartesianCoordinates.generate_from_square(
183
- ... length=2.0, center=(1.0, 1.0), n_points=10)
184
- >>> coords.x.shape
185
- (10, 10)
186
- >>> coords.y.shape
187
- (10, 10)
188
196
  """
189
197
  x0, y0 = center
190
198
 
@@ -232,7 +240,7 @@ class CartesianCoordinates:
232
240
  phi = np.arctan2(self.y, self.x)
233
241
  return CylindricalCoordinates(rho=rho, phi=phi, z=self.z)
234
242
 
235
- def shift_coordinates(self, shift: Tuple[float, float, float]) -> Self:
243
+ def shift_coordinates(self, shift: Tuple[float, float, float]):
236
244
  """
237
245
  Shifts the coordinates by specified amounts.
238
246
 
@@ -9,9 +9,7 @@ __all__ = [
9
9
  'root_path',
10
10
  'project_path',
11
11
  'examples_path',
12
- 'version_path',
13
12
  'doc_path',
14
- # 'logo_path',
15
13
  'doc_css_path',
16
14
  ]
17
15
 
@@ -19,8 +17,6 @@ root_path = Path(PyFiberModes.__path__[0])
19
17
 
20
18
  project_path = root_path.parents[0]
21
19
 
22
- version_path = root_path.joinpath('VERSION')
23
-
24
20
  doc_path = project_path.joinpath('docs')
25
21
 
26
22
  examples_path = doc_path.joinpath('examples')
@@ -29,13 +25,8 @@ logo_path = doc_path.joinpath('images/logo.png')
29
25
 
30
26
  doc_css_path = doc_path.joinpath('source/_static/default.css')
31
27
 
32
- rtd_example = 'https://pyfinitdiff.readthedocs.io/en/latest/Examples.html'
33
-
34
-
35
28
  if __name__ == '__main__':
36
29
  for path_name in __all__:
37
30
  path = locals()[path_name]
38
31
  print(path)
39
32
  assert path.exists(), f"Path {path_name} do not exists"
40
-
41
- # -
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ from itertools import product
5
+ from dataclasses import dataclass, field
6
+ import numpy as np
7
+ from PyFiberModes.fiber import Fiber
8
+
9
+
10
+ @dataclass
11
+ class ProxyLayer:
12
+ """
13
+ Represents a layer configuration in a fiber, with name, radius, and refractive index.
14
+
15
+ Attributes
16
+ ----------
17
+ name : str
18
+ Name of the layer.
19
+ radius : list[float]
20
+ Radius values for the layer (in meters).
21
+ index : list[float]
22
+ Refractive index values for the layer.
23
+ """
24
+ name: str
25
+ radius: list = field(default_factory=list)
26
+ index: list = field(default_factory=list)
27
+
28
+ def __post_init__(self):
29
+ self.name = [self.name]
30
+ self.radius = np.atleast_1d(self.radius)
31
+ self.index = np.atleast_1d(self.index)
32
+
33
+ def get_generator(self):
34
+ """
35
+ Create a generator for all combinations of name, radius, and index.
36
+
37
+ Returns
38
+ -------
39
+ generator : itertools.product
40
+ Generator yielding tuples of (name, radius, index).
41
+ """
42
+ return product(self.name, self.radius, self.index)
43
+
44
+
45
+ class FiberFactory:
46
+ """
47
+ Factory to create and manage multiple Fiber instances with various configurations.
48
+
49
+ Parameters
50
+ ----------
51
+ wavelength : float
52
+ Wavelength (in meters) used for fiber simulations.
53
+
54
+ Attributes
55
+ ----------
56
+ layers_list : list[ProxyLayer]
57
+ List of ProxyLayer objects representing the layers of the fiber.
58
+ neff_solver : None
59
+ Placeholder for a solver object (if required).
60
+ cutoff_solver : None
61
+ Placeholder for a cutoff solver object (if required).
62
+ wavelength : float
63
+ Wavelength used in simulations.
64
+ """
65
+
66
+ def __init__(self, wavelength: float):
67
+ self.layers_list = []
68
+ self.neff_solver = None
69
+ self.cutoff_solver = None
70
+ self.wavelength = wavelength
71
+
72
+ def add_layer(self, index: float, name: str = "", radius: float = 0.0):
73
+ """
74
+ Add a new layer to the fiber factory.
75
+
76
+ Parameters
77
+ ----------
78
+ index : float
79
+ Refractive index of the layer.
80
+ name : str, optional
81
+ Name of the layer (default is an empty string).
82
+ radius : float, optional
83
+ Radius of the layer (default is 0.0 meters).
84
+ """
85
+ layer = ProxyLayer(name=name, radius=radius, index=index)
86
+ self.layers_list.append(layer)
87
+
88
+ def get_overall_generator(self):
89
+ """
90
+ Generate all possible combinations of layer configurations.
91
+
92
+ Returns
93
+ -------
94
+ overall_generator : itertools.product
95
+ Generator yielding all possible layer configurations.
96
+ """
97
+ generators = [layer.get_generator() for layer in self.layers_list]
98
+ return product(*generators)
99
+
100
+ def __getitem__(self, index: int) -> Fiber:
101
+ """
102
+ Retrieve a specific fiber configuration by index.
103
+
104
+ Parameters
105
+ ----------
106
+ index : int
107
+ Index of the desired fiber configuration.
108
+
109
+ Returns
110
+ -------
111
+ fiber : Fiber
112
+ A Fiber object with the selected configuration.
113
+ """
114
+ structure = list(self.get_overall_generator())[index]
115
+ fiber = self._create_fiber_from_structure(structure)
116
+ return fiber
117
+
118
+ def __iter__(self):
119
+ """
120
+ Iterate through all possible fiber configurations.
121
+
122
+ Yields
123
+ ------
124
+ fiber : Fiber
125
+ A Fiber object with the next configuration in the sequence.
126
+ """
127
+ for structure in self.get_overall_generator():
128
+ yield self._create_fiber_from_structure(structure)
129
+
130
+ def _create_fiber_from_structure(self, structure) -> Fiber:
131
+ """
132
+ Create a Fiber object from a given structure.
133
+
134
+ Parameters
135
+ ----------
136
+ structure : iterable
137
+ An iterable containing tuples of (name, radius, index) for each layer.
138
+
139
+ Returns
140
+ -------
141
+ fiber : Fiber
142
+ A Fiber object initialized with the given structure.
143
+ """
144
+ fiber = Fiber(wavelength=self.wavelength)
145
+ for name, radius, index in structure:
146
+ fiber.add_layer(name=name, radius=radius, index=index)
147
+ fiber.initialize_layers()
148
+ return fiber