Photonics

Photonics

Topics related to Lumerical and more.

How to input material instead of permittivity in polygon python script

    • xyjxyj1992
      Subscriber

      Hi, I am trying to specify the material of the polygon by providing the name of the material, but there is always an error popping out. But when I refer to the source code "polygon" in lumopt, it does allow us to give eps_in the name of a material. Can anyone help? Thanks!

    • Guilin Sun
      Ansys Employee
      Based on my limited knowledge on Pyhon assisted simulation, as you mentioned, it allows to have material name. However in the screenshot 3, it is this script
      float(base_epsilon) fails, as it tried to convert "Si (Silicon) - Palik" to float value. "Si (Silicon) - Palik" is string which can only be assigned to material property to an object.

    • xyjxyj1992
      Subscriber
      Thanks for your reply. But as shown in figure 2, in the script "polygon", the underlining command is to identify whether the input belongs to the material category, so it can be the material name as a string. But the script fails to do that somehow, and the users are not allowed to make any changes on either of these in-built scripts.
    • Guilin Sun
      Ansys Employee
      In Fig 2 I did not find "polygon". Polygon is the geometry. For objects in FDTD, it has geometry and material, and one can assign material to a geometry. So you should be able to assign a material using script. For example, in the Y-branch example, the script can assign material to the rectangle.
      However for lumopt, it is from 3rd party, and you will need to modify it in order to expand its functionality: https://github.com/chriskeraly/lumopt
      Welcome to LumOpt: Easy Adjoint Optimization for Lumerical ...
      you can find more information online and some tutorials.
      It is out of the scope of this forum.

    • Taylor Robertson
      Ansys Employee
      Hello
      I believe that if you refer to the y-branch example, it shows how to define a new material based on existing one through Python. See the setup script varFDTD_y_branch.py line 39-43.
      ##MATERIAL
      opt_material=mode.addmaterial('Dielectric');
      mode.setmaterial(opt_material,'name','Si:non-dispersive');
      n_opt=mode.getindex('Si(Silicon)-Palik',c/lam_c);
      mode.setmaterial('Si:non-dispersive','RefractiveIndex',n_opt);

      In the optimization script you define the device and cladding material in the Polygon class.

      #Setdeviceandcladdingmaterials,aswellasasdevicelayerthickness
      eps_in=Material(name='Si:non-dispersive',mesh_order=2)
      eps_out=Material(name='SiO2:non-dispersive',mesh_order=3)
      depth=220.0e-9

      #InitializeFunctionDefinedPolygonclass
      polygon=FunctionDefinedPolygon(func=splitter,
      initial_params=prev_results bounds=bounds z=0.0 depth=depth eps_out=eps_out,eps_in=eps_in edge_precision=5 dx=1.0e-9)

      You could pass the name of a material already defined in the base FDTD file just make sure this string is exactly the same as the name in fdtd, and that it is an instance of Material. If you just want to pass the permittivity that should be fine as well.

      eps_in = 3.4 **2
      eps_out = 1.4 **2
      I hope this helps.
    • xyjxyj1992
      Subscriber
      Hi
      Thank you so much for your reply, that really helps! Sorry it takes so long for me to see your reply.
    • Taylor Robertson
      Ansys Employee
      Hey Glad to hear. I've marked it as a solution.
      Good Luck in your optimizations
Viewing 6 reply threads
  • The topic ‘How to input material instead of permittivity in polygon python script’ is closed to new replies.