Plots the radiation pattern in 3d Cartesian coordinates. Args: radial_flux: radial flux of the far fields at each angle.
(radial_flux: np.ndarray)
| 54 | |
| 55 | |
| 56 | def plot_radiation_pattern_3d(radial_flux: np.ndarray): |
| 57 | """Plots the radiation pattern in 3d Cartesian coordinates. |
| 58 | |
| 59 | Args: |
| 60 | radial_flux: radial flux of the far fields at each angle. |
| 61 | """ |
| 62 | phis = np.linspace(0, 2 * np.pi, NUM_FARFIELD_PTS) |
| 63 | |
| 64 | xs = np.zeros((NUM_FARFIELD_PTS, NUM_FARFIELD_PTS)) |
| 65 | ys = np.zeros((NUM_FARFIELD_PTS, NUM_FARFIELD_PTS)) |
| 66 | zs = np.zeros((NUM_FARFIELD_PTS, NUM_FARFIELD_PTS)) |
| 67 | |
| 68 | for i, theta in enumerate(farfield_angles): |
| 69 | for j, phi in enumerate(phis): |
| 70 | xs[i, j] = radial_flux[i] * np.sin(theta) * np.cos(phi) |
| 71 | ys[i, j] = radial_flux[i] * np.sin(theta) * np.sin(phi) |
| 72 | zs[i, j] = radial_flux[i] * np.cos(theta) |
| 73 | |
| 74 | fig, ax = plt.subplots(subplot_kw={"projection": "3d"}, figsize=(6, 6)) |
| 75 | ax.plot_surface(xs, ys, zs, cmap="inferno") |
| 76 | ax.set_title("radiation pattern in 3d") |
| 77 | ax.set_box_aspect((np.amax(xs), np.amax(ys), np.amax(zs))) |
| 78 | ax.set_zlabel("radial flux (a.u.)") |
| 79 | ax.set(xticklabels=[], yticklabels=[]) |
| 80 | |
| 81 | if mp.am_master(): |
| 82 | fig.savefig( |
| 83 | "disc_radiation_pattern_3d.png", |
| 84 | dpi=150, |
| 85 | bbox_inches="tight", |
| 86 | ) |
| 87 | |
| 88 | |
| 89 | def radiation_pattern(sim: mp.Simulation, n2f_mon: mp.DftNear2Far) -> np.ndarray: |
no test coverage detected