-
-
March 26, 2025 at 7:59 am
longch
SubscriberWe've written the following code to attempt the inverse design of a 2x3 MMI device using Lumopt. The goal is to achieve equal power at the three output ports when two mode light sources enter through two input ports respectively. However, we've noticed that the actual FOM curve doesn't trend towards a gradual reduction in insertion loss. Why is this the case? Could you please provide me with professional advice and assistance? Thank you!
def runSim(params, eps_bg, eps_wg, x_pos, y_pos, size_x, size_y, filter_R, working_dir, beta):
######## DEFINE GEOMETRY ########
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)
######## DEFINE FIGURE OF MERIT FOR EACH OUTPUT WAVEGUIDE ########
#fom1 = ModeMatch(monitor_name = 'fom_1', mode_number = 'Fundamental TE mode', direction = 'Forward', norm_p = 2, target_fom=1/3)
#fom2 = ModeMatch(monitor_name = 'fom_2', mode_number = 'Fundamental TE mode', direction = 'Forward', norm_p = 2, target_fom=1/3)
#fom3 = ModeMatch(monitor_name = 'fom_3', mode_number = 'Fundamental TE mode', direction = 'Forward', norm_p = 2, target_fom=1/3)
fom1 = ModeMatch(monitor_name='fom_1', mode_number='Fundamental TE mode', direction='Forward', norm_p=2, target_T_fwd=lambda wl: 1/3 * np.ones(wl.size))
fom2 = ModeMatch(monitor_name='fom_2', mode_number='Fundamental TE mode', direction='Forward', norm_p=2, target_T_fwd=lambda wl: 1/3 * np.ones(wl.size))
fom3 = ModeMatch(monitor_name='fom_3', mode_number='Fundamental TE mode', direction='Forward', norm_p=2, target_T_fwd=lambda wl: 1/3 * np.ones(wl.size))
######## DEFINE OPTIMIZATION ALGORITHM ########
optimizer1 = ScipyOptimizers(max_iter=400, method='L-BFGS-B', pgtol=1e-6, ftol=1e-5, scale_initial_gradient_to=0.25)
optimizer2 = ScipyOptimizers(max_iter=400, method='L-BFGS-B', pgtol=1e-6, ftol=1e-5, scale_initial_gradient_to=0.25)
optimizer3 = ScipyOptimizers(max_iter=400, method='L-BFGS-B', pgtol=1e-6, ftol=1e-5, scale_initial_gradient_to=0.25)
optimizer4 = ScipyOptimizers(max_iter=400, method='L-BFGS-B', pgtol=1e-6, ftol=1e-5, scale_initial_gradient_to=0.25)
optimizer5 = ScipyOptimizers(max_iter=400, method='L-BFGS-B', pgtol=1e-6, ftol=1e-5, scale_initial_gradient_to=0.25)
optimizer6 = ScipyOptimizers(max_iter=400, method='L-BFGS-B', pgtol=1e-6, ftol=1e-5, scale_initial_gradient_to=0.25)
######## DEFINE SETUP SCRIPT AND INDIVIDUAL OPTIMIZERS ########
script1 = load_from_lsf('E:/CHH/Mixer with lumopt/2x3 MMI Mixer input1 bend 6x6.lsf')
script2 = load_from_lsf('E:/CHH/Mixer with lumopt/2x3 MMI Mixer input2 bend 6x6.lsf')
# script1 = script.replace('opt_size_x=36e-6','opt_size_x={:1.6g}'.format(size_x))
# script1 = script.replace('opt_size_y=6e-6','opt_size_y={:1.6g}'.format(size_y))
wavelengths = Wavelengths(start = 1550e-9, stop = 1550e-9, points = 1)
opt1 = Optimization(base_script=script1, wavelengths = wavelengths, fom=fom1, geometry=geometry, optimizer=optimizer1,
use_deps=False, hide_fdtd_cad=True, plot_history=False, store_all_simulations=False, save_global_index=True)
opt2 = Optimization(base_script=script1, wavelengths = wavelengths, fom=fom2, geometry=geometry, optimizer=optimizer2,
use_deps=False, hide_fdtd_cad=True, plot_history=False, store_all_simulations=False, save_global_index=False)
opt3 = Optimization(base_script=script1, wavelengths = wavelengths, fom=fom3, geometry=geometry, optimizer=optimizer3,
use_deps=False, hide_fdtd_cad=True, plot_history=False, store_all_simulations=False, save_global_index=False)
opt4 = Optimization(base_script=script2, wavelengths=wavelengths, fom=fom1, geometry=geometry, optimizer=optimizer4,
use_deps=False, hide_fdtd_cad=True, plot_history=False, store_all_simulations=False, save_global_index=True)
opt5 = Optimization(base_script=script2, wavelengths=wavelengths, fom=fom2, geometry=geometry, optimizer=optimizer5,
use_deps=False, hide_fdtd_cad=True, plot_history=False, store_all_simulations=False, save_global_index=False)
opt6 = Optimization(base_script=script2, wavelengths=wavelengths, fom=fom3, geometry=geometry, optimizer=optimizer6,
use_deps=False, hide_fdtd_cad=True, plot_history=False, store_all_simulations=False, save_global_index=False)
######## PUT EVERYTHING TOGETHER AND RUN ########
weights = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
opT = [opt1, opt2, opt3, opt4, opt5, opt6]
opt = SuperOptimization(optimizations=opT,weights=weights)
opt.run(working_dir=working_dir)
if __name__ == '__main__':
size_x = 12000
size_y = 6000
filter_R = 200e-9
x_points=int(size_x/20)+1
y_points=int(size_y/20)+1
eps_wg = 2.8**2
eps_bg = 1.44**2
x_pos = np.linspace(-size_x/2*1e-9,size_x/2*1e-9,x_points)
y_pos = np.linspace(-size_y/2*1e-9,size_y/2*1e-9,y_points)
## We need to pick an initial condition. Many different options:
# params = 0.5*np.ones((x_points,y_points)) #< Start with the domain filled with (eps_wg+eps_bg)/2
#params = np.ones((x_points,y_points)) #< Start with the domain filled with eps_wg
#params = np.zeros((x_points,y_points)) #< Start with the domain filled with eps_bg
params = None #< Use the structure defined in the project file as initial condition
working_dir = '2x3_MMI_Mixer_2scripts_x{:04d}_y{:04d}_f{:04d}'.format(size_x,size_y,int(filter_R*1e9))
runSim(params, eps_bg, eps_wg, x_pos, y_pos, size_x*1e-9, size_y*1e-9, filter_R, working_dir=working_dir, beta=1)
-
March 26, 2025 at 4:25 pm
-
March 31, 2025 at 11:03 pm
George Patsamanis
Ansys EmployeeHello,
thank you for reaching out to us.
I can provide you with some overall feedback according to your target design.
When two sources with the same mode are present at the same time, the algorithm will optimize the geometry based on the initial (fixed) phases of the two sources.
You would need a total of 3 figure of merits, one for each output monitor. The “target_fom” can be 1/3 for all foms. The wavelength can be the same for all foms.
You don’t need more than one optimizers. The number of “opt” should also be three, one “opt” for each “fom”.
As the final optimizable parameter, you can have the: opt = opt1+opt2+opt3.You can use the 1×2 splitter topology optimization example as your template and make your modifications there.
Inverse Design of a Splitter Using Topology Optimization – Ansys Optics
In this case, make sure to remove the symmetry, remove the bend waveguide, add one more input and one more output, and setup the fom and opt correctly. You will also need to pay attention when setting up the XY size of the simulation, so that it is the same in both .lsf and .py files.You may need to go through some trials and errors, but when the scripts are all well set you will then have the fom trend converging as expected.
I hope this helps you with your studies.
Regards,
George -
April 1, 2025 at 10:29 am
longch
SubscriberThank you very much for your reply, Engineer George. However, I still have some remaining questions:- Code Structure Clarification
My code loads two separate scripts, each setting up one input source corresponding to 3 output monitors. The goal is to alternately optimize the device structure under two light sources during the optimization process. Therefore, there are 6 monitors and 6optentries in total in my code, not "setting two input sources in one script" as you mentioned. - Optimizer Error in v242
You mentioned that multiple optimizers are unnecessary. This worked in my previous version (v202), where one optimizer handled 3optentries. However, when I ran the identical file in v242, the simulation failed with the error shown in the figure, prompting me to use multiple optimizers. Could you explain why this error occurs and how to resolve it correctly? - Phase Interaction of Two Sources
You stated: "When two sources with the same mode are present at the same time, the algorithm will optimize the geometry based on the initial (fixed) phases of the two sources."
If I set two TE fundamental mode sources with both phases at 0° or a 90° difference in one script, what will the phases in the three output monitors look like?
-
- You must be logged in to reply to this topic.
-
5869
-
1906
-
1420
-
1306
-
1021
© 2026 Copyright ANSYS, Inc. All rights reserved.