On 11/8/20 15:17, Ian Sage wrote:
Does anyone have a working sample circular polarized GaussianBeamSource
code, which they can share?
The following script launches a circularly polarized Gaussian beam
source propagating along the +z direction in 3d. It is based on
combining two overlapping GaussianBeamSource objects with orthogonal
transverse polarization (Ex and Ey) that are 90° out of phase. Note that
for this to work it is necessary to set force_complex_fields=True in the
Simulation constructor (otherwise only the real part of the source is
used by default). A 2d cross section of the beam profile is output at
the end of the run.
import meep as mp
import math
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
resolution = 10
s = 12
dpml = 1
cell_size = mp.Vector3(s,s,s)
boundary_layers = [mp.PML(thickness=dpml)]
beam_x0 = mp.Vector3(0,0,0) # beam center
rot_angle = math.radians(0) # CCW rotation angle about z axis (0: +y axis)
beam_kdir = mp.Vector3(0,0,1).rotate(mp.Vector3(1,0,0),rot_angle) # beam
propagation direction
beam_w0 = 0.8 # beam waist radius
fcen = 1
sources = [mp.GaussianBeamSource(src=mp.ContinuousSource(fcen),
center=mp.Vector3(),
size=mp.Vector3(s,s,0),
beam_x0=beam_x0,
beam_kdir=beam_kdir,
beam_w0=beam_w0,
beam_E0=mp.Vector3(1,0,0)),
mp.GaussianBeamSource(src=mp.ContinuousSource(fcen),
center=mp.Vector3(),
size=mp.Vector3(s,s,0),
beam_x0=beam_x0,
beam_kdir=beam_kdir,
beam_w0=beam_w0,
beam_E0=mp.Vector3(0,1,0),
amplitude=1j)]
sim = mp.Simulation(resolution=resolution,
cell_size=cell_size,
boundary_layers=boundary_layers,
sources=sources,
force_complex_fields=True)
sim.run(until=50)
plt.figure()
sim.plot2D(fields=mp.Ex,
output_plane=mp.Volume(center=mp.Vector3(),
size=mp.Vector3(s-2*dpml,0,s-2*dpml)))
plt.savefig('beam3d_xz_Ex_angle{}.png'.format(int(math.degrees(rot_angle))),bbox_inches='tight',pad_inches=0)
plt.figure()
sim.plot2D(fields=mp.Ex,
output_plane=mp.Volume(center=mp.Vector3(),
size=mp.Vector3(0,s-2*dpml,s-2*dpml)))
plt.savefig('beam3d_yz_Ex_angle{}.png'.format(int(math.degrees(rot_angle))),bbox_inches='tight',pad_inches=0)
_______________________________________________
meep-discuss mailing list
meep-discuss@ab-initio.mit.edu
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss