Skip to content

Commit

Permalink
Version 0.2.5
Browse files Browse the repository at this point in the history
* add_index_region, add_field_region, add_mesh_region can be defined by z_min&z_max.
* Support Fundamental TE mode for add_mode_expansion in fdtdapi.
* Fix a bug for get_transmission error.
  • Loading branch information
Hideousmon committed Nov 26, 2021
1 parent bf81ef4 commit 95f913f
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 16 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,11 @@ A polarization beam splitter inverse design example can be found [here](https://
* Anti-Symmetry boundary condition choice for FDTD simulation region.
* Fix bugs for material definition with float type parameters.
* Fix bugs for putting round on Lumerical CAD.
* Support fundamental TE mode for add_mode_source in fdtdapi.
* Support fundamental TE mode for add_mode_source in fdtdapi.


### Version 0.2.5 (Nov 26, 2021)

* add_index_region, add_field_region, add_mesh_region can be defined by z_min&z_max.
* Support Fundamental TE mode for add_mode_expansion in fdtdapi.
* Fix a bug for get_transmission error.
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ Version 0.2.4 (Nov 13, 2021)
- Support fundamental TE mode for add_mode_source in fdtdapi.


Version 0.2.5 (Nov 26, 2021)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- add_index_region, add_field_region, add_mesh_region can be defined by z_min&z_max.
- Support Fundamental TE mode for add_mode_expansion in fdtdapi.
- Fix a bug for get_transmission error.


.. |GitHub repository| image:: https://img.shields.io/badge/github-SPLayout-blue
:target: https://github.com/Hideousmon/SPLayout
Expand Down
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.2.4"
__version__ = "0.2.5"

from splayout.AEMDgrating import MAKE_AEMD_GRATING
from splayout.bend import Bend
Expand Down
36 changes: 26 additions & 10 deletions splayout/fdtdapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,12 @@ def add_mode_expansion(self,position, mode_list, width=2, height=0.8, expansion_
self.fdtd.eval("set(\"z\",0);")
self.fdtd.eval("set(\"z span\"," + str(height) + "e-6);")
self.fdtd.eval("setexpansion(\"Output\",\""+power_monitor_name+"\");")
self.fdtd.eval("set(\"mode selection\",\"user select\");")
self.fdtd.eval("set(\"selected mode numbers\","+self.str_list(mode_list)+");")
if (type(mode_list) == str):
self.fdtd.eval("set(\"mode selection\",\""+mode_list+"\");")
else:
self.fdtd.eval("set(\"mode selection\",\"user select\");")
self.fdtd.eval("set(\"selected mode numbers\"," + self.str_list(mode_list) + ");")

if (update_mode):
self.fdtd.updatemodes()
self.fdtd.eval("set(\"override global monitor settings\",0);")
Expand Down Expand Up @@ -244,7 +248,7 @@ def reset_source_mode(self, source_name,mode_number):



def add_fdtd_region(self,bottom_left_corner_point,top_right_corner_point,simulation_time=5000,background_index=1.444,mesh_order =2,dimension=3,height = 1,z_symmetric = 0, y_antisymmetric = 0, pml_layers = 8):
def add_fdtd_region(self,bottom_left_corner_point,top_right_corner_point,simulation_time=5000,background_index=1.444,mesh_order =2,dimension=3,height = 1, z_symmetric = 0, y_antisymmetric = 0, pml_layers = 8):
"""
Add simulation region in Lumerical FDTD.
Expand Down Expand Up @@ -290,7 +294,7 @@ def add_fdtd_region(self,bottom_left_corner_point,top_right_corner_point,simulat
self.fdtd.eval("set(\"y min bc\", \"Anti-Symmetric\");")
self.fdtd.eval("set(\"force symmetric y mesh\", 1);")

def add_index_region(self, bottom_left_corner_point, top_right_corner_point, height = 1, index_monitor_name="index",dimension = 2):
def add_index_region(self, bottom_left_corner_point, top_right_corner_point, height = 1, z_min = None, z_max = None, index_monitor_name="index",dimension = 2):
"""
Add index monitor (x-y plane) in Lumerical FDTD.
Expand Down Expand Up @@ -322,7 +326,11 @@ def add_index_region(self, bottom_left_corner_point, top_right_corner_point, hei
self.fdtd.eval("set(\"monitor type\",3);")
elif (dimension == 3):
self.fdtd.eval("set(\"monitor type\",4);")
self.fdtd.eval("set(\"z span\"," + str(height) + "e-6);")
if (type(z_min) != type(None) and type(z_max) != type(None)):
self.fdtd.eval("set(\"z min\"," + str(z_min) + "e-6);")
self.fdtd.eval("set(\"z max\"," + str(z_max) + "e-6);")
else:
self.fdtd.eval("set(\"z span\"," + str(height) + "e-6);")
else:
raise Exception("Wrong dimension for index region!")
self.fdtd.eval("set(\"override global monitor settings\",1);")
Expand All @@ -331,7 +339,7 @@ def add_index_region(self, bottom_left_corner_point, top_right_corner_point, hei
self.fdtd.eval("set(\"spatial interpolation\",\"none\");")


def add_field_region(self, bottom_left_corner_point, top_right_corner_point, height = 1, field_monitor_name="field",dimension = 2):
def add_field_region(self, bottom_left_corner_point, top_right_corner_point, height = 1, z_min = None, z_max = None, field_monitor_name="field",dimension = 2):
"""
Add field monitor (x-y plane) in Lumerical FDTD (DFT Frequency monitor).
Expand All @@ -358,7 +366,11 @@ def add_field_region(self, bottom_left_corner_point, top_right_corner_point, hei
self.fdtd.eval("set(\"monitor type\",7);")
elif (dimension == 3):
self.fdtd.eval("set(\"monitor type\",8);")
self.fdtd.eval("set(\"z span\"," + str(height) + "e-6);")
if (type(z_min) != type(None) and type(z_max) != type(None)):
self.fdtd.eval("set(\"z min\"," + str(z_min) + "e-6);")
self.fdtd.eval("set(\"z max\"," + str(z_max) + "e-6);")
else:
self.fdtd.eval("set(\"z span\"," + str(height) + "e-6);")
else:
raise Exception("Wrong dimension for index region!")
self.fdtd.eval("set(\"x\"," + str(position.x) + "e-6);")
Expand All @@ -369,7 +381,7 @@ def add_field_region(self, bottom_left_corner_point, top_right_corner_point, hei
self.fdtd.eval("set(\"override global monitor settings\",0);")
self.fdtd.eval("set(\"spatial interpolation\",\"none\");")

def add_mesh_region(self,bottom_left_corner_point,top_right_corner_point,x_mesh,y_mesh,z_mesh = 0.0025,height = 1):
def add_mesh_region(self,bottom_left_corner_point,top_right_corner_point,x_mesh,y_mesh,z_mesh = 0.0025,height = 1, z_min = None, z_max = None):
"""
Reset the mesh grid in Lumerical FDTD.
Expand Down Expand Up @@ -397,7 +409,11 @@ def add_mesh_region(self,bottom_left_corner_point,top_right_corner_point,x_mesh,
self.fdtd.eval("set(\"y\"," + str(position.y) + "e-6);")
self.fdtd.eval("set(\"y span\"," + str(y_span) + "e-6);")
self.fdtd.eval("set(\"z\",0);")
self.fdtd.eval("set(\"z span\"," + str(height) + "e-6);")
if (type(z_min) != type(None) and type(z_max) != type(None)):
self.fdtd.eval("set(\"z min\"," + str(z_min) + "e-6);")
self.fdtd.eval("set(\"z max\"," + str(z_max) + "e-6);")
else:
self.fdtd.eval("set(\"z span\"," + str(height) + "e-6);")
self.fdtd.eval("set(\"dx\"," + str(x_mesh) + "e-6);")
self.fdtd.eval("set(\"dy\"," + str(y_mesh) + "e-6);")
self.fdtd.eval("set(\"dz\"," + str(z_mesh) + "e-6);")
Expand Down Expand Up @@ -449,7 +465,7 @@ def get_transmission(self,monitor_name,datafile = None):
transmission = data["T"]
spectrum = np.zeros((2,data["T"].shape[0]))
spectrum[0,:] = wavelength.flatten()
spectrum[1,:] = transmission.flatten
spectrum[1,:] = transmission.flatten()
if (datafile != None):
np.save(datafile,spectrum)
return spectrum
Expand Down
16 changes: 12 additions & 4 deletions splayout/modeapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ def get_E_distribution(self, field_monitor_name = "field", data_name = "field_da
else:
return field['E']

def add_index_region(self, bottom_left_corner_point, top_right_corner_point, height = 1, index_monitor_name="index",dimension = 2):
def add_index_region(self, bottom_left_corner_point, top_right_corner_point, height = 1, z_min = None, z_max = None, index_monitor_name="index",dimension = 2):
"""
Add index monitor (x-y plane) in Lumerical MODE.
Expand Down Expand Up @@ -923,7 +923,11 @@ def add_index_region(self, bottom_left_corner_point, top_right_corner_point, hei
self.mode.eval("set(\"monitor type\",3);")
elif (dimension == 3):
self.mode.eval("set(\"monitor type\",4);")
self.mode.eval("set(\"z span\"," + str(height) + "e-6);")
if (type(z_min) != type(None) and type(z_max) != type(None)):
self.mode.eval("set(\"z min\"," + str(z_min) + "e-6);")
self.mode.eval("set(\"z max\"," + str(z_max) + "e-6);")
else:
self.mode.eval("set(\"z span\"," + str(height) + "e-6);")
else:
raise Exception("Wrong dimension for index region!")
self.mode.eval("set(\"use wavelength spacing\",1);")
Expand All @@ -932,7 +936,7 @@ def add_index_region(self, bottom_left_corner_point, top_right_corner_point, hei
self.mode.eval("set(\"record conformal mesh when possible\",1);")
self.mode.eval("set(\"spatial interpolation\",\"none\");")

def add_field_region(self, bottom_left_corner_point, top_right_corner_point, height = 1, field_monitor_name="field",dimension = 2):
def add_field_region(self, bottom_left_corner_point, top_right_corner_point, height = 1, z_min = None, z_max = None, field_monitor_name="field",dimension = 2):
"""
Add field monitor (x-y plane) in Lumerical MODE (DFT Frequency monitor).
Expand Down Expand Up @@ -964,7 +968,11 @@ def add_field_region(self, bottom_left_corner_point, top_right_corner_point, hei
self.mode.eval("set(\"monitor type\",7);")
elif (dimension == 3):
self.mode.eval("set(\"monitor type\",8);")
self.mode.eval("set(\"z span\"," + str(height) + "e-6);")
if (type(z_min) != type(None) and type(z_max) != type(None)):
self.mode.eval("set(\"z min\"," + str(z_min) + "e-6);")
self.mode.eval("set(\"z max\"," + str(z_max) + "e-6);")
else:
self.mode.eval("set(\"z span\"," + str(height) + "e-6);")
else:
raise Exception("Wrong dimension for index region!")
self.mode.eval("set(\"override global monitor settings\",0);")
Expand Down

0 comments on commit 95f913f

Please sign in to comment.