ubuntu2204
Kernel: Python 3 (system-wide)
In [54]:
import numpy as np import matplotlib.pyplot as plt import cmocean from matplotlib import cm from matplotlib.colors import ListedColormap, LinearSegmentedColormap import scipy as sp import scipy.special import seaborn as sns import scipy.ndimage from matplotlib.gridspec import GridSpec %matplotlib inline from matplotlib import rc rc('font',**{'family':'sans-serif','sans-serif':['Helvetica'], 'size':20}) rc('text', usetex=True) rc('text.latex', preamble=r'\usepackage{mathrsfs}') from matplotlib.gridspec import GridSpec
In [55]:
RC = {'figure.figsize':(10,5), 'axes.facecolor':'white', 'axes.edgecolor':' .15', 'axes.linewidth':' 1.25', 'axes.grid' : True, 'grid.color': '.8', 'font.size' : 15, "xtick.major.size": 4, "ytick.major.size": 4} plt.rcParams.update(RC) sns.set_palette(sns.color_palette('dark'), n_colors=None, desat=None, color_codes=False)
In [56]:
#Define non-dimensional parameters for the simulation Re = 2.478883e+03 Fr = 1.105914e+00 Ri = 1/((Fr/(2*np.pi)))**2 Pr = 7 ch = 50 #input column height
In [57]:
#Define dimensionless functions f and g from equations (2.14) and (2.15) in the manuscript #These can be easily modified by the user a = 1 b = 0.8 c = 0.9 d = 0.9 def f(x): return 19/8 + 11/8*np.tanh(a*np.log(x)-b) def g(x): return 2 + np.tanh(c*np.log(x)-d)
In [58]:
#Model name model = 'shearr_mixed_all_ch50' data_loc = 'processed_data/test/Pr7_decaying/' output_loc = 'PCNN_eps/'
In [59]:
xdim, zdim = 500, 500
In [0]:
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica'], 'size':13}) gs=GridSpec(3,2, width_ratios=[1,0.2], wspace=0.05, hspace=0.2, left=0, right=0.47) gs2 = GridSpec(3,2, width_ratios=[1,0.2], wspace=0.05, hspace=0.2, left=0.5, right=0.97) t = ['T=0.5', 'T=4', 'T=7.7'] fig=plt.figure(figsize=(10,5)) for i in range(3): # J=j[i] ax1=fig.add_subplot(gs[i,0]) ax1.set_ylabel('$\\mathrm{Input\ point}$') ax2=fig.add_subplot(gs[i,1]) #Get non-local sensitivities with respect to input X for horizontally adjacent input points nonlocal_sens_X = np.reshape(np.load(output_loc+model+'_grads_'+t[i]+'.npy')[:,:,0], (xdim, zdim,ch))[:,100,:].T #normalisation constant norm_X = np.mean(nonlocal_sens_X.T, axis=0).max() ax1.pcolormesh(np.arange(0,xdim), np.linspace(-ch//2,ch//2,ch), scipy.ndimage.gaussian_filter(nonlocal_sens_X,sigma=(1,1))/norm_X, vmin=0,vmax=2, cmap=cmocean.cm.ice, shading='auto', rasterized=True) ax2.plot(np.mean(nonlocal_sens_X.T, axis=0)/norm_X, np.arange(0, ch)) ax2.set_ylim(0,ch) ax2.set_yticklabels([]) ax2.set_xticklabels([]) ax1.set_xticklabels([]) ax1.set_yticks([-20,0,20]) ax2.set_xlim(-0.3,1.1) ax3=fig.add_subplot(gs2[i,0]) ax3.set_yticklabels([]) ax4=fig.add_subplot(gs2[i,1]) #Get non-local sensitivities with respect to input Y for horizontally adjacent input points nonlocal_sens_Y = np.reshape(np.load(output_loc+model+'_grads_'+t[i]+'.npy')[:,:,1], (xdim, zdim,ch))[:,100,:].T norm_Y = np.mean(nonlocal_sens_Y.T, axis=0).max() ax3.pcolormesh(np.arange(0,xdim), np.linspace(-ch//2,ch//2,ch), scipy.ndimage.gaussian_filter(nonlocal_sens_Y,sigma=(1,1))/norm_Y, vmin=0,vmax=2, cmap=cmocean.cm.thermal, shading='auto', rasterized=True) ax4.plot(np.mean(nonlocal_sens_Y.T, axis=0)/norm_Y, np.arange(0, ch), color='tab:orange') ax4.set_ylim(0,ch) ax4.set_xlim(-0.3,1.1) ax4.set_yticklabels([]) ax4.set_xticklabels([]) ax3.set_xticklabels([]) ax2.set_xticks([0,1]) ax4.set_xticks([0,1]) ax1.annotate('$a)$', (-25, 150), annotation_clip=False) ax1.annotate('$b)$', (-25, 90), annotation_clip=False) ax1.annotate('$c)$', (-25, 28), annotation_clip=False) ax1.set_xlabel('$\\mathrm{Horizontally \ adjacent\ inputs}$') ax3.set_xlabel('$\\mathrm{Horizontally \ adjacent\ inputs}$') ax3.annotate('$d)$', (-25, 150), annotation_clip=False) ax3.annotate('$e)$', (-25, 90), annotation_clip=False) ax3.annotate('$f)$', (-25, 28), annotation_clip=False) ax2.set_xlabel('$\\mathrm{Mean}$') ax4.set_xlabel('$\\mathrm{Mean}$') fig.show() final_figs='figures/' plt.savefig(final_figs+'fig7.pdf', dpi=300, bbox_inches='tight')
In [0]: