Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Notebooks supporting the J. Fluid Mech. submission "Turbulent mixed convection in vertical and horizontal channels"

206 views
unlisted
ubuntu2204
Kernel: Python 3 (ipykernel)

import numpy as np import h5py import matplotlib as mpl import matplotlib.pyplot as plt import seaborn as sns import cmocean # Aesthetics sns.set_theme() sns.set_style('ticks') sns.set_context('paper') plt.rc('mathtext', fontset='stix') plt.rc('font', family='serif')
simnames = ['RB', 'VC', 'P-RB', 'P-VC']
def y_colour(x): cmap = sns.color_palette('crest', as_cmap=True) return cmap(x*2)
fig, axs = plt.subplots(2,2, layout='constrained', sharex=True, figsize=(5.2,4.6), dpi=150) with h5py.File('../data/spectra.h5','r') as f: for n, grp in enumerate(simnames): kx = f[grp+'/kx'][:] kz = f[grp+'/kz'][:] Ptx = f[grp+'/Phi_TT_kx'][()] Ptz = f[grp+'/Phi_TT_kz'][()] y = f[grp+'/y'][:] nyh = y.size//2 # Set number of y-coordinates to plot nc = 8 ixs = np.arange(1,nc+1)*nyh//nc - 1 ax = axs[n % 2, n//2] for i in ixs: ax.semilogx(kx, kx*Ptx[:,i]/kz[1], '--', color=y_colour(y[i]), zorder=2.5) ax.plot(kz, kz*Ptz[:,i]/kz[1], color=y_colour(y[i])) for ax in axs.flatten(): ax.ticklabel_format(axis='y', scilimits=(0,0), useMathText=True) ax.set_xlim([kz[1]/2, kz[-1]]) # Add legend ax = axs[0,1] ax.plot(1, 1, '--', color=y_colour(0.5), label='$k_x$') ax.plot(1, 1, color=y_colour(0.5), label='$k_z$') ax.legend(loc = 'center right') # Add standalone colour bar cmap = sns.color_palette('crest', as_cmap=True) cb = fig.colorbar(mpl.cm.ScalarMappable(norm=mpl.colors.Normalize(0, 0.5), cmap=cmap), ax=axs, orientation='horizontal', label='$y/H$', shrink=0.5) for i in ixs: cb.ax.axvline(y[i], c='k') # Set limits and aesthetics for ax in axs.flatten(): ax.grid(True, alpha=0.5) axs[0,0].set_ylim([0,4e-3]) axs[0,1].set_ylim([0,2e-2]) axs[1,0].set_ylim([0,4e-3]) axs[1,1].set_ylim([0,4e-3]) for ax in axs[1,:]: ax.set_xlabel('$kH$') for ax in axs[:,0]: ax.set_ylabel('$k \\Phi_{\\theta \\theta}$') axs[0,0].set_title('Natural ($Ri=\\infty$)') axs[0,1].set_title('Mixed ($Ri=1$)') # Add axis labels names = ['RB', 'P-RB','VC', 'P-VC'] lbls = ['$(a)$', '$(b)$', '$(c)$', '$(d)$'] for n, lbl in enumerate(lbls): axs[n//2,n%2].annotate(lbl, (0.02, 0.97), ha='left', va='top', xycoords='axes fraction') axs[n//2,n%2].annotate(names[n], (0.98, 0.97), ha='right', va='top', xycoords='axes fraction') # fig.savefig('Tspectra_1e7.pdf') plt.show()
Image in a Jupyter notebook