NanoComp / meep

free finite-difference time-domain (FDTD) software for electromagnetic simulations
GNU General Public License v2.0
1.16k stars 594 forks source link

The mangitude of input GuassianBeam is not equals to 1 #2849

Closed beizhixing closed 2 weeks ago

beizhixing commented 2 weeks ago

I want to simulate a Circular-polarized Guassianbeam input with mangitude is 1. However, the simulations of input plane in vacuum shows it is vear small, I have no idea, is there any details I need to set?

Here is the code and the resulting image:

Circular-polarized guassian continous source

beam_x0 = mp.Vector3(0, 0, 0)  # beam focus (relative to source center)
rot_angle = 0  # CCW rotation angle about z axis (0: +y axis)
beam_kdir = mp.Vector3(0, 0, 1).rotate(
    mp.Vector3(0, 1, 0), math.radians(rot_angle)
)  # beam propagation direction
beam_w0 = r  # beam waist radius
beam_E0 = math.sqrt(2)/2*mp.Vector3(1,1j,0)
sources = [
mp.GaussianBeamSource(
    src=mp.ContinuousSource(fcen, fwidth=df, is_integrated=True),
    center=mp.Vector3(0,0, -0.5 * sz + dpml+ 0.5*dair),
    size=mp.Vector3(sides,sides,0),
    beam_x0=beam_x0,
    beam_kdir=beam_kdir,
    beam_w0=beam_w0,
    beam_E0=beam_E0, 
    )
]

# Free-space
sim = mp.Simulation(
    resolution=resolution,
    cell_size=cell_size,
    boundary_layers=pml_layers,
    sources=sources,
    default_material=mp.Medium(index=1.0)
)

xy_sizes = mp.Vector3(sides, sides, 0)
sim.add_flux(fcen, 0, 1, mp.FluxRegion(center=mp.Vector3(0, 0, 0), size=mp.Vector3(sides, 0, d)))
sim.add_flux(fcen, 0, 1, mp.FluxRegion(center=mp.Vector3(0, 0, -0.5 * sz + dpml + 0.5 * dair), size=xy_sizes))

sim.run(until = 1000)

# Obtain electric field data from the monitors
plin_data = [sim.get_array(center=mp.Vector3(0, 0, -0.5 * sz + dpml + 0.5*dair), size=mp.Vector3(sides, sides, 0), component=c, cmplx=True) for c in [mp.Ex, mp.Ey, mp.Ez, mp.Hx, mp.Hy, mp.Hz]]    
plXZ_data = [sim.get_array(center=mp.Vector3(0,0,0), size=mp.Vector3(sides, 0, d), component=c, cmplx=True) for c in [mp.Ex, mp.Ey, mp.Ez, mp.Hx, mp.Hy, mp.Hz]]

plane_in_intensity = np.sqrt(np.abs(plin_data[0])**2 + np.abs(plin_data[1])**2 + np.abs(plin_data[2])**2)
plane_XZ_intensity = np.sqrt(np.abs(plXZ_data[0])**2 + np.abs(plXZ_data[1])**2 + np.abs(plXZ_data[2])**2)
savemat('Vacuum_in_data.mat', {'Ex': plin_data[0], 'Ey': plin_data[1], 'Ez': plin_data[2], 'Hx': plin_data[3], 'Hy': plin_data[4], 'Hz': plin_data[5]})
savemat('Vacuum_XZ_data.mat', {'Ex': plXZ_data[0], 'Ey': plXZ_data[1], 'Ez': plXZ_data[2],'Hx': plXZ_data[3], 'Hy': plXZ_data[4], 'Hz': plXZ_data[5]})