Hello all,

I am trying to collect the scattered field in time domain at a far-field
point of a material by hitting it with a laser beam. I placed the
collector and source at the same location. The laser beam will propagate
through a near2far region and hits the target. I follow the near to far
field spectra tutorial, runs a normalization and subtract it from the
second run. And then convert it to time-domain using ifft. However, the
collected time-domain data does not seem right.

I suspect it is the interference between the incident and reflection wave
causes the problem. Would you please let me know how to properly avoid the
interference?

Any help would be appreciated.

import meep as mp
import math
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import csv

c = 299792458  # m/s
meepTime = 1/c

S = 0.5          # Courant parameter
resolution = 35000      # pixels/m (grid resolution dx)
deltaT = (S/resolution)*(meepTime)
# (timestep(deltaT) / time unit)*(meep time in unit a)
deltaX = 1/resolution  # m/resolution (m)

xsize= 0.005
ysize= 0.005
zsize = 0.01
dpml = 0.2e-3
cell_size = mp.Vector3(xsize+2*dpml,ysize+2*dpml,zsize+2*dpml)
# defines the overall size of simulation

spacing = 20 * deltaX        # spacing between source and PML

boundary_layers = [mp.PML(thickness=dpml)]


focus = mp.Vector3(0,0,-zsize/4)                     # beam focus coordinate
center = mp.Vector3(0,0,0.5*zsize-spacing)           # source plane center


rot_angle = 0           # CCW x-axis
beam_kdir = mp.Vector3(0,0,-1).rotate(mp.Vector3(1,0,0
),math.radians(rot_angle))
# prop direction & rotation alone which axis & which degree
beam_w0 = 0.0014        # beam waist radius (a)
beam_E0 = mp.Vector3(1,0,0)     # polarization
beam_x0 = focus - center     # beam focus (relative to source center)


# define custom source:
a1,b1,c1,a2,b2,c2,a3,b3,c3 = 1.6665, -0.0355, 0.0358, -0.6711, -0.0551,
0.1080, 0.0337, -0.3798, 0.4232
a4,b4,c4,a5,b5,c5,a6,b6,c6,a7,b7,c7 = 0.1968, 0.0607, 0.0418, -0.0904, -
0.1674, 0.1471, 0.0147, 0.7947, 0.3705, 0.0026, -0.9388, 0.0522
k = 1.3511e-11 / meepTime
k1 = 7.7970e-12 / meepTime

thz = lambda t : (a1*np.exp(-((((t-k)/k1)-b1)/c1)**2
) + a2*np.exp(-((((t-k)/k1)-b2)/c2)**2) + \
a3*np.exp(-((((t-k)/k1)-b3)/c3)**2) + a4*np.exp(-((((t-k)/k1)-b4)/c4)**2
) + \
a5*np.exp(-((((t-k)/k1)-b5)/c5)**2) + a6*np.exp(-((((t-k)/k1)-b6)/c6)**2
) + \
a7*np.exp(-((((t-k)/k1)-b7)/c7)**2))


fcen = 1/0.00029979      # 1THz
sources = [mp.GaussianBeamSource(src=mp.CustomSource(src_func=thz,
center_frequency= fcen, end_time= 2.6e-11/meepTime),
                        center=center,
                        size=mp.Vector3(xsize,ysize),
                        beam_x0=beam_x0,
                        beam_kdir=beam_kdir,
                        beam_w0=beam_w0,
                        beam_E0=beam_E0)]

sim = mp.Simulation(resolution=resolution,
                    cell_size=cell_size,
                    boundary_layers=boundary_layers,
                    eps_averaging=False,
                    sources=sources,
                    Courant=S)

nearfield_box = sim.add_near2far(6.0544e3, 1.1367e4, 1024,
                                 mp.Near2FarRegion(mp.Vector3(z=-zsize/4
+deltaX), size=mp.Vector3(0.007, 0.007, 0)))


endTime = 26*(10**-12)*3/meepTime



sim.run(until=endTime)

nearfield_refl_data = sim.get_near2far_data(nearfield_box)
# save incident field for subtraction
incidentField_data = sim.get_farfield(nearfield_box, center)
# save incident field for output


sim.reset_meep()
# reset Meep, run simulation with geometry (total field)





# ==========================================   Second run
==========================================================

geometry = [mp.Block(mp.Vector3(0.003,0.003,0.001),
                     center=mp.Vector3(0,0,-0.003),
                     material=mp.Medium(epsilon=4))]

sim = mp.Simulation(resolution=resolution,
                    cell_size=cell_size,
                    boundary_layers=boundary_layers,
                    geometry=geometry,
                    eps_averaging=False,
                    sources=sources,
                    Courant=S)

print('\n beam focus: ',*focus, '\n angle: ', rot_angle)

nearfield_box = sim.add_near2far(6.0544e3, 1.1367e4, 1024,
                                 mp.Near2FarRegion(mp.Vector3(z=-zsize/4
+deltaX), size=mp.Vector3(0.007, 0.007, 0)))

sim.init_sim()   # initialize structure
sim.plot2D(output_plane=mp.Volume(center=mp.Vector3(), size=mp.Vector3(0
,ysize+2*dpml,zsize+2*dpml)))           # take a look at geometry (no field)
plt.savefig('beam3D_yz.png')
plt.close()

sim.load_minus_near2far_data(nearfield_box, nearfield_refl_data)
# subtract incidnet from total field


sim.run(until=endTime)

scatterField_data = sim.get_farfield(nearfield_box, center)


csvFile = open("FFT_Freq.csv", "w")
# save real and imag part of far-field to file
writer = csv.writer(csvFile)
writer.writerow(np.real(scatterField_data))
# row 1,2 is data of second run
writer.writerow(np.imag(scatterField_data))
writer.writerow(np.real(incidentField_data))
# row 3,4 is data of first run
writer.writerow(np.imag(incidentField_data))
_______________________________________________
meep-discuss mailing list
meep-discuss@ab-initio.mit.edu
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss

Reply via email to