(sim: Simulation, output_plane: Volume)
| 247 | # to check if the user accidentally specifies a plane that stretches beyond the |
| 248 | # simulation domain. |
| 249 | def get_2D_dimensions(sim: Simulation, output_plane: Volume) -> Tuple[Vector3, Vector3]: |
| 250 | # Pull correct plane from user |
| 251 | if output_plane: |
| 252 | plane_center, plane_size = (output_plane.center, output_plane.size) |
| 253 | elif sim.output_volume: |
| 254 | plane_center, plane_size = mp.get_center_and_size(sim.output_volume) |
| 255 | else: |
| 256 | if (sim.dimensions == mp.CYLINDRICAL) or sim.is_cylindrical: |
| 257 | plane_center, plane_size = ( |
| 258 | sim.geometry_center + Vector3(sim.cell_size.x / 2), |
| 259 | sim.cell_size, |
| 260 | ) |
| 261 | else: |
| 262 | plane_center, plane_size = (sim.geometry_center, sim.cell_size) |
| 263 | plane_volume = Volume(center=plane_center, size=plane_size) |
| 264 | |
| 265 | if plane_size.x != 0 and plane_size.y != 0 and plane_size.z != 0: |
| 266 | raise ValueError("Plane volume must be 2D (a plane).") |
| 267 | if (sim.dimensions == mp.CYLINDRICAL) or sim.is_cylindrical: |
| 268 | center = sim.geometry_center + Vector3(sim.cell_size.x / 2) |
| 269 | check_volume = Volume(center=center, size=sim.cell_size) |
| 270 | else: |
| 271 | check_volume = Volume(center=sim.geometry_center, size=sim.cell_size) |
| 272 | vertices = intersect_volume_volume(check_volume, plane_volume) |
| 273 | |
| 274 | if len(vertices) == 0: |
| 275 | raise ValueError( |
| 276 | "The specified user volume is completely outside of the simulation domain." |
| 277 | ) |
| 278 | |
| 279 | intersection_vol = Volume(vertices=vertices) |
| 280 | |
| 281 | if (intersection_vol.size != plane_volume.size) or ( |
| 282 | intersection_vol.center != plane_volume.center |
| 283 | ): |
| 284 | warnings.warn( |
| 285 | "The specified user volume is larger than the simulation domain and has been truncated." |
| 286 | ) |
| 287 | |
| 288 | sim_center, sim_size = (intersection_vol.center, intersection_vol.size) |
| 289 | return sim_center, sim_size |
| 290 | |
| 291 | |
| 292 | def box_vertices( |
no test coverage detected