Hello,
I'm learning Meep, and in the spirit of "walk before you run" and
wanting to make sure I am solid on the concepts, I've been experimenting
with some simple tests.
In one experiment, I set the computation cell to be 20 units tall (y
direction) and inserted a "block" of material that's centered in y, and
also 20 units tall.
I am using Bloch periodicity, and illuminating the material with a plane
wave.
If the y-size of the block of material is exactly 20 units, I get what
appears to be diffraction around the end of the block (outside the cell!).
If I extend the block of material by a few tenths of a unit, the effect
diminishes, and appears to be completely gone at 0.1 unit of extra
height. The resolution is set to 10, so I'm wondering if the block is
extending to the next grid point (top and bottom).
Increasing the resolution to 20 does, indeed, half the amount of
extension outside the cell that's required to suppress this diffraction.
This behavior was unexpected to me, so my question is whether this is
expected behavior, or a bug...
Or, it is more likely that this is simply a bug in my understanding of
how things are meant to work.
If anyone is interested, here's the code. The extra block y-size is the
variable "xtra" and the code, as copied here, should show this diffraction.
Regards
Doug
#---------------------------------------------------------------------------------
from __future__ import division
import cmath
import math
import meep as mp
sy=20
sx=40
posx=-sx/2 + 4
t=1.0
xtra=0.0
input_ang_deg=0
input_ang=math.radians(input_ang_deg)
cell = mp.Vector3(sx, sy, 0)
geometry = [mp.Block(mp.Vector3(t, xtra+sy, 1e20), #top half
center=mp.Vector3(posx-(t)/2, 0),
material=mp.Medium(epsilon=2.25))]
def source_cpxamp(pos):
amp=cmath.exp(complex(1, pos.y*k.y))
return amp
fcen = 1.5# pulse center frequency
lam=1/fcen
#df = 0.02 # turn-on bandwidth
k_x=math.cos(input_ang)
k_y=math.sin(input_ang)
kdir = mp.Vector3(k_x,k_y) # direction of k (length is irrelevant)
print('kdir')
print(kdir)
k = kdir.unit().scale(2 * math.pi * fcen) # k with correct length
print('k')
print(k)
bloch_k_point=kdir*fcen # kdir.unit().scale(fcen) # there's a scale
factor that eludes me here...
sources = [
mp.Source(
mp.ContinuousSource(frequency=fcen),
component=mp.Ez,
center=mp.Vector3(-sx/2 +2 , 0),
size=mp.Vector3(0, sy),
amp_func=source_cpxamp
)]
pml_layers = [mp.PML(thickness=1.0 ,direction=mp.X)]
resolution = 10
sim = mp.Simulation(cell_size=cell,
k_point=bloch_k_point,
boundary_layers=pml_layers,
geometry=geometry,
sources=sources,
resolution=resolution)
sim.run(until=50)
import numpy as np
import matplotlib.pyplot as plt
eps_data = sim.get_array(mp.Vector3(), cell, mp.Dielectric)
#plt.figure(dpi=100)
#plt.imshow(eps_data.transpose(),
origin='lower',interpolation='spline36', cmap='binary')
#plt.axis('off')
#plt.show()
ez_data = sim.get_array(mp.Vector3(), cell, mp.Ez,cmplx=False)
plt.figure(dpi=100)
plt.imshow(eps_data.transpose(), origin='lower',
interpolation='spline36', cmap='binary')
plt.imshow(ez_data.transpose(), origin='lower',
interpolation='spline36', cmap='RdBu', alpha=0.9)
plt.axis('off')
plt.show()
_______________________________________________
meep-discuss mailing list
meep-discuss@ab-initio.mit.edu
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss