CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
| Download
Project: JFM-23-1215
Views: 60Visibility: Unlisted (only visible to those who know the link)
Image: ubuntu2004-eolKernel: Python 3 (system-wide)
In [3]:
import k3d import scipy.io as sio import matplotlib.pyplot as plt import numpy as np
In [4]:
import colorama from colorama import Fore from itertools import chain import random import math
In [5]:
# Read data for snapshot A
In [6]:
Phi= np.loadtxt("../Data/Phi_A.txt") Pi = np.loadtxt("../Data/Pi_A.txt") QQ = np.loadtxt("../Data/Q_A.txt") RR = np.loadtxt("../Data/R_A.txt")
In [7]:
Q = np.reshape(QQ, [50, 50, 50]) R = np.reshape(RR, [50, 50, 50]) E = np.reshape(Phi, [50, 50, 50]) P = np.reshape(Pi, [50, 50, 50])
In [8]:
dx=2*math.pi/8192 npoints3D = 50 Factor = 3 x_begin = 1.906947 - Factor *dx * npoints3D/2 y_begin = 3.930307 - Factor *dx * npoints3D/2 z_begin = 1.438494 - Factor *dx * npoints3D/2 x_ = np.linspace(x_begin, x_begin + (npoints3D-1)*Factor*dx, npoints3D) y_ = np.linspace(y_begin, y_begin + (npoints3D-1)*Factor*dx, npoints3D) z_ = np.linspace(z_begin, z_begin + (npoints3D-1)*Factor*dx, npoints3D)
In [9]:
#Creates a K3D isosurface object to show vortices using Q isosurface_A = k3d.marching_cubes(Q.astype(np.float32),xmin=np.min(x_)/2,xmax=np.max(x_)/2, ymin=np.min(y_)/2,ymax=np.max(y_)/2, zmin=np.min(z_)/2, zmax=np.max(z_)/2, level=20, color = 0xf4ea0e, name = 'isotropic: Q Positive', opacity = 0.7) #Creates a K3D isosurface object to show vortices using R isosurface2_A = k3d.marching_cubes(R.astype(np.float32),xmin=np.min(x_)/2,xmax=np.max(x_)/2, ymin=np.min(y_)/2,ymax=np.max(y_)/2, zmin=np.min(z_)/2, zmax=np.max(z_)/2, level=25, color = 0x000000, name = 'isotropic: R Positive', opacity = 0.4) #Creates a K3D isosurface object to show vortices using Phi isosurface3_A = k3d.marching_cubes(E.astype(np.float32),xmin=np.min(x_)/2,xmax=np.max(x_)/2, ymin=np.min(y_)/2,ymax=np.max(y_)/2, zmin=np.min(z_)/2, zmax=np.max(z_)/2, level=-60, color = 0x109df4, name = 'inverse cascade Phi', opacity = 0.4) #Creates a K3D isosurface object to show vortices using Pi isosurface4_A = k3d.marching_cubes(P.astype(np.float32),xmin=np.min(x_)/2,xmax=np.max(x_)/2, ymin=np.min(y_)/2,ymax=np.max(y_)/2, zmin=np.min(z_)/2, zmax=np.max(z_)/2, level=-20, color = 0x10f4e5, name = 'inverse cascade Pi', opacity = 0.4)
In [10]:
# Generate html for Figure 11 (a) plot = k3d.plot() plot.camera_auto_fit = True plot += isosurface_A plot += isosurface2_A plot += isosurface3_A plot.axes = ['x_1','x_2','x_3'] plot.display() plot.get_snapshot() with open('Figure11_a.html','w') as fp: fp.write(plot.get_snapshot())
In [11]:
# Generate html for Figure 11 (c) plot = k3d.plot() plot.camera_auto_fit = True plot += isosurface_A plot += isosurface2_A plot += isosurface4_A plot.axes = ['x_1','x_2','x_3'] plot.display() plot.get_snapshot() with open('Figure11_c.html','w') as fp: fp.write(plot.get_snapshot())
In [12]:
# Read data for snapshot B
In [13]:
Phi= np.loadtxt("../Data/Phi_B.txt") Pi = np.loadtxt("../Data/Pi_B.txt") QQ = np.loadtxt("../Data/Q_B.txt") RR = np.loadtxt("../Data/R_B.txt")
In [14]:
Q = np.reshape(QQ, [50, 50, 50]) R = np.reshape(RR, [50, 50, 50]) E = np.reshape(Phi, [50, 50, 50]) P = np.reshape(Pi, [50, 50, 50])
In [15]:
dx=2*math.pi/8192 npoints3D = 50 Factor = 3 x_begin = 3.869077 - Factor*dx * npoints3D/2 y_begin = 2.402073 - Factor*dx * npoints3D/2 z_begin = 5.798486 - Factor*dx * npoints3D/2 x_2 = np.linspace(x_begin, x_begin + (npoints3D-1)*Factor*dx, npoints3D) y_2 = np.linspace(y_begin, y_begin + (npoints3D-1)*Factor*dx, npoints3D) z_2 = np.linspace(z_begin, z_begin + (npoints3D-1)*Factor*dx, npoints3D)
In [16]:
#Creates a K3D isosurface object to show vortices using Q isosurface_B = k3d.marching_cubes(Q.astype(np.float32),xmin=np.min(x_2)/2,xmax=np.max(x_2)/2, ymin=np.min(y_2)/2,ymax=np.max(y_2)/2, zmin=np.min(z_2)/2, zmax=np.max(z_2)/2, level=20, color = 0xf4ea0e, name = 'isotropic: Q Positive', opacity = 0.7) #Creates a K3D isosurface object to show vortices using R isosurface2_B = k3d.marching_cubes(R.astype(np.float32),xmin=np.min(x_2)/2,xmax=np.max(x_2)/2, ymin=np.min(y_2)/2,ymax=np.max(y_2)/2, zmin=np.min(z_2)/2, zmax=np.max(z_2)/2, level=25, color = 0x000000, name = 'isotropic: R Positive', opacity = 0.4) #Creates a K3D isosurface object to show vortices using Phi isosurface3_B = k3d.marching_cubes(E.astype(np.float32),xmin=np.min(x_2)/2,xmax=np.max(x_2)/2, ymin=np.min(y_2)/2,ymax=np.max(y_2)/2, zmin=np.min(z_2)/2, zmax=np.max(z_2)/2, level=-60, color = 0x109df4, name = 'inverse cascade Phi', opacity = 0.4) #Creates a K3D isosurface object to show vortices using Pi isosurface4_B = k3d.marching_cubes(P.astype(np.float32),xmin=np.min(x_2)/2,xmax=np.max(x_2)/2, ymin=np.min(y_2)/2,ymax=np.max(y_2)/2, zmin=np.min(z_2)/2, zmax=np.max(z_2)/2, level=-20, color = 0x10f4e5, name = 'inverse cascade Pi', opacity = 0.4)
In [17]:
# Generate html for Figure 11 (b) plot = k3d.plot() plot.camera_auto_fit = True plot += isosurface_B plot += isosurface2_B plot += isosurface3_B plot.axes = ['x_1','x_2','x_3'] plot.display() plot.get_snapshot() with open('Figure11_b.html','w') as fp: fp.write(plot.get_snapshot())
In [18]:
# Generate html for Figure 11 (d) plot = k3d.plot() plot.camera_auto_fit = True plot += isosurface_B plot += isosurface2_B plot += isosurface4_B plot.axes = ['x_1','x_2','x_3'] plot.display() plot.get_snapshot() with open('Figure11_d.html','w') as fp: fp.write(plot.get_snapshot())