Skip to content

Commit

Permalink
Add eig_vol argument to EigenModeSource class constructor (#2767)
Browse files Browse the repository at this point in the history
* add eig_vol argument to EigenModeSource class constructor

* define eig_vol within add_source rather than constructor

* fixes
  • Loading branch information
oskooi authored Jan 25, 2024
1 parent d97b6a2 commit 46c7920
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions python/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ def __init__(
volume=None,
eig_lattice_size=None,
eig_lattice_center=None,
eig_vol=None,
component=mp.ALL_COMPONENTS,
direction=mp.AUTOMATIC,
eig_band=1,
Expand Down Expand Up @@ -551,12 +552,13 @@ def __init__(
optional `eig_lattice_size` and `eig_lattice_center`, which define a volume
(which must enclose `size` and `center`) that is used for the unit cell in MPB
with the dielectric function ε taken from the corresponding region in the Meep
simulation.
simulation. Alternatively, a volume object `eig_vol` can be specified.
"""

super().__init__(src, component, center, volume, **kwargs)
self.eig_lattice_size = eig_lattice_size
self.eig_lattice_center = eig_lattice_center
self.eig_vol = eig_vol
self.component = component
self.direction = direction
self.eig_band = eig_band
Expand Down Expand Up @@ -643,12 +645,13 @@ def add_source(self, sim):
else:
direction = self.direction

eig_vol = mp.Volume(
self.eig_lattice_center,
self.eig_lattice_size,
sim.dimensions,
is_cylindrical=sim.is_cylindrical,
).swigobj
if self.eig_vol is None:
self.eig_vol = mp.Volume(
self.eig_lattice_center,
self.eig_lattice_size,
sim.dimensions,
is_cylindrical=sim.is_cylindrical,
)

if isinstance(self.eig_band, mp.DiffractedPlanewave):
eig_band = 1
Expand All @@ -663,7 +666,7 @@ def add_source(self, sim):
self.src.swigobj,
direction,
where,
eig_vol,
self.eig_vol.swigobj,
eig_band,
mp.py_v3_to_vec(
sim.dimensions, self.eig_kpoint, is_cylindrical=sim.is_cylindrical
Expand Down

0 comments on commit 46c7920

Please sign in to comment.