File: absorber-1d.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 (38 lines) | stat: -rw-r--r-- 1,195 bytes parent folder | download | duplicates (8)
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
from __future__ import division

import argparse
import meep as mp
from meep.materials import Al


def main(args):

    resolution = 40
    cell_size = mp.Vector3(z=10)

    boundary_layers = [mp.PML(1, direction=mp.Z) if args.pml else mp.Absorber(1, direction=mp.Z)]

    sources = [mp.Source(src=mp.GaussianSource(1 / 0.803, fwidth=0.1),
                         center=mp.Vector3(),
                         component=mp.Ex)]

    def print_stuff(sim):
        p = sim.get_field_point(mp.Ex, mp.Vector3())
        print("ex:, {}, {}".format(sim.meep_time(), p.real))

    sim = mp.Simulation(cell_size=cell_size,
                        resolution=resolution,
                        dimensions=1,
                        default_material=Al,
                        boundary_layers=boundary_layers,
                        sources=sources)

    sim.run(mp.at_every(10, print_stuff),
            until_after_sources=mp.stop_when_fields_decayed(50, mp.Ex, mp.Vector3(), 1e-6))


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('-pml', action='store_true', default=False, help='Use PML as boundary layer')
    args = parser.parse_args()
    main(args)