File: wvg_src.py

package info (click to toggle)
meep-mpi-default 1.17.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 51,672 kB
  • sloc: cpp: 29,881; python: 17,210; lisp: 1,225; makefile: 477; sh: 249; ansic: 133; javascript: 5
file content (49 lines) | stat: -rw-r--r-- 1,429 bytes parent folder | download | duplicates (3)
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
49
from __future__ import division

import unittest
import sys

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.775216564842667e-03)
        self.assertAlmostEqual(flux2, 7.215785537102116e+00)

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