I am trying to obtain Px and Py for back-scattered light from a gold 
nanorectangle (under mp.Ex source illumination) by defining some dft monitors 
as follows


  1.  set reference simulation dft monitor

## Reflexion DFT monitor
box_DFT_re_ref = sim.add_dft_fields([mp.Ex,mp.Ey,mp.Hx,mp.Hy],
                                frq_cen,dfrq,nfrq,
                                center=mp.Vector3(z=-s/2+dpml+0.05),
                                size=mp.Vector3(s-2*dpml,s-2*dpml),
                                yee_grid=False)


  1.  run simulation


sim.run(…)


  1.  obtain reference flux

# DFT reflected fields ref
flux_ref=[]
flux_x_ref=[]
flux_y_ref=[]
for n in np.arange(0,nfrq,1):
    nfrq_in=int(n)
    (Ex,Ey,Hx,Hy)  = [sim.get_dft_array(box_DFT_re_ref,nfrq,nfrq_in) for nfrq 
in [mp.Ex, mp.Ey, mp.Hx, mp.Hy]]
    (x,y,z,w)      = sim.get_array_metadata(dft_cell=box_DFT_re_ref)
    dxy = 1/resolution**2

    flux_density   = np.real( Ex*np.conj(Hy) -Ey*np.conj(Hx) )    # array
    flux_ref=0.5*np.append(flux_ref, np.sum(flux_density*dxy)) # Total

    flux_density   = np.real( Ex*np.conj(Hy) )    # array
    flux_x_ref=0.5*np.append(flux_x_ref, np.sum(flux_density*dxy)) # Px

    flux_density   = np.real( Ey*np.conj(Hx) )    # array
    flux_y_ref=0.5*np.append(flux_y_ref, np.sum(flux_density*dxy)) # Py


  1.  reset simulation, include geometry, set DFT monitor

# DFT field reflection monitor
box_DFT_re= sim.add_dft_fields([mp.Ex,mp.Ey,mp.Hx,mp.Hy],
                                frq_cen,dfrq,nfrq,
                                center=mp.Vector3(z=-s/2+dpml+0.05),
                                size=mp.Vector3(s-2*dpml,s-2*dpml),
                                yee_grid=False)


  1.  run simulation
  2.  obtain flux

## Px and Py calculation
flux=[]
flux_x=[]
flux_y=[]
for n in np.arange(0,nfrq,1):
    nfrq_in=int(n)
    (Ex,Ey,Hx,Hy)  = [sim.get_dft_array(box_DFT_re,nfrq,nfrq_in) for nfrq in 
[mp.Ex, mp.Ey, mp.Hx, mp.Hy]]
    (x,y,z,w)      = sim.get_array_metadata(dft_cell=box_DFT_re)
    dxy = 1/resolution**2

    flux_density   = np.real( Ex*np.conj(Hy) -Ey*np.conj(Hx) )
    flux=0.5*np.append(flux,np.sum(flux_density*dxy)) # Total

    flux_density   = np.real( Ex*np.conj(Hy) )
    flux_x=0.5*np.append(flux_x,np.sum(flux_density*dxy)) # Px

    flux_density   = np.real( Ey*np.conj(Hx) )
    flux_y=0.5*np.append(flux_y,np.sum(flux_density*dxy)) # Py


  1.  plot results removing source flux and normalize to source

## Plot Px and Py
if mp.am_master():
    plt.figure(dpi=150)

    plt.plot(1/np.asarray(freqs),-(flux-flux_ref)/flux_ref 
,'r-',label='P_total')
    plt.plot(1/np.asarray(freqs),-(flux_x-flux_x_ref)/flux_ref ,'go',label='Px')
    plt.plot(1/np.asarray(freqs),(flux_y-flux_y_ref)/flux_ref ,'c*',label='Py')
    plt.plot(wl,Rs,'bo-',label='Back-scatter') #results obtained from get_flux 
monitor of identical dimensions

    plt.grid(True,which="both",ls="-")
    plt.xlabel('wavelength, um')
    plt.ylabel(Scattering')
    plt.legend(loc='upper left')
    plt.title('Px and Py')
   plt.tight_layout()
    plt.savefig("media/PxPy.png")

Yet my results are not identical to when I use get_flux (also having removed 
the source flux) as seen in this link. What could be the origin of this 
difference?

Image link: 
https://cdn.discordapp.com/attachments/765260434419875931/776558260483391528/PxPy.png

Thank you
_______________________________________________
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