Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Authors: Samvit Kumar, Simon Toedtli, Tamer Zaki, Gregory Eyink Keywords: Wall-bounded turbulence, Vorticity dynamics, Conditional Eddies

71 views
unlisted
ubuntu2204
Kernel: Python 3 (system-wide)
import k3d import scipy.io as sio import numpy as np from k3d import matplotlib_color_maps j_values = [47, 54, 71, 105, 130] # Values of j to process green_dot_positions = [39, 53, 93, 197, 298] # Corresponding green dot positions for j, gdot in zip(j_values, green_dot_positions): filename = f'eddy_isosurf_stream_j_{j:03d}.mat' temp1 = sio.loadmat(filename) a = temp1['streamlineArray1'] # Extract the 3D array n1, n2, n3 = a.shape indices = temp1['indices1'] vertices = temp1['vertices1'] c = temp1['faceColor1'] plt_mesh = k3d.mesh(vertices, indices, color_map=matplotlib_color_maps.PiYG_r, attribute=c, color_range=[-0.1, 0.1], side='double') green_dot = k3d.points(positions=np.array([[0, 0, gdot]], dtype=np.float32), point_size=5.0, color=0x00FF00) plot = k3d.plot(grid=(-600, -200, 0, 600, 200, 300), axes=['z^+', 'x^+', 'y^+']) plot.camera_auto_fit = True plot += plt_mesh plot += green_dot # Loop to add streamlines for i in range(n3): x = a[:, 0, i] # Extract x-coordinates for streamline i y = a[:, 1, i] # Extract y-coordinates for streamline i z = a[:, 2, i] # Extract z-coordinates for streamline i # Ensure x, y, z have the same length if len(x) == len(y) == len(z): streamline = np.column_stack((x, y, z)) # Stack into (N,3) format plot += k3d.line(streamline, width=2.0, color=0x000000) # Black streamline else: print(f"Skipping streamline {i} in j={j} due to inconsistent dimensions: x={len(x)}, y={len(y)}, z={len(z)}") # Save snapshot output_filename = f'eddy_streamline_outflow_yplus_{gdot:03d}.html' with open(output_filename, 'w') as fp: fp.write(plot.get_snapshot()) print(f"Saved plot for j={j} with green dot at {gdot} to {output_filename}")
Saved plot for j=47 with green dot at 39 to eddy_streamline_outflow_yplus_039.html Saved plot for j=54 with green dot at 53 to eddy_streamline_outflow_yplus_053.html Saved plot for j=71 with green dot at 93 to eddy_streamline_outflow_yplus_093.html Saved plot for j=105 with green dot at 197 to eddy_streamline_outflow_yplus_197.html Saved plot for j=130 with green dot at 298 to eddy_streamline_outflow_yplus_298.html