kch3782 / torcwa

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

How to view xy-plane field? #30

Open fyl-nju opened 5 days ago

fyl-nju commented 5 days ago

image Hello. I'm trying to get field of a single atom by TORCWA. The difference are that I choose the incident light from air to structure. So I add an input layer of eps=1,then SiN unit layer, and a SiO2 layer,then an output layer of eps=SiO2, and choose field_xy function to view Pz at the bottom of SiO2. My questions is :How can I get Pz from [Ex,Ey,Ez,Hx.Hy,Hz]?
I also found that, when I set layer_num=-1 with z_prop=-(layer1+layer2) , field_xy function get the field .But this field is different from layer_num=1 with z_prop=(layer1+layer2) or layer_num=2 with z_prop=0. Even for cylindrical structures, x and y polarization produce different imageshow to explain this ?

fyl-nju commented 5 days ago

Here are my codes,and it returns none: inc_ang = 0.(np.pi/180) # radian azi_ang = 0.(np.pi/180) # radian

material

substrate_eps = 1.46**2

geometry

L = [280., 280.] # nm / nm torcwa.rcwa_geo.Lx = L[0] torcwa.rcwa_geo.Ly = L[1] torcwa.rcwa_geo.nx = 280 torcwa.rcwa_geo.ny = 280 torcwa.rcwa_geo.grid() torcwa.rcwa_geo.edge_sharpness = 1000. torcwa.rcwa_geo.dtype = geo_dtype torcwa.rcwa_geo.device = device z = torch.linspace(-500,4000,901,device=device)

x_axis = torcwa.rcwa_geo.x.cpu() y_axis = torcwa.rcwa_geo.y.cpu() z_axis = z.cpu()

layers

layer0_geometry = torcwa.rcwa_geo.rectangle(Wx=150.,Wy=100.,Cx=L[0]/2.,Cy=L[1]/2.) layer0_thickness = 800. layer1_thickness = 2000.

lamb0 = torch.tensor(532.,dtype=geo_dtype,device=device) # nm

order_N = 15 order = [order_N,order_N] sim = torcwa.rcwa(freq=1/lamb0,order=order,L=L,dtype=sim_dtype,device=device) sim.add_input_layer(eps=1.) sim.add_output_layer(eps=substrate_eps) sim.set_incident_angle(inc_ang=inc_ang,azi_ang=azi_ang) silicon_eps = Materials.SiN.apply(lamb0)*2 layer0_eps = layer0_geometrysilicon_eps + (1.-layer0_geometry) sim.add_layer(thickness=layer0_thickness,eps=layer0_eps) sim.add_layer(thickness=layer1_thickness,eps=substrate_eps) sim.solve_global_smatrix() sim.source_planewave(amplitude=[0,1],direction='forward')

View XY-plane fields and export

[Ex, Ey, Ez], [Hx, Hy, Hz] = sim.field_xy(layer_num=2,x_axis=torcwa.rcwa_geo.x,y_axis=torcwa.rcwa_geo.y,z_prop=0) Enorm = torch.sqrt(torch.abs(Ex)2 + torch.abs(Ey)2 + torch.abs(Ez)2) Hnorm = torch.sqrt(torch.abs(Hx)2 + torch.abs(Hy)2 + torch.abs(Hz)2) Pz=torch.real(Ex.conj() Hy - Ey.conj() Hx)