MCPcopy Create free account
hub / github.com/NanoComp/meep / get_equiv_sources

Function get_equiv_sources

python/source.py:780–812  ·  view source on GitHub ↗

Given the fields along a slice, returns the equivalent sources as meep source objects for the beam.

(field, normal_vec, time_src, center, size)

Source from the content-addressed store, hash-verified

778
779
780def get_equiv_sources(field, normal_vec, time_src, center, size):
781 """Given the fields along a slice, returns the equivalent sources as meep source objects for the beam."""
782 # Get fields
783 Ex, Ey, Ez, Hx, Hy, Hz = field
784 nHat = normal_vec
785
786 # Electric current K = nHat x H
787 Kx = nHat[1] * Hz - nHat[2] * Hy
788 Ky = nHat[2] * Hx - nHat[0] * Hz
789 Kz = nHat[0] * Hy - nHat[1] * Hx
790
791 # Mangnetic current N = - nHat x E
792 Nx = nHat[2] * Ey - nHat[1] * Ez
793 Ny = nHat[0] * Ez - nHat[2] * Ex
794 Nz = nHat[1] * Ex - nHat[0] * Ey
795
796 # Source components
797 components = {mp.Ex: Kx, mp.Ey: Ky, mp.Ez: Kz, mp.Hx: Nx, mp.Hy: Ny, mp.Hz: Nz}
798
799 # Make sources
800 sources = [
801 mp.Source(
802 time_src,
803 field_comp,
804 center=center,
805 size=size,
806 amp_data=source_comp,
807 )
808 for field_comp, source_comp in components.items()
809 if np.sum(np.abs(source_comp))
810 ]
811
812 return sources
813
814
815class GaussianBeam2DSource(GaussianBeam3DSource):

Callers 1

add_sourceMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected