Skip to content

Commit d065c23

Browse files
committed
update
1 parent 18b065a commit d065c23

20 files changed

Lines changed: 1258 additions & 1414 deletions

CMAKES/Utils.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ add_custom_command(
55
COMMAND python3 setup.py bdist_wheel --NewMinor
66
COMMAND python3 -m twine upload --password $ENV{PyPiPassword} --username $ENV{PyPiToken} --repository pypi dist/*
77
COMMENT "Upload on Pypi")
8-
add_custom_target(UploadPypi DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/UploadPypi.txt)
8+
add_custom_target(Upload DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Upload.txt)
99

1010

1111

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/CMAKES/Meta.cmake)
55

66
include(${CMAKE_CURRENT_SOURCE_DIR}/CMAKES/EigenSolver.cmake)
77

8+
include(${CMAKE_CURRENT_SOURCE_DIR}/CMAKES/Utils.cmake)
9+
810
install(TARGETS EigenSolver DESTINATION SuPyMode/bin CONFIGURATIONS Release)
911

1012
#install(TARGETS EigenSolver DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} CONFIGURATIONS Debug)

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,32 @@ EigenSolver/fast:
174174
$(MAKE) $(MAKESILENT) -f CMakeFiles/EigenSolver.dir/build.make CMakeFiles/EigenSolver.dir/build
175175
.PHONY : EigenSolver/fast
176176

177+
#=============================================================================
178+
# Target rules for targets named Upload
179+
180+
# Build rule for target.
181+
Upload: cmake_check_build_system
182+
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 Upload
183+
.PHONY : Upload
184+
185+
# fast build rule for target.
186+
Upload/fast:
187+
$(MAKE) $(MAKESILENT) -f CMakeFiles/Upload.dir/build.make CMakeFiles/Upload.dir/build
188+
.PHONY : Upload/fast
189+
190+
#=============================================================================
191+
# Target rules for targets named Clean
192+
193+
# Build rule for target.
194+
Clean: cmake_check_build_system
195+
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 Clean
196+
.PHONY : Clean
197+
198+
# fast build rule for target.
199+
Clean/fast:
200+
$(MAKE) $(MAKESILENT) -f CMakeFiles/Clean.dir/build.make CMakeFiles/Clean.dir/build
201+
.PHONY : Clean/fast
202+
177203
SuPyMode/includes/interface.o: SuPyMode/includes/interface.cpp.o
178204
.PHONY : SuPyMode/includes/interface.o
179205

@@ -210,6 +236,8 @@ help:
210236
@echo "... install/strip"
211237
@echo "... list_install_components"
212238
@echo "... rebuild_cache"
239+
@echo "... Clean"
240+
@echo "... Upload"
213241
@echo "... EigenSolver"
214242
@echo "... SuPyMode/includes/interface.o"
215243
@echo "... SuPyMode/includes/interface.i"

SuPyMode/Geometry.py

Lines changed: 35 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,27 @@
33
import os
44
import numpy as np
55
import logging
6+
from dataclasses import dataclass
67

78
from matplotlib.path import Path
89
from itertools import combinations
910
from shapely.geometry import Point, box
1011
from shapely import affinity
1112
from scipy.ndimage.filters import gaussian_filter
1213
from shapely.geometry import Point, MultiPolygon, Polygon
13-
from shapely.ops import nearest_points, unary_union
1414
from shapely.geometry.collection import GeometryCollection
1515
from scipy.optimize import minimize_scalar
1616

1717
""" package imports """
18-
from SuPyMode.Tools.Directories import RootPath
1918
from SuPyMode.Tools.Special import gradientO4
2019
from SuPyMode.Tools.utils import ToList, Axes
21-
from SuPyMode.Plotting.Plots import Scene, Axis, Mesh, Contour
20+
from SuPyMode.Plotting.Plots import Scene, Axis, Mesh, Contour, ColorBar
2221
from SuPyMode.Tools.utils import ObjectUnion
22+
from SuPyMode.Tools.ShapelyUtils import NearestPoints, GetBoundaries, ObjectIntersection, Rotate
2323

2424
Mlogger = logging.getLogger(__name__)
2525

26-
def NearestPoints(object0, object1):
27-
return list( nearest_points(object0.exterior, object1.exterior) )
2826

29-
def GetBoundaries(Objects):
30-
Objects = ToList(Objects)
31-
return unary_union(Objects).bounds
32-
33-
def ObjectIntersection(Objects):
34-
Objects = ToList(Objects)
35-
object0 = Objects[0]
36-
37-
for object in Objects:
38-
object0 = object0.intersection(object)
39-
40-
return object0
41-
42-
43-
def Rotate(Coord = None, Object=None, Angle=0):
44-
45-
Angle = ToList(Angle)
46-
rotated = tuple( affinity.rotate(Object, angle, origin = (0,0) ) for angle in Angle )
47-
48-
if len(rotated) == 1:
49-
return rotated[0]
50-
else:
51-
return rotated
5227

5328
class Gradient:
5429
def __init__(self, Center, Nin, Nout, Rout):
@@ -71,6 +46,8 @@ class Namespace:
7146
def __init__(self, **kwargs):
7247
self.__dict__.update(kwargs)
7348

49+
50+
@dataclass
7451
class Geometry(object):
7552
""" Class represent the refractive index (RI) geometrique profile which
7653
can be used to retrieve the supermodes.
@@ -89,25 +66,25 @@ class Geometry(object):
8966
Number of point for Y dimensions discretization.
9067
"""
9168

92-
def __init__(self, Clad, Objects, Xbound, Ybound, Nx, Ny, GConv=0, BackGroundIndex=1.):
93-
self.Clad = Clad
94-
95-
self.Objects = ToList(Objects)
96-
97-
self.Boundaries = [Xbound, Ybound]
69+
Clad: object
70+
Objects: list
71+
Xbound: list
72+
Ybound: list
73+
Nx: int = 100
74+
Ny: int = 10
75+
GConv: float = 0
76+
BackGroundIndex: float = 1.
9877

99-
self.Shape = [Nx, Ny]
100-
101-
self.GConv = GConv
102-
self._Mesh = None
103-
104-
self.BackGroundIndex = BackGroundIndex
78+
def __post_init__(self):
79+
self.Objects = ToList(self.Objects)
80+
self.Boundaries = [self.Xbound, self.Ybound]
81+
self.Shape = [self.Nx, self.Ny]
10582

10683
self.Axes = Axes( {'wavelength': 1.0,
107-
'Xbound' : Xbound,
108-
'Ybound' : Ybound,
109-
'Nx' : Nx,
110-
'Ny' : Ny } )
84+
'Xbound' : self.Xbound,
85+
'Ybound' : self.Ybound,
86+
'Nx' : self.Nx,
87+
'Ny' : self.Ny } )
11188

11289
self.CreateBackGround()
11390
self.GetAllIndex()
@@ -282,18 +259,17 @@ def Plot(self):
282259
self.CreateMesh()
283260

284261
Fig = Scene('SuPyMode Figure', UnitSize=(4,4))
262+
Colorbar = ColorBar(Discreet=True, Position='right')
285263

286264
ax = Axis(Row = 0,
287265
Col = 0,
288266
xLabel = r'x [$\mu m$]',
289267
yLabel = r'y [$\mu m$]',
290268
Title = f'Refractive index structure',
291269
Legend = False,
292-
ColorBar = True,
293270
Grid = False,
294271
Equal = True,
295-
DiscreetColorbar = True,
296-
ColorbarPosition = 'right',
272+
Colorbar = Colorbar,
297273
xScale = 'linear',
298274
yScale = 'linear')
299275

@@ -337,22 +313,21 @@ def Gradient(self, Plot=False):
337313

338314

339315

340-
316+
@dataclass
341317
class BaseFused():
342-
def __init__(self, Radius, Fusion, Angle, Theta, Index, debug, Gradient=None):
343-
344-
assert not all([Index, Gradient]), "Error, you must either define an Index or a Gradient but not both."
345-
assert any([Index, Gradient]), "Error, you must at least define an Index or a Gradient."
346-
Mlogger.setLevel(getattr(logging, debug))
347-
348-
self.Index = Index
349-
self.Radius = Radius
350-
self.Fusion = Fusion
351-
self.Angle = Angle
318+
Radius: float
319+
Fusion: float
320+
Angle: float
321+
Theta: float
322+
Index: float
323+
debug: bool
324+
Gradient: object = None
325+
326+
def __post_init__(self):
352327
self.hole = None
353328
self.N = len(self.Angle)
354-
self.Theta = np.deg2rad(Theta)
355-
self.Gradient = Gradient
329+
self.Theta = np.deg2rad(self.Theta)
330+
356331
self.GetFibers()
357332
self.GetTopology()
358333

0 commit comments

Comments
 (0)