NanoComp / meep

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

Are magnetic fields automatically synchronised with electric fields in the function get_dft_array? #2508

Closed tmteryz closed 1 year ago

tmteryz commented 1 year ago

hello, dear meep developers I have noted the example(see the following picture and codes)in meep-document. so I want to confirm my understanding that magnetic fields are always automatically synchronised with electric fields in the function _get_dftarray. That is, the samples of the magnetic field at the moment t=nΔt is used for the discrete Fourier transform in _get_dftarray.

image

  # x-directed Poynting flux through monitor from frequency-domain fields
  monitor        = mp.FluxRegion(center=mon_center, size=mon_size)
  dft_cell       = sim.add_flux(freq, 0, 1, monitor)
  sim.run(...)    # timestep until DFTs converged
  (Ey,Ez,Hy,Hz)  = [sim.get_dft_array(dft_cell,c,0) for c in [mp.Ey, mp.Ez, mp.Hy, mp.Hz]]
  (x,y,z,w)      = sim.get_array_metadata(dft=dft_cell)
  flux_density   = np.real( np.conj(Ey)*Hz - np.conj(Ez)*Hy )    # array
  flux           = np.sum(w*flux_density)                        # scalar
smartalecH commented 1 year ago

Duplicate of #2506.