MCPcopy Create free account
hub / github.com/NanoComp/meep / main

Function main

python/examples/ring.py:5–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3
4
5def main():
6 n = 3.4 # index of waveguide
7 w = 1 # width of waveguide
8 r = 1 # inner radius of ring
9 pad = 4 # padding between waveguide and edge of PML
10 dpml = 2 # thickness of PML
11 sxy = 2 * (r + w + pad + dpml) # cell size
12
13 # Create a ring waveguide by two overlapping cylinders - later objects
14 # take precedence over earlier objects, so we put the outer cylinder first.
15 # and the inner (air) cylinder second.
16
17 c1 = mp.Cylinder(radius=r + w, material=mp.Medium(index=n))
18 c2 = mp.Cylinder(radius=r)
19
20 # If we don't want to excite a specific mode symmetry, we can just
21 # put a single point source at some arbitrary place, pointing in some
22 # arbitrary direction. We will only look for Ez-polarized modes.
23
24 fcen = 0.15 # pulse center frequency
25 df = 0.1 # pulse width (in frequency)
26
27 src = mp.Source(mp.GaussianSource(fcen, fwidth=df), mp.Ez, mp.Vector3(r + 0.1))
28
29 sim = mp.Simulation(
30 cell_size=mp.Vector3(sxy, sxy),
31 geometry=[c1, c2],
32 sources=[src],
33 resolution=10,
34 symmetries=[mp.Mirror(mp.Y)],
35 boundary_layers=[mp.PML(dpml)],
36 )
37
38 sim.run(
39 mp.at_beginning(mp.output_epsilon),
40 mp.after_sources(mp.Harminv(mp.Ez, mp.Vector3(r + 0.1), fcen, df)),
41 until_after_sources=300,
42 )
43
44 # Output fields for one period at the end. (If we output
45 # at a single time, we might accidentally catch the Ez field when it is
46 # almost zero and get a distorted view.)
47 sim.run(mp.at_every(1 / fcen / 20, mp.output_efield_z), until=1 / fcen)
48
49
50if __name__ == "__main__":

Callers 1

ring.pyFile · 0.70

Calls 1

runMethod · 0.95

Tested by

no test coverage detected