kch3782 / torcwa

GPU-accelerated RCWA with automatic differentiation
Other
98 stars 20 forks source link

Function field_xy #29

Closed ayash04 closed 1 month ago

ayash04 commented 1 month ago

TORCWA Fields I am using TORCWA, Lumerical FDTD, and Lumerical RCWA to simulate a simple structure for the sake of verification between different solvers. The fields in the XZ plane at y=0 match really well. However, if I use the function field_xy and visualize the fields at different z positions, the results of TORCWA are just the opposite than the other solvers (where it should be max it is min and vice versa), and it contradicts the results I got by field_xz function. Is it possible that there is some issue with the function field_xy? PS: All the results shown are for the electric field intensity. Thank you in advance! Kindly find my code: inc_ang = 0 azi_ang =0 lamb0 = torch.tensor(630., dtype= geo_dtype,device=device)

material

substrate_eps = 1.4572 NbO_eps = 2.3052

geometry

L = [1000.,1000.] #pitch torcwa.rcwa_geo.Lx = L[0] torcwa.rcwa_geo.Ly = L[1] torcwa.rcwa_geo.nx = 1000 torcwa.rcwa_geo.ny = 1000 torcwa.rcwa_geo.grid() torcwa.rcwa_geo.edge_sharpness = 1000. torcwa.rcwa_geo.dtype = geo_dtype torcwa.rcwa_geo.device = device z = torch.linspace(-200,5000,400,device=device) x_axis = torcwa.rcwa_geo.x.cpu() y_axis = torcwa.rcwa_geo.y.cpu() z_axis = z.cpu()

layers

Width= 180. layer0_geometry = torcwa.rcwa_geo.square(W=Width,Cx =L[0]/2,Cy =L[1]/2.) layer0_thickness = 800. order = [12,12] sim = torcwa.rcwa(freq=1 / lamb0, order=order, L=L, dtype=sim_dtype, device=device) sim.source_planewave(amplitude=[1.,0],direction='forward') sim.add_input_layer(eps=substrate_eps) sim.set_incident_angle(inc_ang=inc_ang, azi_ang=azi_ang) layer0_eps = layer0_geometry NbO_eps + (1. - layer0_geometry)1 sim.add_layer(thickness=layer0_thickness, eps=layer0_eps) sim.solve_global_smatrix() pixel_span = torcwa.rcwa_geo.Lx/2 x_axis = torch.linspace(-pixel_span, pixel_span, torcwa.rcwa_geo.nx) # Adjust range and resolution as needed y_axis = torch.linspace(-pixel_span, pixel_span,torcwa.rcwa_geo.ny) layer_num = 1 # Example layer number z_prop =1700 # Distance from layer boundary [Ex, Ey, Ez], [Hx, Hy, Hz] = sim.field_xy(layer_num, x_axis, y_axis, z_prop) I = torch.abs(Ex)2 + torch.abs(Ey)2 + torch.abs(Ez)**2