Skip to content

Commit

Permalink
Version 0.1.8
Browse files Browse the repository at this point in the history
* bug fix for 0.1.7, nothing added.
  • Loading branch information
Hideousmon committed Sep 25, 2021
1 parent fb4d106 commit c74fba1
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,8 @@ The documentation can be found [here](https://splayout.readthedocs.io/en/latest/
* Support cell flatten.
* Fix a bug: initial_solution in DirectBianrySearchAlgorithm can not be properly defined.


### Version 0.1.8 (Sep 25, 2021)

* Able to derive phase information from monitor.
* Able to create rectangle&circle pixels with fdtd functions.
8 changes: 6 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,16 @@ Version 0.1.4 & Version 0.1.5 (Sep 6, 2021)
Version 0.1.6 (Sep 17, 2021)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- README.rst for pypi ducumentation.
- Support numpy array for Polygong definition.
- Annotation for DBS run .
- Support numpy array for Polygon definition.
- Annotation for DBS run.
- Support cell flatten.
- Fix a bug: initial_solution in DirectBianrySearchAlgorithm can not be properly defined.

Version 0.1.8 (Sep 25, 2021)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Able to derive phase information from monitor.
- Able to create rectangle&circle pixels with fdtd functions.


.. |GitHub repository| image:: https://img.shields.io/badge/github-SPLayout-blue
Expand Down
2 changes: 2 additions & 0 deletions examples/inverse design/powersplitter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


2 changes: 1 addition & 1 deletion splayout/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.1.6"
__version__ = "0.1.8"

from splayout.AEMDgrating import MAKE_AEMD_GRATING
from splayout.bend import Bend
Expand Down
94 changes: 93 additions & 1 deletion splayout/fdtdapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self,hide=0,fdtd_path = "C:\\Program Files\\Lumerical\\v202\\api\\p

def add_structure_from_gdsii(self,filename,cellname,layer=1,datatype=0,material=Si, z_start = -0.11, z_end = 0.11,rename = None):
"""
Draw the Component on the layout.
Draw the structure to the simulation CAD from gdsii file.
Parameters
----------
Expand Down Expand Up @@ -63,6 +63,67 @@ def add_structure_from_gdsii(self,filename,cellname,layer=1,datatype=0,material=
self.fdtd.eval("select(\"GDS_LAYER_" + str(layer) +":" + str(datatype) + "\");")
self.fdtd.eval("set(\"name\",\"" + rename + "\");")

def add_structure_circle(self, center_point, radius, material=SiO2, z_start = -0.11, z_end = 0.11,rename = "circle"):
'''
Draw the a circle on the simulation CAD.
Parameters
----------
center_point : Point
Center point of the circle.
radius : float
Radius of the circle (unit: μm).
material : String
Material setting for the structure in Lumerical FDTD (SiO2 = "SiO2 (Glass) - Palik", SiO2 = "SiO2 (Glass) - Palik", default: SiO2).
z_start : Float
The start point for the structure in z axis (unit: μm, default: -0.11).
z_end : Float
The end point for the structure in z axis (unit: μm, default: 0.11).
rename : String
New name of the structure in Lumerical FDTD (default: "circle").
'''
self.fdtd.eval("addcircle;")
self.fdtd.eval("set(\"x\"," + str(center_point.x) + "e-6);")
self.fdtd.eval("set(\"y\"," + str(center_point.y) + "e-6);")
self.fdtd.eval("set(\"radius\"," + str(radius) + "e-6);")
self.fdtd.eval("set(\"z min\"," + str(z_start) + "e-6);")
self.fdtd.eval("set(\"z max\"," + str(z_end) + "e-6);")
self.fdtd.eval("set(\"material\",\"" + material + "\");")
self.fdtd.eval("set(\"name\",\"" + rename + "\");")



def add_structure_rectangle(self, center_point, x_length, y_length, material=SiO2, z_start=-0.11, z_end=0.11, rename="rect"):
'''
Draw the a rectangle on the simulation CAD.
Parameters
----------
center_point : Point
Center point of the rectangle.
x_length : float
Length in the x axis (unit: μm).
y_length : float
Length in the y axis (unit: μm).
material : String
Material setting for the structure in Lumerical FDTD (SiO2 = "SiO2 (Glass) - Palik", SiO2 = "SiO2 (Glass) - Palik", default: SiO2).
z_start : Float
The start point for the structure in z axis (unit: μm, default: -0.11).
z_end : Float
The end point for the structure in z axis (unit: μm, default: 0.11).
rename : String
New name of the structure in Lumerical FDTD (default: "rect").
'''
self.fdtd.eval("addrect;")
self.fdtd.eval("set(\"x\"," + str(center_point.x) + "e-6);")
self.fdtd.eval("set(\"x span\"," + str(x_length) + "e-6);")
self.fdtd.eval("set(\"y\"," + str(center_point.y) + "e-6);")
self.fdtd.eval("set(\"y span\"," + str(y_length) + "e-6);")
self.fdtd.eval("set(\"z min\"," + str(z_start) + "e-6);")
self.fdtd.eval("set(\"z max\"," + str(z_end) + "e-6);")
self.fdtd.eval("set(\"material\",\"" + material + "\");")
self.fdtd.eval("set(\"name\",\"" + rename + "\");")

def add_power_monitor(self,position,width=2,height=0.8,monitor_name="powermonitor",points=1001):
"""
Add power monitor in Lumerical FDTD (DFT Frequency monitor).
Expand Down Expand Up @@ -460,6 +521,37 @@ def get_mode_transmission(self,expansion_name, datafile = None):
np.save(datafile, spectrum)
return spectrum

def get_mode_phase(self, expansion_name, direction = FORWARD, datafile = None):
"""
Get data and calculate phase vs wavelength from mode expansion monitor after running the simulation.
Parameters
----------
expansion_name : String
Name of the mode expansion monitor.
direction : Int
The light propagation direction 1: the positive direction of x-axis, 0: the negative direction of x-axis(FORWARD:1, BACKWARD:0 , default: FORWARD).
datafile : String
The name of the file for saving the data, None means no saving (default: None).
Returns
-------
out : Array
Phase, size: (1,frequency points).
"""
mode_exp_data_set = self.fdtd.getresult(expansion_name, 'expansion for Output')
fwd_trans_coeff = mode_exp_data_set['a'] * np.sqrt(mode_exp_data_set['N'].real)
back_trans_coeff = mode_exp_data_set['b'] * np.sqrt(mode_exp_data_set['N'].real)
if direction == FORWARD:
mode_phase = np.angle(fwd_trans_coeff)
elif direction == BACKWARD:
mode_phase = np.angle(back_trans_coeff)
else:
raise Exception("Wrong direction setting!")
if (datafile != None):
np.save(datafile, mode_phase.flatten())
return mode_phase.flatten()

def get_mode_coefficient(self, expansion_name , direction = FORWARD, datafile = None):
"""
Get data and calculate coefficient from mode expansion monitor after running the simulation.
Expand Down

0 comments on commit c74fba1

Please sign in to comment.