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

Function radiation_pattern

python/examples/disc_extraction_efficiency.py:89–122  ·  view source on GitHub ↗

Computes the radiation pattern from the near fields. Args: sim: a `Simulation` object. n2f_mon: a `DftNear2Far` object returned by `Simulation.add_near2far`. Returns: The radiation pattern (radial flux at each angle) as a 1d array.

(sim: mp.Simulation, n2f_mon: mp.DftNear2Far)

Source from the content-addressed store, hash-verified

87
88
89def radiation_pattern(sim: mp.Simulation, n2f_mon: mp.DftNear2Far) -> np.ndarray:
90 """Computes the radiation pattern from the near fields.
91
92 Args:
93 sim: a `Simulation` object.
94 n2f_mon: a `DftNear2Far` object returned by `Simulation.add_near2far`.
95
96 Returns:
97 The radiation pattern (radial flux at each angle) as a 1d array.
98 """
99 e_field = np.zeros((NUM_FARFIELD_PTS, 3), dtype=np.complex128)
100 h_field = np.zeros((NUM_FARFIELD_PTS, 3), dtype=np.complex128)
101 for n in range(NUM_FARFIELD_PTS):
102 far_field = sim.get_farfield(
103 n2f_mon,
104 mp.Vector3(
105 FARFIELD_RADIUS_UM * math.sin(farfield_angles[n]),
106 0,
107 FARFIELD_RADIUS_UM * math.cos(farfield_angles[n]),
108 ),
109 GREENCYL_TOL,
110 )
111 e_field[n, :] = [far_field[j] for j in range(3)]
112 h_field[n, :] = [far_field[j + 3] for j in range(3)]
113
114 flux_x = np.real(
115 np.conj(e_field[:, 1]) * h_field[:, 2] - np.conj(e_field[:, 2]) * h_field[:, 1]
116 )
117 flux_z = np.real(
118 np.conj(e_field[:, 0]) * h_field[:, 1] - np.conj(e_field[:, 1]) * h_field[:, 0]
119 )
120 flux_r = np.sqrt(np.square(flux_x) + np.square(flux_z))
121
122 return flux_r
123
124
125def radiation_pattern_flux(radial_flux: np.ndarray) -> float:

Callers 1

dipole_in_discFunction · 0.70

Calls 2

get_farfieldMethod · 0.80
conjMethod · 0.45

Tested by

no test coverage detected