Ansys Learning Forum › Forums › Discuss Simulation › Photonics › unable to calcualte mode expansion › Reply To: unable to calcualte mode expansion
@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))