Photonics

Photonics

Using ‘addplanarsolid()’ with Python

    • martinmi
      Subscriber

      Hallo all, i ihave a problem when i try to use the addplanarsolid() function in python. I first create vtx and an cell array a like:

      vtx = np.array([[0,0,0], [1e-6,0,0], [1e-6,1e-6,0], [0,1e-6,0], [0,0,1e-6], [1e-6,0,1e-6], [1e-6,1e-6,1e-6], [0,1e-6,1e-6]]) 

      a =  np.array([[1,4,3,2], [1,2,6,5], [2,3,7,6], [3,4,8,7], [1,5,8,4], [5,6,7,8]])

      addplanarsolid()
      set('vertices',vtx)
      set('facets',a)

       

      The result that i am getting is:

       

      I saw that some other users have the same problem, so if any Admin know how to resolve the problem, 

      please post an example code. 

       

      I tested the same structure with ,lsf script and it was working perfectly. The Problem is when i try to add addplanarsolid with Python. 

       

      Best regards, 

      Martin 

    • Taylor Robertson
      Ansys Employee

      Hello Martin,

      It seems to me that the list of facets would be problem. This should be a list of np.arrays, with each entry correnponding to a single facet. Not an NP array of the facets.

      https://optics.ansys.com/hc/en-us/articles/360034901573-Planar-solid-Simulation-Object

      The following are methods of a session handle, so they should be used like fdtd.addplanersolid(),

      addplanarsolid()
      set('vertices',vtx)
      set('facets',a)

      I would suggest using putv and compare vtx and a between the API and lsf methods. However if you have a method that works in lsf pehaps you can just use fdtd.eval('' lsf script'')

      https://optics.ansys.com/hc/en-us/articles/360041401434

      Best Regards,

       

      • martinmi
        Subscriber

        Hi Taylor, 

        Thanks for the reply! After many tries I just found the right data type for the facets. So if someone creates a planarsolid object with Python, the vertices and facets should be defined as follows:

        1.  vtx = np.array([[0,0,0], [1e-6,0,0], [1e-6,1e-6,0], [0,1e-6,0], [0,0,1e-6], [1e-6,0,1e-6], [1e-6,1e-6,1e-6], [0,1e-6,1e-6]])
        2. a = [[np.array([[1,4,3,2]], dtype = object)], [np.array([[1,5,8,4]], dtype = object)], [np.array([[1,2,6,5]], dtype = object)], [np.array([[2,6,7,3]], dtype = object)], [np.array([[3,4,8,7]], dtype = object)], [np.array([[5,6,7,8]], dtype = object)]]

        After that, as you have already mentioned, you need(can) pass the facets and vertices to Lumerical Workspace:

        lum.putv('vertices',vtx)
        lum.putv('facets',a)

        And then use lum.addplanarsolid(vtx,a),

        I have run into another problem, this time I think it is more of a problem with the Lumerical Visualization option. So after I create the structure I want, for example a taper, I can't see one of the sides of the taper. Then when I rotate the object in Lumerical, some of the sides of the taper disappear in a certain position and then come back after I rotate the object back. Do you know if this is a problem that could affect my simulation results or is it more of a Lumerical Visualization problem? I have attached some photos that I took while rotating my taper. All the pictures are from the same object, but taken from a different object rotation angle.

         

        Best Regards,

        Martin 

         

         

Viewing 1 reply thread
  • You must be logged in to reply to this topic.