for x, y in zip(polygon_points_x, polygon_points_y)] polygon_points = np.array(polygon_points_up[::-1] + polygon_points_down) return polygon_points # The geometry will pass on the bounds and initial parameters to the optimizer bounds = [(0.2e-6, 1e-6)] * 10 initial_params = np.array([ 0.24481602, 0.26607235, 0.26211813, 0.43546523, 0.65633663, 0.65340398, 0.68939602, 0.62139496, 0.66486771, 0.58121573 ]) * 1e-6 geometry = function_defined_Polygon(func=taper_splitter, initial_params=initial_params, eps_out=1.44**2, eps_in='Si (Silicon) - Palik', bounds=bounds, depth=220e-9, edge_precision=5) # We must define the permittivities of the material making the optimizable # geometry and of that surrounding it. Since this is a 2D simulation, the depth has no importance. # edge_precision defines the discretization of the edges forming the optimizable polygon. It should be set such # that there are at least a few points per mesh cell. An effective index of 2.8 is user to simulate a 2D slab of # 220 nm thick ######## DEFINE FIGURE OF MERIT ######## fom = ModeMatch(modeorder=1, monitor_name='fom', wavelength=1550e-9) # The base simulation script defines a field monitor named 'fom' at the point where we want to # modematch to the 3rd order mode (fundamental TE mode)
from lumopt.geometries.polygon import function_defined_Polygon, cross from lumopt.optimizers.generic_optimizers import ScipyOptimizers from lumopt.figures_of_merit.modematch import ModeMatch from lumopt.utilities.load_lumerical_scripts import load_from_lsf import os import matplotlib.pyplot as plt from lumopt import CONFIG base_script = load_from_lsf( os.path.join(CONFIG['root'], 'examples/crossing/crossing_base_TE_modematch_2D.lsf')) fom = ModeMatch(modeorder=2) optimizer = ScipyOptimizers(max_iter=20) # optimizer=FixedStepGradientDescent(max_dx=20e-9,max_iter=100) bounds = [(0.2e-6, 1e-6)] * 10 geometry = function_defined_Polygon(func=cross, initial_params=np.linspace( 0.25e-6, 0.6e-6, 10), eps_out='SiO2 (Glass) - Palik', eps_in=2.8**2, bounds=bounds, depth=220e-9, edge_precision=5) opt = Optimization(base_script=base_script, fom=fom, geometry=geometry, optimizer=optimizer) opt.run()
initial_positions = 550e-9 * np.arange(n_grates) + 300e-9 initial_widths = 100e-9 * np.ones(n_grates) edge_precision = 20 # The geometry will pass on the bounds and initial parameters to the optimizer bounds = [(250e-9, 15e-6)] * n_grates + [(100e-9, 500e-9)] * n_grates initial_params = np.concatenate((initial_positions, initial_widths)) oxide = Material(material=1.44**2, mesh_order=1) silicon = Material(material=3.4**2) #default material is Silicon first_tooth = function_defined_Polygon(func=grate_function_generator(0), initial_params=initial_params, eps_out=silicon, eps_in=oxide, bounds=bounds, depth=1e-6, edge_precision=edge_precision) full_geometry = first_tooth for i in range(1, n_grates): new_tooth = function_defined_Polygon(func=grate_function_generator(i), initial_params=initial_params, eps_out=silicon, eps_in=oxide, bounds=bounds, depth=1e-6, edge_precision=edge_precision) full_geometry = full_geometry * new_tooth
from lumopt.utilities.materials import Material from lumopt import CONFIG import scipy ######## DEFINE BASE SIMULATION ######## script = load_from_lsf( os.path.join(CONFIG['root'], 'examples/crossing/crossing_base_TE_modematch_2D.lsf')) ######## DEFINE OPTIMIZABLE GEOMETRY ######## bounds = [(0.2e-6, 1e-6)] * 10 geometry = function_defined_Polygon(func=cross, initial_params=np.linspace( 0.25e-6, 0.6e-6, 10), eps_out=Material(1.44**2), eps_in=Material(2.8**2, 2), bounds=bounds, depth=220e-9, edge_precision=5) ######## DEFINE FIGURE OF MERIT ######## fom = ModeMatch(modeorder=2) ######## DEFINE OPTIMIZATION ALGORITHM ######## optimizer = ScipyOptimizers(max_iter=20) ######## PUT EVERYTHING TOGETHER ######## opt = Optimization(base_script=script, fom=fom, geometry=geometry,
n_interpolation_points=100 polygon_points_x = np.linspace(min(points_x), max(points_x), n_interpolation_points) interpolator = scipy.interpolate.interp1d(points_x, points_y, kind='cubic') polygon_points_y = [max(min(point,separation/2+0.5e-6),-0e-6) for point in interpolator(polygon_points_x)] polygon_points_up = [(x, y) for x, y in zip(polygon_points_x, polygon_points_y)] polygon_points_down = [(x, y+0.5e-6) for x, y in zip(polygon_points_x, polygon_points_y)] polygon_points = np.array(polygon_points_up + polygon_points_down[::-1]) return polygon_points bounds = [(-0.25e-6, 0.25e-6)]*10 #final value from splitter_opt_2D.py optimization initial_params=np.linspace(0,0.24e-6,10) #initial_params=np.linspace(-0.25e-6,0.25e-6,10) geometry_1550_lower = function_defined_Polygon(func=lower_coupler_arm,initial_params=initial_params,eps_out=1.44 ** 2, eps_in=2.8 ** 2,bounds=bounds,depth=220e-9,edge_precision=5) geometry_1550_upper = function_defined_Polygon(func=upper_coupler_arm,initial_params=initial_params,eps_out=1.44 ** 2, eps_in=2.8 ** 2,bounds=bounds,depth=220e-9,edge_precision=5) geometry_1550=geometry_1550_lower*geometry_1550_upper geometry_1310_lower = function_defined_Polygon(func=lower_coupler_arm,initial_params=initial_params,eps_out=1.44 ** 2, eps_in=2.8 ** 2,bounds=bounds,depth=220e-9,edge_precision=5) geometry_1310_upper = function_defined_Polygon(func=upper_coupler_arm,initial_params=initial_params,eps_out=1.44 ** 2, eps_in=2.8 ** 2,bounds=bounds,depth=220e-9,edge_precision=5) geometry_1310=geometry_1310_lower*geometry_1310_upper ######## DEFINE FIGURE OF MERIT ######## # Although we are optimizing for the same thing, two separate fom objects must be create fom_1550=ModeMatch(modeorder=2,wavelength=1550e-9,monitor_name='fom_1550') fom_1310=ModeMatch(modeorder=2,wavelength=1310e-9,monitor_name='fom_1310') ######## DEFINE OPTIMIZATION ALGORITHM ######## #For the optimizer, they should all be set the same, but different objects. Eventually this will be improved optimizer_1550=ScipyOptimizers(max_iter=40)
return polygon_points bounds = [(0.2e-6, 1e-6)] * 10 #final value from splitter_opt_2D.py optimization initial_params = np.array([ 2.44788514e-07, 2.65915795e-07, 2.68748023e-07, 4.42233947e-07, 6.61232152e-07, 6.47561406e-07, 6.91473099e-07, 6.17511522e-07, 6.70669074e-07, 5.86141086e-07 ]) geometry_1 = function_defined_Polygon(func=taper_splitter_1, initial_params=initial_params, eps_out=1.44**2, eps_in=2.8**2, bounds=bounds, depth=220e-9, edge_precision=5) geometry_2 = function_defined_Polygon(func=taper_splitter_2, initial_params=initial_params, eps_out=1.44**2, eps_in=2.8**2, bounds=bounds, depth=220e-9, edge_precision=5) ######## DEFINE FIGURE OF MERIT ######## # Although we are optimizing for the same thing, two separate fom objects must be create fom_1 = ModeMatch(modeorder=3)