Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinPdeS committed Jun 29, 2022
1 parent 18b065a commit d065c23
Show file tree
Hide file tree
Showing 20 changed files with 1,258 additions and 1,414 deletions.
2 changes: 1 addition & 1 deletion CMAKES/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ add_custom_command(
COMMAND python3 setup.py bdist_wheel --NewMinor
COMMAND python3 -m twine upload --password $ENV{PyPiPassword} --username $ENV{PyPiToken} --repository pypi dist/*
COMMENT "Upload on Pypi")
add_custom_target(UploadPypi DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/UploadPypi.txt)
add_custom_target(Upload DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Upload.txt)



Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/CMAKES/Meta.cmake)

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

include(${CMAKE_CURRENT_SOURCE_DIR}/CMAKES/Utils.cmake)

install(TARGETS EigenSolver DESTINATION SuPyMode/bin CONFIGURATIONS Release)

#install(TARGETS EigenSolver DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} CONFIGURATIONS Debug)
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,32 @@ EigenSolver/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles/EigenSolver.dir/build.make CMakeFiles/EigenSolver.dir/build
.PHONY : EigenSolver/fast

#=============================================================================
# Target rules for targets named Upload

# Build rule for target.
Upload: cmake_check_build_system
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 Upload
.PHONY : Upload

# fast build rule for target.
Upload/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles/Upload.dir/build.make CMakeFiles/Upload.dir/build
.PHONY : Upload/fast

#=============================================================================
# Target rules for targets named Clean

# Build rule for target.
Clean: cmake_check_build_system
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 Clean
.PHONY : Clean

# fast build rule for target.
Clean/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles/Clean.dir/build.make CMakeFiles/Clean.dir/build
.PHONY : Clean/fast

SuPyMode/includes/interface.o: SuPyMode/includes/interface.cpp.o
.PHONY : SuPyMode/includes/interface.o

Expand Down Expand Up @@ -210,6 +236,8 @@ help:
@echo "... install/strip"
@echo "... list_install_components"
@echo "... rebuild_cache"
@echo "... Clean"
@echo "... Upload"
@echo "... EigenSolver"
@echo "... SuPyMode/includes/interface.o"
@echo "... SuPyMode/includes/interface.i"
Expand Down
95 changes: 35 additions & 60 deletions SuPyMode/Geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,27 @@
import os
import numpy as np
import logging
from dataclasses import dataclass

from matplotlib.path import Path
from itertools import combinations
from shapely.geometry import Point, box
from shapely import affinity
from scipy.ndimage.filters import gaussian_filter
from shapely.geometry import Point, MultiPolygon, Polygon
from shapely.ops import nearest_points, unary_union
from shapely.geometry.collection import GeometryCollection
from scipy.optimize import minimize_scalar

""" package imports """
from SuPyMode.Tools.Directories import RootPath
from SuPyMode.Tools.Special import gradientO4
from SuPyMode.Tools.utils import ToList, Axes
from SuPyMode.Plotting.Plots import Scene, Axis, Mesh, Contour
from SuPyMode.Plotting.Plots import Scene, Axis, Mesh, Contour, ColorBar
from SuPyMode.Tools.utils import ObjectUnion
from SuPyMode.Tools.ShapelyUtils import NearestPoints, GetBoundaries, ObjectIntersection, Rotate

Mlogger = logging.getLogger(__name__)

def NearestPoints(object0, object1):
return list( nearest_points(object0.exterior, object1.exterior) )

def GetBoundaries(Objects):
Objects = ToList(Objects)
return unary_union(Objects).bounds

def ObjectIntersection(Objects):
Objects = ToList(Objects)
object0 = Objects[0]

for object in Objects:
object0 = object0.intersection(object)

return object0


def Rotate(Coord = None, Object=None, Angle=0):

Angle = ToList(Angle)
rotated = tuple( affinity.rotate(Object, angle, origin = (0,0) ) for angle in Angle )

if len(rotated) == 1:
return rotated[0]
else:
return rotated

class Gradient:
def __init__(self, Center, Nin, Nout, Rout):
Expand All @@ -71,6 +46,8 @@ class Namespace:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)


@dataclass
class Geometry(object):
""" Class represent the refractive index (RI) geometrique profile which
can be used to retrieve the supermodes.
Expand All @@ -89,25 +66,25 @@ class Geometry(object):
Number of point for Y dimensions discretization.
"""

def __init__(self, Clad, Objects, Xbound, Ybound, Nx, Ny, GConv=0, BackGroundIndex=1.):
self.Clad = Clad

self.Objects = ToList(Objects)

self.Boundaries = [Xbound, Ybound]
Clad: object
Objects: list
Xbound: list
Ybound: list
Nx: int = 100
Ny: int = 10
GConv: float = 0
BackGroundIndex: float = 1.

self.Shape = [Nx, Ny]

self.GConv = GConv
self._Mesh = None

self.BackGroundIndex = BackGroundIndex
def __post_init__(self):
self.Objects = ToList(self.Objects)
self.Boundaries = [self.Xbound, self.Ybound]
self.Shape = [self.Nx, self.Ny]

self.Axes = Axes( {'wavelength': 1.0,
'Xbound' : Xbound,
'Ybound' : Ybound,
'Nx' : Nx,
'Ny' : Ny } )
'Xbound' : self.Xbound,
'Ybound' : self.Ybound,
'Nx' : self.Nx,
'Ny' : self.Ny } )

self.CreateBackGround()
self.GetAllIndex()
Expand Down Expand Up @@ -282,18 +259,17 @@ def Plot(self):
self.CreateMesh()

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

ax = Axis(Row = 0,
Col = 0,
xLabel = r'x [$\mu m$]',
yLabel = r'y [$\mu m$]',
Title = f'Refractive index structure',
Legend = False,
ColorBar = True,
Grid = False,
Equal = True,
DiscreetColorbar = True,
ColorbarPosition = 'right',
Colorbar = Colorbar,
xScale = 'linear',
yScale = 'linear')

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




@dataclass
class BaseFused():
def __init__(self, Radius, Fusion, Angle, Theta, Index, debug, Gradient=None):

assert not all([Index, Gradient]), "Error, you must either define an Index or a Gradient but not both."
assert any([Index, Gradient]), "Error, you must at least define an Index or a Gradient."
Mlogger.setLevel(getattr(logging, debug))

self.Index = Index
self.Radius = Radius
self.Fusion = Fusion
self.Angle = Angle
Radius: float
Fusion: float
Angle: float
Theta: float
Index: float
debug: bool
Gradient: object = None

def __post_init__(self):
self.hole = None
self.N = len(self.Angle)
self.Theta = np.deg2rad(Theta)
self.Gradient = Gradient
self.Theta = np.deg2rad(self.Theta)

self.GetFibers()
self.GetTopology()

Expand Down
Loading

0 comments on commit d065c23

Please sign in to comment.