Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions doc/docs/Python_Tutorials/Eigenmode_Source.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ The simulation script is in [examples/oblique-planewave.py](https://github.com/N
```py
import meep as mp
import numpy as np
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt

resolution = 50 # pixels/μm
Expand All @@ -243,9 +245,9 @@ cell_size = mp.Vector3(14,10,0)
pml_layers = [mp.PML(thickness=2,direction=mp.X)]

# rotation angle (in degrees) of planewave, counter clockwise (CCW) around z-axis
rot_angle = np.radians(0)
rot_angle = np.radians(23.2)

fsrc = 1.0 # frequency of planewave (wavelength = 1/fsrc)
fsrc = 1.0 # frequency (wavelength = 1/fsrc)

n = 1.5 # refractive index of homogeneous material
default_material = mp.Medium(index=n)
Expand All @@ -258,8 +260,7 @@ sources = [mp.EigenModeSource(src=mp.ContinuousSource(fsrc),
direction=mp.AUTOMATIC if rot_angle == 0 else mp.NO_DIRECTION,
eig_kpoint=k_point,
eig_band=1,
eig_parity=mp.EVEN_Y+mp.ODD_Z if rot_angle == 0 else mp.ODD_Z,
eig_match_freq=True)]
eig_parity=mp.EVEN_Y+mp.ODD_Z if rot_angle == 0 else mp.ODD_Z)]

sim = mp.Simulation(cell_size=cell_size,
resolution=resolution,
Expand All @@ -269,11 +270,12 @@ sim = mp.Simulation(cell_size=cell_size,
default_material=default_material,
symmetries=[mp.Mirror(mp.Y)] if rot_angle == 0 else [])

sim.run(until=100)
sim.run(until=20)

nonpml_vol = mp.Volume(center=mp.Vector3(), size=mp.Vector3(10,10,0))

sim.plot2D(fields=mp.Ez,
plot_boundaries_flag=False,
output_plane=nonpml_vol)

if mp.am_master():
Expand All @@ -288,3 +290,15 @@ Shown below are the steady-state field profiles generated by the planewave for t
<center>
![](../images/eigenmode_planewave.png)
</center>

An alternative method to launching a planewave in homogeneous media which provides more control over specifying its polarization, particularly in 3D, is to use a `DiffractedPlanewave` object for the `eig_band` property of the `EigenModeSource` instead of a band number and parity as in the previous example which used 1 and `mp.ODD_Z`, respectively. A planewave with wavevector $\vec{k}$ can be defined using the *zeroth* diffraction order combined with the `k_point` of the `Simulation` object set to $\vec{k}$. As a demonstration, the previous example which involved an $E_z$-polarized source (equivalent to the $\mathcal{S}$ polarization given the plane of incidence of $xy$), can also be defined using:

```py
sources = [mp.EigenModeSource(src=mp.ContinuousSource(fsrc),
center=mp.Vector3(),
size=mp.Vector3(y=10),
eig_band=mp.DiffractedPlanewave((0,0,0),
mp.Vector3(0,1,0),
1,
0))]
```
22 changes: 17 additions & 5 deletions python/examples/oblique-planewave.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import meep as mp
import numpy as np
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt


resolution = 50 # pixels/μm

cell_size = mp.Vector3(14,10,0)

pml_layers = [mp.PML(thickness=2,direction=mp.X)]

# rotation angle (in degrees) of planewave, counter clockwise (CCW) around z-axis
rot_angle = np.radians(0)
rot_angle = np.radians(23.2)

fsrc = 1.0 # frequency of planewave (wavelength = 1/fsrc)
fsrc = 1.0 # frequency (wavelength = 1/fsrc)

n = 1.5 # refractive index of homogeneous material
default_material = mp.Medium(index=n)
Expand All @@ -24,8 +27,16 @@
direction=mp.AUTOMATIC if rot_angle == 0 else mp.NO_DIRECTION,
eig_kpoint=k_point,
eig_band=1,
eig_parity=mp.EVEN_Y+mp.ODD_Z if rot_angle == 0 else mp.ODD_Z,
eig_match_freq=True)]
eig_parity=mp.EVEN_Y+mp.ODD_Z if rot_angle == 0 else mp.ODD_Z)]

## equivalent definition
# sources = [mp.EigenModeSource(src=mp.ContinuousSource(fsrc),
# center=mp.Vector3(),
# size=mp.Vector3(y=10),
# eig_band=mp.DiffractedPlanewave((0,0,0),
# mp.Vector3(0,1,0),
# 1,
# 0))]

sim = mp.Simulation(cell_size=cell_size,
resolution=resolution,
Expand All @@ -35,11 +46,12 @@
default_material=default_material,
symmetries=[mp.Mirror(mp.Y)] if rot_angle == 0 else [])

sim.run(until=100)
sim.run(until=20)

nonpml_vol = mp.Volume(center=mp.Vector3(), size=mp.Vector3(10,10,0))

sim.plot2D(fields=mp.Ez,
plot_boundaries_flag=False,
output_plane=nonpml_vol)

if mp.am_master():
Expand Down
Loading