예제 #1
0
    def test_two_parameter_maximization(self):
        optimizer = ScipyOptimizers(max_iter=200,
                                    method='L-BFGS-B',
                                    scaling_factor=1.0,
                                    pgtol=1.0e-11)
        fom = lambda params: np.sin(np.pi * params[0]) * np.sin(np.pi * params[
            1])
        jac = lambda params: np.pi * np.array([
            np.cos(np.pi * params[0]) * np.sin(np.pi * params[1]),
            np.sin(np.pi * params[0]) * np.cos(np.pi * params[1])
        ])
        start = np.array([1.0e-5, 1.0 - 1e-5])
        bounds = np.array([(self.machine_eps, 1.0 - self.machine_eps),
                           (self.machine_eps, 1.0 - self.machine_eps)])

        def plot_fun():
            pass

        optimizer.initialize(start_params=start,
                             callable_fom=fom,
                             callable_jac=jac,
                             bounds=bounds,
                             plotting_function=plot_fun)
        results = optimizer.run()
        self.assertTrue(results.success)
        self.assertAlmostEqual(results.x.size, 2)
        self.assertAlmostEqual(results.x[0], 0.5, 11)
        self.assertAlmostEqual(results.x[1], 0.5, 11)
        self.assertAlmostEqual(results.fun, 1.0, 11)
        self.assertLessEqual(results.nit, 3)
        self.assertLessEqual(results.nfev, 15)
예제 #2
0
    def test_single_parameter_maximization_with_scaling(self):
        span = 1.0e-9
        optimizer = ScipyOptimizers(max_iter=200,
                                    method='L-BFGS-B',
                                    scaling_factor=1.0 / span,
                                    pgtol=1.0e-11)
        fom = lambda param: -1.0 / np.sin(np.pi / span * param[0])
        jac = lambda param: np.pi * np.cos(np.pi / span * param[0]) / np.power(
            np.sin(np.pi / span * param[0]), 2) / span
        start = np.array(1.0e-6) * span
        bounds = np.array([(self.machine_eps, 1.0 - self.machine_eps)]) * span

        def plot_fun():
            pass

        optimizer.initialize(start_params=start,
                             callable_fom=fom,
                             callable_jac=jac,
                             bounds=bounds,
                             plotting_function=plot_fun)
        results = optimizer.run()
        self.assertTrue(results.success)
        self.assertAlmostEqual(results.x.size, 1)
        self.assertAlmostEqual(results.x[0], 0.5 * span, 11)
        self.assertAlmostEqual(results.fun, -1.0, 11)
        self.assertLessEqual(results.nit, 31)
        self.assertLessEqual(results.nfev, 46)
    def setUp(self):
        # Base simulation project files
        self.base_TE_sim = os.path.join(
            self.file_dir,
            'co_optimization_parallel_plate_waveguide_TE_base.fsp')
        self.base_TM_sim = os.path.join(
            self.file_dir,
            'co_optimization_parallel_plate_waveguide_TM_base.fsp')
        # Simulation bandwidth
        self.wavelengths = Wavelengths(start=1500e-9, stop=1600e-9, points=12)
        # Polygon defining a rectangle that can grow or shrink along the y-axis to fill the gap
        self.mesh_del = 10.0e-9
        # must be kept in sych with self.base_script
        initial_points_y = np.array(
            [1.75 * self.mesh_del, 0.01 * self.mesh_del])

        def wall(param=initial_points_y):
            assert param.size == 2, "walls defined by two points."
            self.wg_gap = 10.0 * self.mesh_del  # must be kept in sych
            points_x = 0.5 * np.array(
                [-self.wg_gap, self.wg_gap, self.wg_gap, -self.wg_gap])
            points_y = np.array([-param[0], -param[1], param[1], param[0]])
            polygon_points = [(x, y) for x, y in zip(points_x, points_y)]
            return np.array(polygon_points)

        self.wg_width = 50.0 * self.mesh_del  # must be kept in synch
        bounds = [(0.0, self.wg_width / 2.0)] * initial_points_y.size
        self.geometry = FunctionDefinedPolygon(
            func=wall,
            initial_params=initial_points_y,
            bounds=bounds,
            z=0.0,  # must be kept in sych
            depth=self.wg_width,
            eps_out=Material(base_epsilon=1.0**2,
                             name='<Object defined dielectric>',
                             mesh_order=2),  # must be kept in synch
            eps_in=Material(base_epsilon=4.0**2,
                            name='<Object defined dielectric>',
                            mesh_order=1),  # must be kept in sych
            edge_precision=50,
            dx=1.0e-10)
        # Figure of merit
        self.fom = ModeMatch(
            monitor_name='fom',  # must be kept in sych
            mode_number=1,  # must be kept in sych
            direction='Forward',
            multi_freq_src=True,
            target_T_fwd=lambda wl: np.ones(wl.size),
            norm_p=1)
        # Scipy optimizer
        self.optimizer = ScipyOptimizers(max_iter=5,
                                         method='L-BFGS-B',
                                         scaling_factor=1.0e7,
                                         pgtol=1.0e-5,
                                         ftol=1.0e-12,
                                         target_fom=0.0,
                                         scale_initial_gradient_to=None)
def runSim(params,
           eps_bg,
           eps_wg,
           x_pos,
           y_pos,
           size_x,
           filter_R,
           beta_start=1):

    ######## DEFINE A 2D TOPOLOGY OPTIMIZATION REGION ########
    geometry = TopologyOptimization2D(params=params,
                                      eps_min=eps_bg,
                                      eps_max=eps_wg,
                                      x=x_pos,
                                      y=y_pos,
                                      z=0,
                                      filter_R=filter_R,
                                      beta=beta_start)

    ######## DEFINE FIGURE OF MERIT ########
    # The base simulation script defines a field monitor named 'fom' at the point where we want to modematch to the fundamental TE mode
    fom = ModeMatch(monitor_name='fom',
                    mode_number='Fundamental TE mode',
                    direction='Forward',
                    norm_p=2)

    ######## DEFINE OPTIMIZATION ALGORITHM ########
    optimizer = ScipyOptimizers(max_iter=50,
                                method='L-BFGS-B',
                                scaling_factor=1,
                                pgtol=1e-6,
                                ftol=1e-4,
                                target_fom=0.5,
                                scale_initial_gradient_to=0.25)

    ######## LOAD TEMPLATE SCRIPT AND SUBSTITUTE PARAMETERS ########
    script = load_from_lsf(
        os.path.join(CONFIG['root'],
                     'examples/Ysplitter/splitter_base_2D_TE_topology.lsf'))
    script = script.replace('opt_size_x=3.5e-6',
                            'opt_size_x={:1.6g}'.format(size_x))

    wavelengths = Wavelengths(start=1450e-9, stop=1650e-9, points=11)
    opt = Optimization(base_script=script,
                       wavelengths=wavelengths,
                       fom=fom,
                       geometry=geometry,
                       optimizer=optimizer,
                       use_deps=False,
                       hide_fdtd_cad=True,
                       plot_history=False,
                       store_all_simulations=False)

    ######## RUN THE OPTIMIZER ########
    opt.run()
예제 #5
0
 def setUp(self):
     # Base simulation script
     self.base_script = load_from_lsf(os.path.join(self.file_dir, 'optimization_waveguide_filter_TM_2D_base.lsf'))
     # Simulation bandwidth
     self.wavelengths = Wavelengths(start = 1300e-9,
                                    stop = 1800e-9,
                                    points = 41)
     # Polygons to form the two gaps
     self.mesh_del = 20.0e-9; # must be kept in sych with self.base_script
     initial_param = 10.0 * np.array([self.mesh_del])
     def rectangle(param = initial_param, offset = 0.0):
         assert param.size == 1, "rectangle grows along a single dimension."
         wg_width = 35.0 * self.mesh_del # must be kept in synch
         points_x = 0.5 * np.array([-wg_width,  wg_width, wg_width, -wg_width])
         points_y = 0.5 * np.array([-param, -param, param,  param]) + offset
         polygon_points = [(x, y) for x, y in zip(points_x, points_y)]
         return np.array(polygon_points)
     bounds = [(self.mesh_del, 20.0 * self.mesh_del)]
     z = 0.0 # must be kept in sych
     depth = 200.0 * self.mesh_del # must be kept in sych
     eps_in = Material(base_epsilon = 1.44 ** 2, mesh_order = 1) # must be kept in sych with
     eps_out = Material(base_epsilon = 2.8 ** 2, mesh_order = 1) # must be kept in sych with
     edge_precision = 25
     dx = 1.0e-10
     self.geometry = (FunctionDefinedPolygon(func = lambda param: rectangle(param[0], 2.0 * param[0]), initial_params = initial_param, bounds = bounds, z = z, depth = depth, eps_out = eps_out, eps_in = eps_in, edge_precision = edge_precision, dx = dx) *
                      FunctionDefinedPolygon(func = lambda param: rectangle(param[0],-2.0 * param[0]), initial_params = initial_param, bounds = bounds, z = z, depth = depth, eps_out = eps_out, eps_in = eps_in, edge_precision = edge_precision, dx = dx))
     # Broadband figure of merit
     target_T_fwd = lambda wl: 0.3 + 0.65*np.power(np.sin(np.pi * (wl - wl.min()) / (wl.max() - wl.min())), 6)
     self.fom = ModeMatch(monitor_name = 'FOM', # must be kept in sych
                          mode_number = 1, # must be kept in sych
                          direction = 'Backward',
                          multi_freq_src = True,
                          target_T_fwd = target_T_fwd,
                          norm_p = 1)
     # Scipy optimzier
     self.optimizer = ScipyOptimizers(max_iter = 10, 
                                      method = 'L-BFGS-B',
                                      scaling_factor = 1.0e7,
                                      pgtol = 5.6e-3)
예제 #6
0
    def __init__(self, max_iter, method, scaling_factor, pgtol, ftol,
                 wavelength_start, wavelength_stop, wavelength_points,
                 build_simulation, fom, geometry, hide_fdtd_cad):

        # The optimizer must be generated anew at each iteration
        self._new_local_optimizer = ScipyOptimizers(
            max_iter=max_iter,
            method=method,
            scaling_factor=scaling_factor,
            ftol=ftol,
            pgtol=pgtol)

        self._wl = Wavelengths(start=wavelength_start,
                               stop=wavelength_stop,
                               points=wavelength_points)

        self._optimization = Optimization(base_script=build_simulation,
                                          wavelengths=self._wl,
                                          fom=fom,
                                          geometry=geometry,
                                          optimizer=self._new_local_optimizer,
                                          hide_fdtd_cad=hide_fdtd_cad,
                                          use_deps=True)
예제 #7
0
                                  depth=wg_height,
                                  eps_out=1.0**2,
                                  eps_in=3.47668**2,
                                  edge_precision=5,
                                  dx=1.0e-5)

######## DEFINE FIGURE OF MERIT ########
fom = ModeMatch(monitor_name='fom',
                mode_number=3,
                direction='Backward',
                target_T_fwd=lambda wl: 0.5 * np.ones(wl.size),
                norm_p=1)

######## DEFINE OPTIMIZATION ALGORITHM ########
optimizer = ScipyOptimizers(max_iter=200,
                            method='L-BFGS-B',
                            scaling_factor=1.0,
                            pgtol=1.0e-4)

######## PUT EVERYTHING TOGETHER ########
opt = Optimization(base_script=base_sim,
                   wavelengths=wavelengths,
                   fom=fom,
                   geometry=geometry,
                   optimizer=optimizer,
                   hide_fdtd_cad=False,
                   use_deps=True)

######## RUN THE OPTIMIZER ########
opt.run()
예제 #8
0
                                    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)

######## DEFINE OPTIMIZATION ALGORITHM ########
optimizer = ScipyOptimizers(max_iter=20, method='L-BFGS-B', scaling_factor=1e6)
# This will run Scipy's implementation of the L-BFGS-B algoithm for at least 40 iterations. Since the variables are on the
# order of 1e-6, we scale them up to be on the order of 1

######## PUT EVERYTHING TOGETHER ########
opt = Optimization(base_script=script,
                   fom=fom,
                   geometry=geometry,
                   optimizer=optimizer)

######## RUN THE OPTIMIZER ########
opt.run()
예제 #9
0
def runGratingOptimization(bandwidth_in_nm, etch_depth_shallow, etch_depth_deep, n_grates, initial_params = None):
    ### Yet another parametrization which allows to enforce minimum feature size when the optimizer only supports box constraints  
    ### params = [x0, a1, b1, ..., aN]
    if initial_params is None:
        params = np.zeros(4*n_grates)

        for i in range(n_grates):
            params[i*4]   = 0.2     #< Width up
            params[i*4+1] = 0.4*(i/n_grates)     #< Width of the shallow etch
            params[i*4+2] = 0.1    #< Width up
            params[i*4+3] = 0.4*(i/n_grates)     #< Width of the deep etch

        params[0] = 0      #< Overwrite the first since it has a special meaning: Start of the grating at 0um
    else:
        params = initial_params

    bounds = [(0, 1)]*(4*n_grates)  
    bounds[0] = (-3,3)

    def grating_params_pos(params, output_waveguide_length = 0.5e-6, height = 220e-9, y0 = 0):
        x_begin = -3e-6

        y3 = y0+height
        y2 = y3-etch_depth_deep
        y1 = y3-etch_depth_shallow

        x0 = params[0]*1e-6     #< First parameter is the starting position
        verts = np.array( [ [x_begin,y0],[x_begin,y3],[x0,y3],[x0,y1] ] )
        
        ## Iterate over all but the last
        for i in range(n_grates-1):
            x1 = x0 + params[i*4+1]*1e-6    #< Width of the deep etch
            x2 = x1 + params[i*4+2]*1e-6    #< Width up
            x3 = x2 + params[i*4+3]*1e-6    #< Width of the shallow etch
            x4 = x3 + params[i*4+4]*1e-6    #< Width up
            verts = np.concatenate((verts,[[x1,y1],[x1,y3],[x2,y3],[x2,y2],[x3,y2],[x3,y3],[x4,y3],[x4,y1]]),axis=0)
            x0 = x4

        x1 = x0 + params[(n_grates-1)*4+1]*1e-6    #< Width of the deep etch
        x2 = x1 + params[(n_grates-1)*4+2]*1e-6    #< Width up
        x3 = x2 + params[(n_grates-1)*4+3]*1e-6    #< Width of the shallow etch
        x_end   = x3+output_waveguide_length
        verts = np.concatenate((verts,[[x1,y1],[x1,y3],[x2,y3],[x2,y2],[x3,y2],[x3,y3],[x_end,y3],[x_end,y0]]),axis=0) 

        return verts

    geometry = FunctionDefinedPolygon(func = grating_params_pos, initial_params = params, bounds = bounds, z = 0.0, depth = 220e-9, eps_out = 1.44 ** 2, eps_in = 3.47668 ** 2, edge_precision = 5, dx = 1e-3)

    ######## DEFINE FIGURE OF MERIT ########
    fom = ModeMatch(monitor_name = 'fom', mode_number = 1, direction = 'Backward', target_T_fwd = lambda wl: np.ones(wl.size), norm_p = 1)

    ######## DEFINE OPTIMIZATION ALGORITHM ########
    optimizer = ScipyOptimizers(max_iter = 250, method = 'L-BFGS-B', scaling_factor = 1, pgtol = 1e-6) #SLSQP

    ######## DEFINE BASE SIMULATION ########
    base_script = load_from_lsf(os.path.join(os.path.dirname(__file__), 'grating_coupler_2D_2etch.lsf'))

    ######## PUT EVERYTHING TOGETHER ########
    lambda_start = 1550 - bandwidth_in_nm/2
    lambda_end   = 1550 + bandwidth_in_nm/2
    lambda_pts   = int(bandwidth_in_nm/10)+1
    wavelengths = Wavelengths(start = lambda_start*1e-9, stop = lambda_end*1e-9, points = lambda_pts)
    opt = Optimization(base_script = base_script, wavelengths = wavelengths, fom = fom, geometry = geometry, optimizer = optimizer, hide_fdtd_cad = True, use_deps = True)

    ######## RUN THE OPTIMIZER ########
    opt.run()
예제 #10
0
                                  dx=0.01e-9)

######## DEFINE FIGURE OF MERIT ########
# The base simulation script defines a field monitor named 'fom' at the point where we want to modematch to the 3rd mode (fundamental TE mode).
fom = ModeMatch(monitor_name='fom',
                mode_number=2,
                direction='Forward',
                multi_freq_src=False,
                target_T_fwd=lambda wl: np.ones(wl.size),
                norm_p=1)

######## DEFINE OPTIMIZATION ALGORITHM ########
# This will run Scipy's implementation of the L-BFGS-B algoithm for at least 40 iterations. Since the variables are on the
# order of 1e-6, thery are scale up to be on the order of 1.
optimizer = ScipyOptimizers(max_iter=500,
                            method='L-BFGS-B',
                            scaling_factor=1e6,
                            pgtol=1e-9)

######## PUT EVERYTHING TOGETHER ########
opt = Optimization(base_script=base_script,
                   wavelengths=wavelengths,
                   fom=fom,
                   geometry=geometry,
                   optimizer=optimizer,
                   hide_fdtd_cad=False,
                   use_deps=True)

######## RUN THE OPTIMIZER ########
opt.run()
예제 #11
0
def runGratingOptimization(bandwidth_in_nm, etch_depth, n_grates, params):

    bounds = [(0.1, 1)] * 4
    bounds[0] = (-3, 3)  #< Starting position
    bounds[1] = (0, 0.1)  #< Scaling parameter R
    bounds[2] = (1.5, 3)  #< Parameter a
    bounds[3] = (0, 2)  #< Parameter b

    def grating_params_pos(params,
                           output_waveguide_length=0.5e-6,
                           height=220e-9,
                           y0=0):
        x_begin = -3e-6
        y3 = y0 + height
        y1 = y3 - etch_depth

        x_start = params[0] * 1e-6  #< First parameter is the starting position
        x0 = x_start
        R = params[1] * 1e6  #< second parameter (unit is 1/um)
        a = params[2]  #< Third parameter (dim-less)
        b = params[3]  #< Fourth parameter (dim-less)

        verts = np.array([[x_begin, y0], [x_begin, y3], [x0, y3], [x0, y1]])

        lambda_c = 1.55e-6
        F0 = 0.95

        ## Iterate over all but the last
        for i in range(n_grates - 1):
            F = F0 - R * (x0 - x_start)
            Lambda = lambda_c / (a + F * b)
            x1 = x0 + (1 - F) * Lambda  #< Width of the etched region
            x2 = x0 + Lambda  #< Rest of cell
            verts = np.concatenate(
                (verts, [[x1, y1], [x1, y3], [x2, y3], [x2, y1]]), axis=0)
            x0 = x2

        F = F0 - R * (x0 - x_start)
        Lambda = lambda_c / (a + F * b)
        x1 = x0 + (1 - F) * Lambda  #< Width of the etched region
        x_end = x1 + output_waveguide_length
        verts = np.concatenate(
            (verts, [[x1, y1], [x1, y3], [x_end, y3], [x_end, y0]]), axis=0)

        return verts

    geometry = FunctionDefinedPolygon(func=grating_params_pos,
                                      initial_params=params,
                                      bounds=bounds,
                                      z=0.0,
                                      depth=110e-9,
                                      eps_out=1.44**2,
                                      eps_in=3.47668**2,
                                      edge_precision=5,
                                      dx=1e-3)

    ######## DEFINE FIGURE OF MERIT ########
    fom = ModeMatch(monitor_name='fom',
                    mode_number=1,
                    direction='Backward',
                    target_T_fwd=lambda wl: np.ones(wl.size),
                    norm_p=1)

    ######## DEFINE OPTIMIZATION ALGORITHM ########
    optimizer = ScipyOptimizers(max_iter=25,
                                method='L-BFGS-B',
                                scaling_factor=1,
                                pgtol=1e-6)

    ######## DEFINE BASE SIMULATION ########
    base_script = load_from_lsf(
        os.path.join(os.path.dirname(__file__),
                     'grating_coupler_2D_2etch.lsf'))

    ######## PUT EVERYTHING TOGETHER ########
    lambda_start = 1550 - bandwidth_in_nm / 2
    lambda_end = 1550 + bandwidth_in_nm / 2
    lambda_pts = int(bandwidth_in_nm / 10) + 1
    wavelengths = Wavelengths(start=lambda_start * 1e-9,
                              stop=lambda_end * 1e-9,
                              points=lambda_pts)
    opt = Optimization(base_script=base_script,
                       wavelengths=wavelengths,
                       fom=fom,
                       geometry=geometry,
                       optimizer=optimizer,
                       hide_fdtd_cad=True,
                       use_deps=True)

    ######## RUN THE OPTIMIZER ########
    opt.run()
예제 #12
0
if __name__ == '__main__':
    import numpy as np
    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)
예제 #13
0
    interpolator = sp.interpolate.interp1d(points_x, points_y, kind='cubic')
    polygon_points_y = [max(min(point,1e-6),-1e-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) 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

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 = FunctionDefinedPolygon(func = taper_splitter_1, initial_params = initial_params, bounds = bounds, z = 0.0, depth = 220e-9, eps_out = 1.44 ** 2, eps_in = 2.8 ** 2, edge_precision = 5, dx = 0.1e-9)
geometry_2 = FunctionDefinedPolygon(func = taper_splitter_2, initial_params = initial_params, bounds = bounds, z = 0.0, depth = 220e-9, eps_out = 1.44 ** 2, eps_in = 2.8 ** 2, edge_precision = 5, dx = 0.1e-9)

######## DEFINE FIGURE OF MERIT ########
# Although we are optimizing for the same thing, two separate fom objects must be create
fom_1 = ModeMatch(monitor_name = 'fom', mode_number = 3, direction = 'Forward')
fom_2 = ModeMatch(monitor_name = 'fom', mode_number = 3, direction = 'Forward')

######## DEFINE OPTIMIZATION ALGORITHM ########
#For the optimizer, they should all be set the same, but different objects. Eventually this will be improved
optimizer_1 = ScipyOptimizers(max_iter = 40)
optimizer_2 = ScipyOptimizers(max_iter = 40)

######## PUT EVERYTHING TOGETHER ########
opt_1 = Optimization(base_script = script_1, wavelengths = wavelengths, fom = fom_1, geometry = geometry_1, optimizer = optimizer_1)
opt_2 = Optimization(base_script = script_2, wavelengths = wavelengths, fom = fom_2, geometry = geometry_2, optimizer = optimizer_2)
opt = opt_1 + opt_2

######## RUN THE OPTIMIZER ########
opt.run()
예제 #14
0
#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)
optimizer_1310=ScipyOptimizers(max_iter=40)

######## PUT EVERYTHING TOGETHER ########
opt_1550=Optimization(base_script=script_1550,fom=fom_1550,geometry=geometry_1550,optimizer=optimizer_1550)
opt_1310=Optimization(base_script=script_1310,fom=fom_1310,geometry=geometry_1310,optimizer=optimizer_1310)

opt=opt_1550+opt_1310

######## RUN THE OPTIMIZER ########
opt.run()
예제 #15
0
fom_1550 = ModeMatch(monitor_name='fom_1550',
                     mode_number=2,
                     direction='Forward',
                     target_T_fwd=lambda wl: np.ones(wl.size),
                     norm_p=1)
fom_1310 = ModeMatch(monitor_name='fom_1310',
                     mode_number=2,
                     direction='Forward',
                     target_T_fwd=lambda wl: np.ones(wl.size),
                     norm_p=1)

######## 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,
                                 method='L-BFGS-B',
                                 scaling_factor=1e6,
                                 pgtol=1e-9)
optimizer_1310 = ScipyOptimizers(max_iter=40,
                                 method='L-BFGS-B',
                                 scaling_factor=1e6,
                                 pgtol=1e-9)

######## PUT EVERYTHING TOGETHER ########
opt_1550 = Optimization(base_script=script_1550,
                        wavelengths=wavelengths_1551,
                        fom=fom_1550,
                        geometry=geometry_1550,
                        optimizer=optimizer_1550,
                        hide_fdtd_cad=False,
                        use_deps=True)
opt_1310 = Optimization(base_script=script_1310,