diff --git a/README.md b/README.md index 14b72b0..3bcd832 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file diff --git a/README.rst b/README.rst index 4908035..04abc57 100644 --- a/README.rst +++ b/README.rst @@ -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 diff --git a/examples/inverse design/powersplitter.py b/examples/inverse design/powersplitter.py new file mode 100644 index 0000000..139597f --- /dev/null +++ b/examples/inverse design/powersplitter.py @@ -0,0 +1,2 @@ + + diff --git a/splayout/__init__.py b/splayout/__init__.py index 04b1dee..90d2067 100644 --- a/splayout/__init__.py +++ b/splayout/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.1.6" +__version__ = "0.1.8" from splayout.AEMDgrating import MAKE_AEMD_GRATING from splayout.bend import Bend diff --git a/splayout/fdtdapi.py b/splayout/fdtdapi.py index cf2589c..dfa3502 100644 --- a/splayout/fdtdapi.py +++ b/splayout/fdtdapi.py @@ -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 ---------- @@ -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). @@ -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.