Photonics

Photonics

Topics related to Lumerical and more.

unable to calcualte mode expansion

    • Vincent Letourneau
      Subscriber
      Hi, I'm getting this error, can you help identify its cause? I get it if running from a computer cluster but not on my local machine where it returns the correct values without problem.
       
      │ERROR:root:unable to calcualte mode expansion.
      │Traceback (most recent call last):
      │  File "/home/mila/l/letournv/repos/nanophoto/lumerical.py", line 87, in FDTD_FOM_computations
      │    foms.append(fom.get_fom(sim))
      │  File "/home/mila/l/letournv/opt/lumerical/v241/api/python/lumopt/figures_of_merit/modematch.py", line 2
      │07, in get_fom
      │    trans_coeff, self.wavelengths = ModeMatch.get_transmission_coefficient(sim, self.direction, self.moni
      │tor_name, self.mode_expansion_monitor_name)
      │  File "/home/mila/l/letournv/opt/lumerical/v241/api/python/lumopt/figures_of_merit/modematch.py", line 2
      │34, in get_transmission_coefficient
      │    raise UserWarning('unable to calcualte mode expansion.')
      │UserWarning: unable to calcualte mode expansion.
       
       
    • Guilin Sun
      Ansys Employee

      It is difficult to give solutions based on the error message from Python. Maybe it is due to the difference of opration system? what OS you are using? what kind of device is this? does the mode expansion work directly from the file wihtout using python? I would suggest that you use a simple straight waveguide with ports, first do direct simulation, then use Python script.   we need to isolate the possible issues.

    • Lito
      Ansys Employee

      @Vincent, 

      From your message, 

      I get it if running from a computer cluster but not on my local machine where it returns the correct values without problem.

      How are you running the Python/API script (requires a GUI connection) on the cluster? Are you connecting to the cluster with a GUI/desktop connection like VNC, OpenText ETX, X11 forwarding, etc?  

    • 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))

    • Guilin Sun
      Ansys Employee

      Before "fdtd.run() "

      you should be able to see the FDTD file, and save it to a fsp file on you local machine. Then directly run it on your local computer, and then move to the cluster and run it. If the cluster has GUI you can open and run the file. If not, please refer to this link: https://optics.ansys.com/hc/en-us/articles/360024974033-Running-simulations-using-terminal-on-Linux 

      You can also use one of the online examples with port objects, such as this one  https://api.lumerical.com/app-gallery/fetch-download-web?id=c118296f-waveguide-crossing 

      run the example file on the cluster and try to get the result. See what happens.

    • Vincent Letourneau
      Subscriber

      So far I am able to open fdtd with a specific simulation file

      $ /opt/lumerical/v241/bin/fdtd-solutions simulationfile.fsp
      but I dont understand how to run the simulation from the CLI.
    • Vincent Letourneau
      Subscriber

      Ok I think I got it. If I run

      fdtd-engine -log-stdout forward_0.fsp
      I get 
      fdtd-engine: error while loading shared libraries: libglut.so.3: cannot open shared object file: No such file or directory                                           
      this library is definitely installed. Can you tell me where it should be located for lumerical to find it? freeglut was installed with conda and I have created a symbolic link /opt/lumerical/v241/lib/intoconda to the conda env library dir that contains the libglut.so.3 file. Is that a good solution?

    • Vincent Letourneau
      Subscriber

      I have also just tried to create a symbolic link to libglut.so.3 directly into /opt/lumerical/v241/lib/ but get the same error message "error while loading shared libraries: libglut.so.3"

    • Lito
      Ansys Employee

      @Vincent Letourneau,

      Can you open ‘fdtd-solutions’ directly from the terminal on the cluster? 

      /opt/lumerical/v241/bin/fdtd-solutions &

      If so, then you can run the python script from the GUI. Try running the sample script that is shown in the image below. 

      You can run the simulationfile.fsp directly from the terminal.

      e.g. run with 32 threads on the machine (-t 32)
      /opt/lumerical/v241/bin/fdtd-engine -t 32  simulationfile.fsp

      See this KB for more information >>Running simulations using terminal on Linux – Ansys Optics 

    • Vincent Letourneau
      Subscriber

      I do not have access to a graphical interface. If I run 

      /opt/lumerical/v241/bin/fdtd-engine forward_0.fsp

      I get

      /opt/lumerical/v241/bin/fdtd-engine: error while loading shared libraries: libglut.so.3: cannot open shared object file: No such file or directory                                           

    • Vincent Letourneau
      Subscriber

      Hi, are there other tests i can do to identify the bug? Do you guys know ho to fix that libglut.so.3 error that was returned both from the python api call and the direct fdtd-engine call?

    • Lito
      Ansys Employee

      Running Lumerical script or Python API scripts will always require a GUI/Desktop connection to the Linux machine. GUI/CAD related computations cannot be done without a GUI connection/interface. You can only run the simulationfile.fsp directly from the terminal/command line in Linux.

      The error indicates that you are missing the library, ‘libglut.so.3’ — required by Lumerical on Linux systems. Please install the required libraries/packages for your system. 

      See this KB for a complete list of the required packages for your Linux distribution. >> Required libraries for Ansys Lumerical on Linux – Ansys Optics 

    • Vincent Letourneau
      Subscriber

      I know Lumerical "thinks" Im missing the package but its really installed in my conda env directory. Im asking for help about how to make Lumerical see it correctly. I made a symbolic link in /opt/lumerical/v241/lib/ to the conda directory containing the library libglut.so.3 but that does not seem to be enough. I cannot install stuff directly with "sudo apt install ..." because this is an installation on a computer cluster and can only install stuff through conda.

    • Vincent Letourneau
      Subscriber

      Hi, I seem to have fixed the libglut.so.3 problem with patchelf. Now if I call

      fdtd-engine forward.fsp

      I get 

      Messages file /ansys_inc/shared_files/licensing/language/en-us/ansysli_msgs.xml does not exist.
      0.224167% complete. Elapsed simulation time: 2.24167e-15 secs. Max time remaining: 6 secs. Auto Shutoff: 1
      2.31639% complete. Elapsed simulation time: 2.31639e-14 secs. Max time remaining: 6 secs. Auto Shutoff: 1
      4.7075% complete. Elapsed simulation time: 4.7075e-14 secs. Max time remaining: 6 secs. Auto Shutoff: 1
      9.48972% complete. Elapsed simulation time: 9.48972e-14 secs. Max time remaining: 6 secs. Auto Shutoff: 0.0011975
      19.0542% complete. Elapsed simulation time: 1.90542e-13 secs. Max time remaining: 5 secs. Auto Shutoff: 2.17561e-07

      So Lumerical seems to be working fine directly from the terminal (with the exception of the missing message file), but im still getting errors when using the python API. If run my script I get
      CONFIGURATION FILE {'root': '/home/mila/l/letournv/opt/lumerical/v241/api/python', 'lumapi': '/home/mila/l/letournv/opt/lumerical/v241/api/python'}
      Traceback (most recent call last):
        File "/home/mila/l/letournv/repos/nanophoto/lumtest.py", line 42, in
          print(fom.get_fom(sim))
        File "/home/mila/l/letournv/opt/lumerical/v241/api/python/lumopt/figures_of_merit/modematch.py", line 207, in get_fom
          trans_coeff, self.wavelengths = ModeMatch.get_transmission_coefficient(sim, self.direction, self.monitor_name, self.mode_expansion_monitor_name)
        File "/home/mila/l/letournv/opt/lumerical/v241/api/python/lumopt/figures_of_merit/modematch.py", line 234, in get_transmission_coefficient
          raise UserWarning('unable to calcualte mode expansion.')
      UserWarning: unable to calcualte mode expansion.

      Any help on this would be appreciated

    • Lito
      Ansys Employee

      @Vincent Letourneau, 

      We shall continue with your support case via email. I will be closing this post for now. 

Viewing 14 reply threads
  • The topic ‘unable to calcualte mode expansion’ is closed to new replies.