File: cyl-ellipsoid.py

package info (click to toggle)
meep-openmpi 1.25.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 64,556 kB
  • sloc: cpp: 32,214; python: 27,958; lisp: 1,225; makefile: 505; sh: 249; ansic: 131; javascript: 5
file content (46 lines) | stat: -rw-r--r-- 1,142 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
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(f"t, Ez: {sim.round_time()} {p.real}+{p.imag}i")

    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(f"stopped at meep time = {sim.round_time()}")


if __name__ == "__main__":
    main()