File: wvg_src.py

package info (click to toggle)
meep-openmpi 1.7.0-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 25,828 kB
  • sloc: cpp: 27,370; python: 10,574; lisp: 1,213; makefile: 437; sh: 28
file content (48 lines) | stat: -rw-r--r-- 1,426 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from __future__ import division

import unittest

import meep as mp


class TestWvgSrc(unittest.TestCase):

    def setUp(self):

        cell = mp.Vector3(16, 8)

        geometry = [
            mp.Block(center=mp.Vector3(), size=mp.Vector3(mp.inf, 1, mp.inf),
                     material=mp.Medium(epsilon=12)),
            mp.Block(center=mp.Vector3(y=0.3), size=mp.Vector3(mp.inf, 0.1, mp.inf),
                     material=mp.Medium())
        ]

        sources = [
            mp.EigenModeSource(src=mp.ContinuousSource(0.15), size=mp.Vector3(y=6),
                               center=mp.Vector3(x=-5), component=mp.Dielectric,
                               eig_parity=mp.ODD_Z)
        ]

        pml_layers = [mp.PML(1.0)]

        self.sim = mp.Simulation(
            cell_size=cell,
            geometry=geometry,
            sources=sources,
            boundary_layers=pml_layers,
            force_complex_fields=True,
            resolution=10
        )

    def test_wvg_src(self):
        self.sim.run(until=200)

        flux1 = self.sim.flux_in_box(mp.X, mp.Volume(center=mp.Vector3(-6.0), size=mp.Vector3(1.8, 6)))
        flux2 = self.sim.flux_in_box(mp.X, mp.Volume(center=mp.Vector3(6.0), size=mp.Vector3(1.8, 6)))

        self.assertAlmostEqual(flux1 / -1.8, 7.125912849303947e-5)
        self.assertAlmostEqual(flux2 / 1.8, 0.2898392510553291)

if __name__ == '__main__':
    unittest.main()