File: cyl-ellipsoid.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 (42 lines) | stat: -rw-r--r-- 1,247 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
39
40
41
42
from __future__ import division

import meep as mp


def main():

    c = mp.Cylinder(radius=3, material=mp.Medium(index=3.5))
    e = mp.Ellipsoid(size=mp.Vector3(1, 2, mp.inf))

    src_cmpt = mp.Hz
    sources = mp.Source(src=mp.GaussianSource(1, fwidth=0.1), component=src_cmpt, center=mp.Vector3())

    if src_cmpt == mp.Ez:
        symmetries = [mp.Mirror(mp.X), mp.Mirror(mp.Y)]

    if src_cmpt == mp.Hz:
        symmetries = [mp.Mirror(mp.X, -1), mp.Mirror(mp.Y, -1)]

    sim = mp.Simulation(cell_size=mp.Vector3(10, 10),
                        geometry=[c, e],
                        boundary_layers=[mp.PML(1.0)],
                        sources=[sources],
                        symmetries=symmetries,
                        resolution=100)

    def print_stuff(sim_obj):
        v = mp.Vector3(4.13, 3.75, 0)
        p = sim.get_field_point(src_cmpt, v)
        print("t, Ez: {} {}+{}i".format(sim.round_time(), p.real, p.imag))

    sim.run(mp.at_beginning(mp.output_epsilon),
            mp.at_every(0.25, print_stuff),
            mp.at_end(print_stuff),
            mp.at_end(mp.output_efield_z),
            until=23)

    print("stopped at meep time = {}".format(sim.round_time()))


if __name__ == '__main__':
    main()