Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eigenmode source unable to launch modes in negative direction #752

Closed
oskooi opened this issue Mar 2, 2019 · 2 comments
Closed

eigenmode source unable to launch modes in negative direction #752

oskooi opened this issue Mar 2, 2019 · 2 comments
Labels

Comments

@oskooi
Copy link
Collaborator

oskooi commented Mar 2, 2019

The EigenModeSource can be used to launch oblique-angle, forward-propagating planewaves as demonstrated by the following script.

import meep as mp
import numpy as np
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)

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

n = 1.5 # refractive index of homogeneous material                                                                                                                       
default_material = mp.Medium(index=n)

k_point = mp.Vector3(fsrc*n).rotate(mp.Vector3(z=1), rot_angle)

sources = [mp.EigenModeSource(src=mp.ContinuousSource(fsrc),
                              center=mp.Vector3(),
                              size=mp.Vector3(y=10),
                              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)]

sim = mp.Simulation(cell_size=cell_size,
                    resolution=resolution,
                    boundary_layers=pml_layers,
                    sources=sources,
                    k_point=k_point,
                    default_material=default_material,
                    symmetries=[mp.Mirror(mp.Y)] if rot_angle == 0 else [])

sim.run(until=100)

nonpml_vol = mp.Volume(center=mp.Vector3(), size=mp.Vector3(10,10,0))
ez_data = sim.get_array(vol=nonpml_vol, component=mp.Ez)

plt.figure()
plt.imshow(np.flipud(np.transpose(np.real(ez_data))), interpolation='spline36', cmap='RdBu')
plt.axis('off')
plt.show()

eigenmode_pw

The three examples shown above for rotation angles (rot_angle) of 0°, 20°, and 40° involve a k_point in which all vector components have positive values. However, when trying to launch a planewave propagating in the negative direction at 0° via a negative k_point (shown below), the fields blow up:

k_point = mp.Vector3(-fsrc*n).rotate(mp.Vector3(z=1), rot_angle)

The fields also blow up if the rotation angle is >90° which involves negative components for k_point.

@oskooi oskooi added the bug label Mar 2, 2019
@stevengj
Copy link
Collaborator

stevengj commented Mar 8, 2019

This should be a simple bug somewhere — nothing fundamental prevents this, so there is probably a line or two that is incorrectly assuming the sign of k

@stevengj
Copy link
Collaborator

stevengj commented Mar 21, 2019

Should be fixed now, e.g. I tried your script for an angle of 110° and got the expected result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants