Good morning
I am a beginner in Meep. Currently, I am trying modifying
the simulation in Eigenmode source tutorial reported in
meep documentation.
Here I report the code I am using
import meep as mp
import numpy as np
import matplotlib.pyplot as plt
w = 5 # width of waveguide
delta_n=0.01 #delta di n della perturbazione
d = 0.8 # defect spacing (ordinary spacing = 1)
c=3*np.power(10,8)
l_unit=1e-6
N = 50 # number of slab on either side of
defect
sy =15 # size of cell in y direction
(perpendicular to wvg.)
pad = 2 # padding between last hole and PML edge
dpml = 1.0 # PML thickness
n_c=1.3 #n_cladding
index=1.5 #n_core
index2=index+delta_n #defect material
V=0.46 #normalized frequency
k0=V/((w*l_unit)*np.sqrt(np.power(index,2)-np.power(n_c,2)))
f=k0*c/(2*np.pi)
lambda_used=(c/f)/l_unit
n_eff=1.303
kx =n_eff/lambda_used # initial guess for wavevector in
x-direction of eigenmode
period_needed=lambda_used/(2*n_eff)
r=period_needed-d #dimension of defect
print(r)
fsrc=1/lambda_used
delta_wl=5
delta_f=abs(1/(lambda_used-delta_wl)-1/(lambda_used+delta_wl))
par=delta_f/fsrc
print(par)
time_to_wait=1000
bnum = 1 # band number of eigenmode
tolerance=1e-1
nfreq=128
resolution = 10 # pixels/um
sx = 2*(pad+dpml)+N*(d+r)+d # size of cell in x direction
y_center=0
cell=mp.Vector3(sx,sy,0)
geometry = [mp.Block(mp.Vector3(mp.inf,w,mp.inf),
center=mp.Vector3(),
material=mp.Medium(index=index)),mp.Block(mp.Vector3(mp.inf,w,mp.inf),
center=mp.Vector3(0,-w,0),
material=mp.Medium(index=n_c)),mp.Block(mp.Vector3(mp.inf,w,mp.inf),
center=mp.Vector3(0,w,0), material=mp.Medium(index=n_c))]
pml_layer=[mp.PML(1.0)]
src = [mp.EigenModeSource(src=mp.GaussianSource(fsrc,
delta_f),
center=mp.Vector3(-0.5*sx+dpml,y_center,0),
size=mp.Vector3(y=3*w),
direction=mp.AUTOMATIC,
eig_kpoint=mp.Vector3(kx),
eig_band=bnum,
eig_match_freq=True)]
sim = mp.Simulation(cell_size=cell, geometry=geometry,
boundary_layers=pml_layer, sources=src,
resolution=resolution)
refl_fr=mp.FluxRegion(center=mp.Vector3(-0.5*sx+dpml+1,y_center,0),size=mp.Vector3(0,2*w,0))
refl=sim.add_flux(fsrc,delta_f,nfreq,refl_fr)
tran_fr=mp.FluxRegion(center=mp.Vector3(0.5*sx-dpml-1,y_center,0),size=mp.Vector3(0,2*w,0))
tran=sim.add_flux(fsrc,delta_f,nfreq,tran_fr)
%matplotlib inline
plt.figure(dpi=100)
sim.plot2D()
plt.show()
pt=mp.Vector3(0.5*sx+dpml-3,y_center)
sim.run(until_after_sources=mp.stop_when_fields_decayed(time_to_wait,mp.Ez,pt,tolerance))
flux_frequencies=mp.get_flux_freqs(tran)
reflection_for_normalization=sim.get_flux_data(refl)
to_be_plotted=mp.get_fluxes(refl)
transmission_plot_no_discontinuity=mp.get_fluxes(tran)
wl = []
Ts_no_d = []
Rs_no_d = []
for i in range(nfreq):
wl = np.append(wl, flux_frequencies[i])
Rs_no_d=np.append(Rs_no_d,to_be_plotted[i])
Ts_no_d =
np.append(Ts_no_d,transmission_plot_no_discontinuity[i])
if mp.am_master():
plt.figure()
plt.plot(wl,Rs_no_d, label='riflectivity no
discontinuity')
plt.plot(wl,Ts_no_d,label='transmittance no
discontinuity')
plt.xlabel("wavelength (μm)")
plt.legend(loc="upper right")
plt.show()
My problem is related to this last step. In fact, The
plotted result is different from a Gaussian pulse. Is it
normal? Can you explain me where I am wrong?
_______________________________________________
meep-discuss mailing list
meep-discuss@ab-initio.mit.edu
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss