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

Function tri_rods

python/examples/mpb_data_analysis.py:14–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12
13
14def tri_rods():
15 # Import the ModeSolver defined in the mpb_tri_rods.py example
16 from mpb_tri_rods import ms as tr_ms
17
18 efields = []
19
20 # Band function to collect the efields
21 def get_efields(tr_ms, band):
22 efields.append(tr_ms.get_efield(band))
23
24 tr_ms.run_tm(
25 mpb.output_at_kpoint(
26 mp.Vector3(1 / -3, 1 / 3), mpb.fix_efield_phase, get_efields
27 )
28 )
29
30 # Create an MPBData instance to transform the efields
31 md = mpb.MPBData(rectify=True, resolution=32, periods=3)
32
33 converted = []
34 for f in efields:
35 # Get just the z component of the efields
36 f = f[..., 0, 2]
37 converted.append(md.convert(f))
38
39 tr_ms.run_te()
40
41 eps = tr_ms.get_epsilon()
42 plt.imshow(eps.T, interpolation="spline36", cmap="binary")
43 plt.axis("off")
44 plt.show()
45
46 md = mpb.MPBData(rectify=True, resolution=32, periods=3)
47 rectangular_data = md.convert(eps)
48 plt.imshow(rectangular_data.T, interpolation="spline36", cmap="binary")
49 plt.axis("off")
50 plt.show()
51
52 for i, f in enumerate(converted):
53 plt.subplot(331 + i)
54 plt.contour(rectangular_data.T, cmap="binary")
55 plt.imshow(np.real(f).T, interpolation="spline36", cmap="RdBu", alpha=0.9)
56 plt.axis("off")
57
58 plt.show()
59
60
61def diamond():

Callers 1

Calls 3

convertMethod · 0.95
axisMethod · 0.80
get_epsilonMethod · 0.45

Tested by

no test coverage detected