Ansys Learning Forum Forums Discuss Simulation Photonics unable to calcualte mode expansion Reply To: unable to calcualte mode expansion

Vincent Letourneau
Subscriber

@Guilin, I'm unfortunately quite unfamiliar with the rest of Lumerical. Could you give me instructions to run my simulation without the python api? The code launching the simulation is copied below.

@Lito, I am connecting to the cluster with ssh + X11 forwarding.

from lumopt.utilities.simulation import Simulation 
from lumopt.figures_of_merit.modematch import ModeMatch 

sim = Simulation('.', False, False) 
fom = ModeMatch(monitor_name = 'fom', mode_number = 'Fundamental TE mode', direction = 'Forward', norm_p = 2) 
sim.fdtd.load("./files/forward_0.fsp")
size_x = 2000
delta_x = 20
size_y = 1800
delta_y = 20
x_points = int(size_x / delta_x) + 1 
y_points = int(size_y / delta_y) + 1 
x_pos = np.linspace(-size_x / 2, size_x / 2, x_points) * 1e-9 
y_pos = np.linspace(0, size_y, y_points) * 1e-9
sim.fdtd.switchtolayout() 
sim.fdtd.putv('x_geo',x_pos) 
sim.fdtd.putv('y_geo',y_pos) 
\sim.fdtd.putv('z_geo',np.array([0-110e-9,0+110e-9])) 
sim.fdtd.putv('eps_geo',eps_for_sim) 
script=('select("import");' 
'delete;' 
'addimport;' 
'temp=zeros(length(x_geo),length(y_geo),2);' 
'temp(:,:,1)=eps_geo;' 
'temp(:,:,2)=eps_geo;' 
'importnk2(sqrt(temp),x_geo,y_geo,z_geo);') 
sim.fdtd.eval(script) 
fdtd.run() 
print(fom.get_fom(sim))