def test_plot_3d_current_loops_fail(): x = np.cos(np.linspace(0, 2 * np.pi)) y = np.sin(np.linspace(0, 2 * np.pi)) z = np.zeros_like(y) loops = [np.array([x, y, z]).T, 2 * np.array([x, y, z]).T] viz.plot_3d_current_loops(loops, tube_radius=0.01, colors="boop")
#%% # Plot coil windings and target points N_contours = 6 loops = scalar_contour(coil.mesh, coil.s.vert, N_contours=N_contours) if PLOT: f = mlab.figure(None, bgcolor=(1, 1, 1), fgcolor=(0.5, 0.5, 0.5), size=(650, 750)) mlab.clf() plot_3d_current_loops(loops, colors="auto", figure=f) # B_target = coil.B_coupling(target_points) @ coil.s # mlab.quiver3d(*target_points.T, *B_target.T, mode="arrow", scale_factor=1) f.scene.isometric_view() # f.scene.camera.zoom(0.95) if SAVE_FIGURES: mlab.savefig( SAVE_DIR + "biplanar_loops.png", figure=f, magnification=4, ) mlab.close()
8.52196480605194e-08, ] scene1.scene.camera.view_angle = 30.0 scene1.scene.camera.view_up = [1.0, 0.0, 0.0] scene1.scene.camera.clipping_range = [ 2.948955346473114, 3.40878670176758 ] scene1.scene.camera.compute_view_plane_normal() scene1.scene.render() scene1.scene.anti_aliasing_frames = 20 scene1.scene.magnification = 2 fig = mlab.figure(bgcolor=(1, 1, 1), size=(400, 400)) fig = plot_3d_current_loops(contours1, tube_radius=0.005, colors=(0.9, 0.9, 0.9), figure=fig) m = abs(s1).max() mask = mesh1.triangles_center[:, 1] > 0 faces1 = mesh1.faces[mask] surf = mlab.triangular_mesh(*mesh1.vertices.T, faces1, scalars=s1.vert, vmin=-m, vmax=m, colormap="seismic") setscene(surf, 1) fig = mlab.figure(bgcolor=(1, 1, 1), size=(400, 400)) fig = plot_3d_current_loops(contours2, tube_radius=0.005,
#%% # Plot coil windings and target points loops = scalar_contour(coil.mesh, coil.s.vert, N_contours=6) # loops = [simplify_contour(loop, min_edge=1e-2, angle_threshold=2e-2, smooth=True) for loop in loops] # loops = [loop for loop in loops if loop is not None] if PLOT: f = mlab.figure(None, bgcolor=(1, 1, 1), fgcolor=(0.5, 0.5, 0.5), size=(600, 500)) mlab.clf() plot_3d_current_loops(loops, colors="auto", figure=f, tube_radius=0.005) B_target = coil.B_coupling(target_points) @ coil.s mlab.quiver3d(*target_points.T, *B_target.T) # plot_data_on_vertices(shield.mesh, shield.induced_s.vert, ncolors=256, figure=f, opacity=0.5, cull_back=True) # plot_data_on_vertices(shield.mesh, shield.induced_s.vert, ncolors=256, figure=f, opacity=1, cull_front=True) shield.plot_mesh( representation="surface", opacity=0.5, cull_back=True, color=(0.8, 0.8, 0.8), figure=f, )
def test_plot_3d_current_loops(): x = np.cos(np.linspace(0, 2 * np.pi)) y = np.sin(np.linspace(0, 2 * np.pi)) z = np.zeros_like(y) loops = [np.array([x, y, z]).T, 2 * np.array([x, y, z]).T] viz.plot_3d_current_loops(loops, tube_radius=0.01) viz.plot_3d_current_loops(loops, tube_radius=0.01, colors="auto") f = mlab.figure() viz.plot_3d_current_loops(loops, tube_radius=0.01, figure=f) viz.plot_3d_current_loops(loops, tube_radius=0.01, colors=None) viz.plot_3d_current_loops(loops, tube_radius=0.01, colors=(1, 0, 0)) viz.plot_3d_current_loops(loops, tube_radius=0.01, colors=[(1, 0, 0)] * 2) # Longest segment is the one closing the loop x = np.cos(np.linspace(0, 2 * np.pi))[:-1] y = np.sin(np.linspace(0, 2 * np.pi))[:-1] z = np.zeros_like(y) loops = [np.array([x, y, z]).T, 2 * np.array([x, y, z]).T] viz.plot_3d_current_loops(loops, tube_radius=0.01)