Ansys Learning Forum Forums Discuss Simulation Photonics Inverse design y branch visulizaing initial geometry Reply To: Inverse design y branch visulizaing initial geometry

Taylor Robertson
Ansys Employee


It is important to avoid any self-intersecting geometries, and so checking the shape of geometry is important. Using matplotlib is the easiest way. Something like the following python code would work for FunctionDefinedGeometry.
import matplotlib.pyplot as plt
...
def shape_function(params):
...
return polygon_points
...
points = shape_function(initial_parameters)
x , y =points[:,0], points[:,1]
plt.plot(x, y, 'b-')
plt.show If you are using ParameterizedGeometry then you will need to use lumapi to start a session and have the lumerical GUI draw the structure. Maybe copy your function to a new file, and add a main. That is what I would do anyway.
...
def func(params, fdtd_handle, only_update = True):
...
return
...
if __name__ == "__main__":
with lumapi.FDTD() as fdtd:
fdtd.eval('coupler;') #Set-up script in same directory
params = np.array([()] ) # Test params
func(params, fdtd) #Eval your function
input('Press enter..') #Wait so you can inspect the design