Skip to content

Commit

Permalink
test case for 2D gaussianbeam
Browse files Browse the repository at this point in the history
  • Loading branch information
hammy4815 committed Dec 14, 2022
1 parent 55f8149 commit a2b24c5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions python/tests/test_gaussianbeam.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class TestGaussianBeamSource(unittest.TestCase):
def gaussian_beam(self, rot_angle):
def gaussian_beam(self, rot_angle, beamfunc=mp.GaussianBeamSource):

s = 14
resolution = 25
Expand All @@ -27,7 +27,7 @@ def gaussian_beam(self, rot_angle):
src_x = 0
src_y = -0.5 * s + dpml + 1.0
sources = [
mp.GaussianBeamSource(
beamfunc(
src=mp.GaussianSource(fcen, fwidth=0.2 * fcen),
center=mp.Vector3(src_x, src_y),
size=mp.Vector3(s),
Expand Down Expand Up @@ -76,10 +76,11 @@ def gaussian_beam(self, rot_angle):
f"ratio of the Gaussian beam energy at the focus over the maximum beam energy for the entire cell: {frac}"
)

self.assertGreater(frac, 0.99)
self.assertGreater(frac, 0.98)

def test_gaussian_beam(self):
self.gaussian_beam(-40)
self.gaussian_beam(-40, mp.GaussianBeam2DSource)
self.gaussian_beam(-40, mp.GaussianBeam3DSource)


if __name__ == "__main__":
Expand Down

0 comments on commit a2b24c5

Please sign in to comment.