Skip to content

Commit

Permalink
Version 0.2.0
Browse files Browse the repository at this point in the history
* Component drawing functions on fdtd_engine with z_start, z_end and material. .
* Tuple support for definitions.
* Float index to define material in fdtd (object defined dielectric).
* Lumerical script eval for fdtd.
* ArbitraryAngleWaveguide class.
* Example for DBS.
* Width property for waveguides.
* Fix a bug for unexpected rotation in SelfDefineComponent.
* Self.start_point -> self.start_point_for_return in func:get_start_point of SelfDefineComponent.
* Able to get backward transmission from mode expansion monitor.
  • Loading branch information
Hideousmon committed Oct 28, 2021
1 parent 707331c commit 2a52478
Show file tree
Hide file tree
Showing 21 changed files with 1,237 additions and 194 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,5 @@ dist
.gitattributes
docs/Makefile
docs/make.bat
docs/_build
docs/_build
temporal_tests
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,17 @@ A polarization beam splitter inverse design example can be found [here](https://
### Version 0.1.9 (Sep 29, 2021)

* Pixels region for inverse design.
* Variable names: point1 -> bottom_left_corner_point, point2 -> top_right_corner_point.
* Variable names: point1 -> bottom_left_corner_point, point2 -> top_right_corner_point.

### Version 0.2.0 (Oct 29, 2021)

* Component drawing functions on fdtd_engine with z_start, z_end and material. .
* Tuple support for definitions.
* Float index to define material in fdtd (object defined dielectric).
* Lumerical script eval for fdtd.
* ArbitraryAngleWaveguide class.
* Example for DBS.
* Width property for waveguides.
* Fix a bug for unexpected rotation in SelfDefineComponent.
* Self.start_point -> self.start_point_for_return in func:get_start_point of SelfDefineComponent.
* Able to get backward transmission from mode expansion monitor.
14 changes: 14 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ Version 0.1.9 (Sep 29, 2021)
- Pixels region for inverse design.
- Variable names: point1 -> bottom_left_corner_point, point2 -> top_right_corner_point.

Version 0.2.0 (Oct 29, 2021)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Component drawing functions on fdtd_engine with z_start, z_end and material. .
- Tuple support for definitions.
- Float index to define material in fdtd (object defined dielectric).
- Lumerical script eval for fdtd.
- ArbitraryAngleWaveguide class.
- Example for DBS.
- Width property for waveguides.
- Fix a bug for unexpected rotation in SelfDefineComponent.
- Self.start_point -> self.start_point_for_return in func:get_start_point of SelfDefineComponent.
- Able to get backward transmission from mode expansion monitor.


.. |GitHub repository| image:: https://img.shields.io/badge/github-SPLayout-blue
:target: https://github.com/Hideousmon/SPLayout
Expand Down
16 changes: 16 additions & 0 deletions docs/apireference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ Waveguide
:inherited-members:
:show-inheritance:

ArbitraryAngleWaveguide
=============

.. autoclass:: splayout.ArbitraryAngleWaveguide
:members:
:inherited-members:
:show-inheritance:

Taper
=============

Expand Down Expand Up @@ -192,6 +200,14 @@ FDTDSimulation
:inherited-members:
:show-inheritance:

MODESimulation
=============

.. autoclass:: splayout.MODESimulation
:members:
:inherited-members:
:show-inheritance:


******************************************
Inverse Design Algorithms
Expand Down
2 changes: 1 addition & 1 deletion splayout/AEMDgrating.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def MAKE_AEMD_GRATING(port_width=0.45,waveguide_layer=Layer(1,0),etch_layer=Laye

class AEMDgrating():
def __init__(self,start_point,relative_position = RIGHT):
self.start_point = start_point
self.start_point = tuple_to_point(start_point)
self.rotate_radian = relative_position
self.count = AEMDGratingCount_local

Expand Down
12 changes: 9 additions & 3 deletions splayout/Selfdefinecomponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,19 @@ def MAKE_COMPONENT(filename,rename=None,relative_start_point=Point(0,0),relative
SelfDefineCount += 1
SelfDefineCount_local = SelfDefineCount

relative_start_point = tuple_to_point(relative_start_point)
relative_end_point = tuple_to_point(relative_end_point)
relative_input_point =tuple_to_point(relative_input_point)
relative_through_point =tuple_to_point(relative_through_point)
relative_drop_point =tuple_to_point(relative_drop_point)
relative_add_point = tuple_to_point(relative_add_point)



class SelfDefineComponent():
def __init__(self,start_point,relative_position=RIGHT):
self.start_point = start_point - relative_start_point
self.rotate_radian = relative_position - initial_relative_position
self.start_point = tuple_to_point(start_point) - relative_start_point
self.rotate_radian = (relative_position - initial_relative_position + 360)%360
self.count = SelfDefineCount_local
if (type(relative_start_point) != type(None)):
if (self.rotate_radian == RIGHT):
Expand Down Expand Up @@ -179,7 +185,7 @@ def draw(self,cell):
cell.cell.add(gdspy.CellReference(SelfDefineComponent_cell_list[self.count].cell, (self.start_point.x, self.start_point.y),rotation=self.rotate_radian))

def get_start_point(self):
return self.start_point
return self.start_point_for_return

def get_end_point(self):
if (type(self.end_point_for_return) == type(None)):
Expand Down
5 changes: 3 additions & 2 deletions splayout/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.1.9"
__version__ = "0.2.0"

from splayout.AEMDgrating import MAKE_AEMD_GRATING
from splayout.bend import Bend
Expand All @@ -10,10 +10,11 @@
from splayout.taper import Taper
from splayout.text import Text
from splayout.utils import *
from splayout.waveguide import Waveguide
from splayout.waveguide import Waveguide, ArbitraryAngleWaveguide
from splayout.sbend import SBend,ASBend
from splayout.filledpattern import Circle,Rectangle
from splayout.fdtdapi import FDTDSimulation
from splayout.modeapi import MODESimulation
from splayout.BinaryBatAlgorithm import BinaryBatAlgorithm
from splayout.DirectBinarySearchAlgorithm import DirectBianrySearchAlgorithm
from splayout.pixelsregion import RectanglePixelsRegion,CirclePixelsRegion
37 changes: 34 additions & 3 deletions splayout/bend.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from splayout.utils import *
from splayout.waveguide import Waveguide
from splayout.fdtdapi import FDTDSimulation
from splayout.modeapi import MODESimulation

class Bend:
"""
Expand All @@ -17,13 +18,23 @@ class Bend:
Width of the waveguide (μm).
radius : float
Radius of the bend (μm).
z_start : Float
The start point for the structure in z axis (unit: μm, default: None, only useful when draw on CAD).
z_end : Float
The end point for the structure in z axis (unit: μm, default: None, only useful when draw on CAD).
material : str or float
Material setting for the structure in Lumerical FDTD (SiO2 = "SiO2 (Glass) - Palik", SiO2 = "SiO2 (Glass) - Palik"). When it is a float, the material in FDTD will be
<Object defined dielectric>, and index will be defined. (default: None, only useful when draw on CAD)
"""
def __init__(self,center_point, start_radian, end_radian, width , radius):
self.center_point = center_point
def __init__(self,center_point, start_radian, end_radian, width , radius, z_start = None, z_end = None, material = None):
self.center_point = tuple_to_point(center_point)
self.start_radian = start_radian
self.end_radian = end_radian
self.width = width
self.radius = radius
self.z_start = z_start
self.z_end = z_end
self.material = material
self.start_point = Point(self.center_point.x + radius*math.cos(start_radian),
self.center_point.y + radius*math.sin(start_radian))
self.end_point = Point(self.center_point.x + radius * math.cos(end_radian),
Expand Down Expand Up @@ -59,6 +70,26 @@ def draw(self,cell,layer):
cell.cell.add(round)
return self.start_point, self.end_point

def draw_on_lumerical_CAD(self, engine):
"""
Draw the Component on the lumerical CAD (FDTD or MODE).
Parameters
----------
engine : FDTDSimulation or MODESimulation
CAD to draw the component.
"""
if ((type(engine) == FDTDSimulation) or (type(engine) == MODESimulation)):
if (type(self.z_start) != type(None) and type(self.z_end) != type(None) and type(self.material) != type(None) ):
engine.put_round(self.center_point, inner_radius = self.radius - self.width/2,
outer_radius = self.radius + self.width/2,
start_radian = self.start_radian,
end_radian = self.end_radian, z_start=self.z_start, z_end= self.z_end, material= self.material)
else:
raise Exception("Z-axis specification or material specification is missing!")
else:
raise Exception("Wrong CAD engine!")

def get_start_point(self):
"""
Derive the start point of the bend.
Expand Down
69 changes: 50 additions & 19 deletions splayout/doubleconnector.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from splayout.utils import *
from splayout.quarbend import AQuarBend,QuarBend
from splayout.fdtdapi import FDTDSimulation
from splayout.modeapi import MODESimulation

class DoubleBendConnector:
"""
Expand All @@ -13,6 +15,13 @@ class DoubleBendConnector:
End point of the DoubleBendConnector.
width : float
Width of the waveguide (μm).
z_start : Float
The start point for the structure in z axis (unit: μm, default: None, only useful when draw on CAD).
z_end : Float
The end point for the structure in z axis (unit: μm, default: None, only useful when draw on CAD).
material : str or float
Material setting for the structure in Lumerical FDTD (SiO2 = "SiO2 (Glass) - Palik", SiO2 = "SiO2 (Glass) - Palik"). When it is a float, the material in FDTD will be
<Object defined dielectric>, and index will be defined. (default: None, only useful when draw on CAD)
radius : float
Radius of the bends (μm).
xpercent : float
Expand All @@ -25,10 +34,14 @@ class DoubleBendConnector:
start point and end point in the vertical direction
"""
def __init__(self,start_point,end_point,width,radius=5, xpercent = 0.5 , ypercent = 0.5,direction = HORIZONTAL):
self.start_point = start_point
self.end_point = end_point
def __init__(self,start_point,end_point,width, z_start = None, z_end = None, material = None,radius=5, xpercent = 0.5 , ypercent = 0.5,direction = HORIZONTAL):
self.start_point = tuple_to_point(start_point)
self.end_point = tuple_to_point(end_point)
self.radius = radius
self.width = width
self.z_start = z_start
self.z_end = z_end
self.material = material
self.x_percent = xpercent
self.y_percent = ypercent
self.direction = direction
Expand All @@ -40,38 +53,38 @@ def __init__(self,start_point,end_point,width,radius=5, xpercent = 0.5 , ypercen

if (self.start_point.x < self.end_point.x and self.start_point.y < self.end_point.y): ## up right type
if (self.direction == HORIZONTAL):
self.first_bend = AQuarBend(self.start_point, self.center_point, width,self.radius)
self.second_bend = QuarBend(self.center_point, self.end_point, width,self.radius)
self.first_bend = AQuarBend(self.start_point, self.center_point, width,self.radius, z_start = self.z_start, z_end = self.z_end, material = self.material)
self.second_bend = QuarBend(self.center_point, self.end_point, width,self.radius, z_start = self.z_start, z_end = self.z_end, material = self.material)
elif (self.direction == VERTICAL):
self.first_bend = QuarBend(self.start_point, self.center_point, width, self.radius)
self.second_bend = AQuarBend(self.center_point, self.end_point, width, self.radius)
self.first_bend = QuarBend(self.start_point, self.center_point, width, self.radius, z_start = self.z_start, z_end = self.z_end, material = self.material)
self.second_bend = AQuarBend(self.center_point, self.end_point, width, self.radius, z_start = self.z_start, z_end = self.z_end, material = self.material)
else:
raise Exception("Wrong direction expression!")
elif (self.start_point.x < self.end_point.x and self.start_point.y > self.end_point.y): ## down right type
if (self.direction == HORIZONTAL):
self.first_bend = QuarBend(self.start_point, self.center_point, width,self.radius)
self.second_bend = AQuarBend(self.center_point, self.end_point, width,self.radius)
self.first_bend = QuarBend(self.start_point, self.center_point, width,self.radius, z_start = self.z_start, z_end = self.z_end, material = self.material)
self.second_bend = AQuarBend(self.center_point, self.end_point, width,self.radius, z_start = self.z_start, z_end = self.z_end, material = self.material)
elif (self.direction == VERTICAL):
self.first_bend = AQuarBend(self.start_point, self.center_point, width, self.radius)
self.second_bend = QuarBend(self.center_point, self.end_point, width, self.radius)
self.first_bend = AQuarBend(self.start_point, self.center_point, width, self.radius, z_start = self.z_start, z_end = self.z_end, material = self.material)
self.second_bend = QuarBend(self.center_point, self.end_point, width, self.radius, z_start = self.z_start, z_end = self.z_end, material = self.material)
else:
raise Exception("Wrong direction expression!")
elif (self.start_point.x > self.end_point.x and self.start_point.y > self.end_point.y): ## down left type
if (self.direction == HORIZONTAL):
self.first_bend = AQuarBend(self.start_point, self.center_point, width,self.radius)
self.second_bend = QuarBend(self.center_point, self.end_point, width,self.radius)
self.first_bend = AQuarBend(self.start_point, self.center_point, width,self.radius, z_start = self.z_start, z_end = self.z_end, material = self.material)
self.second_bend = QuarBend(self.center_point, self.end_point, width,self.radius, z_start = self.z_start, z_end = self.z_end, material = self.material)
elif (self.direction == VERTICAL):
self.first_bend = QuarBend(self.start_point, self.center_point, width, self.radius)
self.second_bend = AQuarBend(self.center_point, self.end_point, width, self.radius)
self.first_bend = QuarBend(self.start_point, self.center_point, width, self.radius, z_start = self.z_start, z_end = self.z_end, material = self.material)
self.second_bend = AQuarBend(self.center_point, self.end_point, width, self.radius, z_start = self.z_start, z_end = self.z_end, material = self.material)
else:
raise Exception("Wrong direction expression!")
elif (self.start_point.x > self.end_point.x and self.start_point.y < self.end_point.y): ## up left type
if (self.direction == HORIZONTAL):
self.first_bend = QuarBend(self.start_point, self.center_point, width,self.radius)
self.second_bend = AQuarBend(self.center_point, self.end_point, width,self.radius)
self.first_bend = QuarBend(self.start_point, self.center_point, width,self.radius, z_start = self.z_start, z_end = self.z_end, material = self.material)
self.second_bend = AQuarBend(self.center_point, self.end_point, width,self.radius, z_start = self.z_start, z_end = self.z_end, material = self.material)
elif (self.direction == VERTICAL):
self.first_bend = AQuarBend(self.start_point, self.center_point, width, self.radius)
self.second_bend = QuarBend(self.center_point, self.end_point, width, self.radius)
self.first_bend = AQuarBend(self.start_point, self.center_point, width, self.radius, z_start = self.z_start, z_end = self.z_end, material = self.material)
self.second_bend = QuarBend(self.center_point, self.end_point, width, self.radius, z_start = self.z_start, z_end = self.z_end, material = self.material)
else:
raise Exception("Wrong direction expression!")
else:
Expand All @@ -97,6 +110,24 @@ def draw(self,cell,layer):
self.second_bend.draw(cell,layer )
return self.start_point, self.end_point

def draw_on_lumerical_CAD(self, engine):
"""
Draw the Component on the lumerical CAD (FDTD or MODE).
Parameters
----------
engine : FDTDSimulation or MODESimulation
CAD to draw the component.
"""
if ((type(engine) == FDTDSimulation) or (type(engine) == MODESimulation)):
if (type(self.z_start) != type(None) and type(self.z_end) != type(None) and type(self.material) != type(None) ):
self.first_bend.draw_on_lumerical_CAD(engine)
self.second_bend.draw_on_lumerical_CAD(engine)
else:
raise Exception("Z-axis specification or material specification is missing!")
else:
raise Exception("Wrong CAD engine!")

def get_start_point(self):
"""
Derive the start point of the connector.
Expand Down
Loading

0 comments on commit 2a52478

Please sign in to comment.