Plots the radiation pattern in 3d Cartesian coordinates. Args: radial_flux: radial flux of the far fields in polar coordinates.
(radial_flux: np.ndarray)
| 62 | |
| 63 | |
| 64 | def plot_radiation_pattern_3d(radial_flux: np.ndarray): |
| 65 | """Plots the radiation pattern in 3d Cartesian coordinates. |
| 66 | |
| 67 | Args: |
| 68 | radial_flux: radial flux of the far fields in polar coordinates. |
| 69 | """ |
| 70 | x_coord = np.zeros((NUM_POLAR, NUM_AZIMUTH)) |
| 71 | y_coord = np.zeros((NUM_POLAR, NUM_AZIMUTH)) |
| 72 | z_coord = np.zeros((NUM_POLAR, NUM_AZIMUTH)) |
| 73 | |
| 74 | for i in range(NUM_POLAR): |
| 75 | for j in range(NUM_AZIMUTH): |
| 76 | x_coord[i, j] = ( |
| 77 | radial_flux[i] * np.sin(polar_rad[i]) * np.cos(azimuth_rad[j]) |
| 78 | ) |
| 79 | y_coord[i, j] = ( |
| 80 | radial_flux[i] * np.sin(polar_rad[i]) * np.sin(azimuth_rad[j]) |
| 81 | ) |
| 82 | z_coord[i, j] = radial_flux[i] * np.cos(polar_rad[i]) |
| 83 | |
| 84 | fig, ax = plt.subplots(subplot_kw={"projection": "3d"}, figsize=(6, 6)) |
| 85 | ax.plot_surface(x_coord, y_coord, z_coord, cmap="inferno") |
| 86 | ax.set_title("radiation pattern in 3d") |
| 87 | ax.set_box_aspect((np.amax(x_coord), np.amax(y_coord), np.amax(z_coord))) |
| 88 | ax.set_zlabel("radial flux (a.u.)") |
| 89 | ax.set(xticklabels=[], yticklabels=[]) |
| 90 | |
| 91 | if mp.am_master(): |
| 92 | fig.savefig( |
| 93 | "disc_radiation_pattern_3d.png", |
| 94 | dpi=150, |
| 95 | bbox_inches="tight", |
| 96 | ) |
| 97 | |
| 98 | |
| 99 | def radiation_pattern(sim: mp.Simulation, n2f_mon: mp.DftNear2Far) -> np.ndarray: |
no test coverage detected