Skip to content

Commit 49baffe

Browse files
author
Paul Mannix
committed
Updated plotting code
1 parent b4facd9 commit 49baffe

File tree

8 files changed

+565
-649
lines changed

8 files changed

+565
-649
lines changed

Gap_Continuation.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def Gap_Vary(Ra_s_new, open_filename, frame):
1111

1212
try:
1313
Ra = f['Checkpoints/Ra_DATA'][frame]
14-
#Ra = f['Bifurcation/Ra_DATA'][frame];
14+
Ra = f['Bifurcation/Ra_DATA'][frame];
1515
except:
1616
Ra = f['Parameters']["Ra"][()]
1717

@@ -25,16 +25,16 @@ def Gap_Vary(Ra_s_new, open_filename, frame):
2525

2626
# ~~~~~~~~~ Interpolate ~~~~~~~~~~~~~~~~~~~
2727
from Matrix_Operators import INTERP_RADIAL, INTERP_THETAS
28-
N_r_n = 32
28+
N_r_n = 25
2929
X = INTERP_RADIAL(N_r_n, N_r, X, d)
30-
N_fm_n = 256
30+
N_fm_n = 128
3131
X = INTERP_THETAS(N_fm_n, N_fm, X)
3232
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3333

3434
print("\n Loading Ra = %e, Ra_s=%e, Pr=%2.5f, Tau=%2.5f, d=%2.5f and resolution N_fm, N_r = %d,%d \n"%(Ra,Ra_s,Pr,Tau,d,N_fm,N_r))
3535

36-
sign = -1
37-
N_steps = 500
36+
sign = 1
37+
N_steps = 100
3838
Y = np.hstack((X, Ra))
3939
kwargs = {"Ra":Ra,"Ra_s":Ra_s_new,"Tau":Tau,"Pr":Pr,"d":d,"N_fm":N_fm_n,"N_r":N_r_n, "symmetric":True}
4040

@@ -53,10 +53,10 @@ def main():
5353

5454
print('Creating a test directory .... \n')
5555

56-
open_filename = "ConvectonL10PlusRas400Ras300_1.h5"
57-
frame = 0
56+
open_filename = "AntiConvectonL10PlusRas175Ras195_0.h5"
57+
frame = -10
5858

59-
for Ras_i in [306.125]:
59+
for Ras_i in [198,199]:
6060
print("\n Ra_s = ",Ras_i)
6161
Gap_Vary(Ras_i, open_filename, frame)
6262

Linear_Problem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ def large_aspect_neutrals():
674674

675675
return None
676676

677-
# Execute main
677+
# Execute main to produce figures 4 and 5, a little slow to run
678678
if __name__ == "__main__":
679679

680680
# %%

Main.py

Lines changed: 96 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from numba import njit
22
import numpy as np
33
import matplotlib.pyplot as plt
4-
from Matrix_Operators import cheb_radial
4+
from Matrix_Operators import cheb_radial, Vecs_to_X, X_to_Vecs
55
import os
66
import time
77
import warnings
@@ -38,6 +38,71 @@ def Base_State_Coeffs(d):
3838
return A_T, B_T
3939

4040

41+
def bump_function(X, N_fm, nr, symmetric):
42+
43+
PSI_hat, T_hat, C_hat = X_to_Vecs(X, N_fm, nr, symmetric)
44+
45+
from Transforms import IDCT, DCT, IDST, DST, grid
46+
PSI = IDST(PSI_hat,n = (3*N_fm)//2)
47+
T = IDCT( T_hat,n = (3*N_fm)//2)
48+
C = IDCT( C_hat,n = (3*N_fm)//2)
49+
50+
loc_l = np.pi/2 - 0.25*np.pi
51+
loc_r = np.pi/2 + 0.25*np.pi
52+
xx = grid(N=(3*N_fm)//2)
53+
f = np.tanh( 2*(xx - loc_l) ) + np.tanh( 2*(loc_r - xx) )
54+
bump = .5*np.outer(np.ones(nr),f)
55+
56+
PSI_hat = DST(bump*PSI,axis=-1)[:,0:N_fm]
57+
T_hat = DCT(bump*T ,axis=-1)[:,0:N_fm]
58+
C_hat = DCT(bump*C ,axis=-1)[:,0:N_fm]
59+
60+
X = Vecs_to_X(PSI_hat, T_hat, C_hat, N_fm, nr, symmetric)
61+
62+
# from Plot_Tools import Spectral_To_Gridpoints
63+
# from Matrix_Operators import cheb_radial
64+
65+
# d = 3.132500e-01
66+
# R = cheb_radial(nr+1,d)[1]
67+
# Theta_grid = np.linspace(0,np.pi,N_fm);
68+
# r_grid = np.linspace(R[-1],R[0],50);
69+
70+
# PSI, T, S, T_0 = Spectral_To_Gridpoints(X, R,r_grid,N_fm,d)
71+
# RES = 20
72+
# # if Include_Base_State == True:
73+
# # T +=T_0;
74+
# # S +=T_0;
75+
76+
# # 1) Fix \theta labels to be [0,pi]
77+
# fig, (ax1, ax2, ax3) = plt.subplots(nrows=3,figsize=(12,8),dpi=1200)
78+
79+
# C_cntr = ax1.contour( Theta_grid,r_grid,T, RES, colors = 'k', linewidths=0.5,);
80+
# C_cntrf = ax1.contourf(Theta_grid,r_grid,T, RES, cmap="RdBu_r")
81+
# fig.colorbar(C_cntrf, ax=ax1)#
82+
# ax1.set_title(r'$T$',fontsize=20)
83+
84+
# P_cntr = ax2.contour( Theta_grid,r_grid,PSI,RES, colors = 'k', linewidths=0.5);
85+
# P_cntrf = ax2.contourf(Theta_grid,r_grid,PSI,RES, cmap="RdBu_r")
86+
# fig.colorbar(P_cntrf, ax=ax2)#
87+
# ax2.set_title(r'$\psi$',fontsize=20)
88+
89+
90+
# T_cntr = ax3.contour( Theta_grid,r_grid,S, RES, colors = 'k',linewidths=0.5);
91+
# T_cntrf = ax3.contourf(Theta_grid,r_grid,S, RES, cmap="RdBu_r")
92+
# fig.colorbar(T_cntrf, ax=ax3)#
93+
# ax3.set_ylabel(r'$r$',fontsize=18)
94+
95+
# ax3.set_xlabel(r'$\theta$',fontsize=18)
96+
# ax3.set_title(r'$S$',fontsize=18)
97+
98+
# plt.subplots_adjust(hspace=0.25)
99+
# plt.tight_layout()
100+
# plt.savefig("X_Frame.png",format='png', dpi=200)
101+
# plt.show()
102+
103+
return X
104+
105+
41106
@njit(fastmath=True)
42107
def Nusselt(T_hat, d, R, D, N_fm, nr, check=True):
43108

@@ -575,9 +640,9 @@ def Newton(fac, open_filename='NewtonSolve_0.h5', save_filename='NewtonSolve_0.h
575640

576641
# Problem Params
577642
X = f['Checkpoints/X_DATA'][frame];
578-
Ra = f['Checkpoints/Ra_DATA'][frame];
643+
#Ra = f['Checkpoints/Ra_DATA'][frame];
579644

580-
#Ra = f['Parameters']["Ra"][()];
645+
Ra = f['Parameters']["Ra"][()];
581646
Ra_s = f['Parameters']["Ra_s"][()];
582647
Tau = f['Parameters']["Tau"][()];
583648
Pr = f['Parameters']["Pr"][()];
@@ -597,27 +662,27 @@ def Newton(fac, open_filename='NewtonSolve_0.h5', save_filename='NewtonSolve_0.h
597662

598663
# ~~~~~~~~~ Interpolate ~~~~~~~~~~~~~~~~~~~
599664
from Matrix_Operators import INTERP_RADIAL,INTERP_THETAS
600-
N_r_n = 32; X = INTERP_RADIAL(N_r_n,N_r,X,d); N_r = N_r_n
601-
N_fm_n = 256; X = INTERP_THETAS(N_fm_n,N_fm,X); N_fm = N_fm_n
665+
N_r_n = 25; X = INTERP_RADIAL(N_r_n,N_r,X,d); N_r = N_r_n
666+
N_fm_n = 192; X = INTERP_THETAS(N_fm_n,N_fm,X); N_fm = N_fm_n
602667
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
603668

604669
# ~~~~~~~~~ Old Initial Conditions ~~~~~~~~~~~~~~~~~~
605670
if open_filename.endswith('.npy'):
606671
X = np.load(open_filename);
607672

608673
# # ~~~~~# L = 11 Gap #~~~~~~~~~#
609-
# l = 11
610-
# d = 0.31325
611-
# Ra_s = 400
612-
# Ra = 8275.70
674+
l = 11
675+
d = 0.31325
676+
Ra_s = 400
677+
Ra = 8275.70
613678

614679
# ~~~~~# L = 10 Gap #~~~~~~~~~#
615-
l = 10
616-
d = 0.3521
617-
Ra_s = 400
618-
Ra = 8351.53
680+
# l = 10
681+
# d = 0.3521
682+
# Ra_s = 400
683+
# Ra = 8351.53
619684

620-
Ra -=5e-03
685+
Ra -=1
621686

622687
Tau = 1./15.
623688
Pr = 1.
@@ -633,6 +698,9 @@ def Newton(fac, open_filename='NewtonSolve_0.h5', save_filename='NewtonSolve_0.h
633698
else:
634699
symmetric = True
635700

701+
702+
#X = bump_function(X, N_fm, N_r-1, symmetric=False)
703+
#Ra_s = 650.0
636704
#~~~~~~~~~~#~~~~~~~~~~#
637705
# Run Code
638706
#~~~~~~~~~~#~~~~~~~~~~#
@@ -965,8 +1033,8 @@ def _Continuation(filename, N_steps, sign, Y, **kwargs):
9651033

9661034
# Default parameters
9671035
ds =0.01; # The starting step size
968-
ds_min=1.0; #Threshold to switching between Newton & Psuedo
969-
ds_max=1.5; # Max Newton step
1036+
ds_min=.5; #Threshold to switching between Newton & Psuedo
1037+
ds_max=1.; # Max Newton step
9701038

9711039
Result = result()
9721040

@@ -1090,14 +1158,14 @@ def Continuation(open_filename, frame=-1):
10901158

10911159
# ~~~~~~~~~ Interpolate ~~~~~~~~~~~~~~~~~~~
10921160
from Matrix_Operators import INTERP_RADIAL,INTERP_THETAS
1093-
N_r_n = 25; X = INTERP_RADIAL(N_r_n,N_r,X,d);
1094-
N_fm_n = 128; X = INTERP_THETAS(N_fm_n,N_fm,X);
1161+
N_r_n = 32; X = INTERP_RADIAL(N_r_n,N_r,X,d);
1162+
N_fm_n = 256; X = INTERP_THETAS(N_fm_n,N_fm,X);
10951163
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10961164

10971165
sign = -1;
1098-
N_steps= 500;
1166+
N_steps= 2000;
10991167
Y = np.hstack( (X,Ra) );
1100-
kwargs = {"Ra":Ra,"Ra_s":Ra_s,"Tau":Tau,"Pr":Pr,"d":d,"N_fm":N_fm_n,"N_r":N_r_n, "symmetric":True}
1168+
kwargs = {"Ra":Ra,"Ra_s":Ra_s,"Tau":Tau,"Pr":Pr,"d":d,"N_fm":N_fm_n,"N_r":N_r_n, "symmetric":False}
11011169

11021170
save_filename = uniquify(open_filename)
11031171

@@ -1198,21 +1266,21 @@ def _plot_bif(filename, point = -1):
11981266
print("Initialising the code for running...")
11991267

12001268
# %%
1201-
#file = "ConvectonL10PlusRas303_6.h5"
1202-
#Continuation(open_filename=file,frame=18)
1269+
file = "Continuationl11Ras150_1.h5"
1270+
Continuation(open_filename=file,frame=25)
12031271
#trim(filename='Continuationl11Ras150_0.h5',point=-4)
12041272
#_plot_bif(filename='Continuationl11Ras150_0.h5',point=-4) # Good start point
12051273

12061274
# %%
1207-
#filename = "EigVec_l10.npy"
1208-
#Newton(fac=-1e-2,open_filename=filename,frame=-1)
1275+
#filename = "ContinuationL11LargeRas600_1.h5"
1276+
#Newton(fac=20,open_filename=filename,frame=0)
12091277

12101278
# %%
12111279
from Plot_Tools import Cartesian_Plot, Energy,Uradial_plot
1212-
filename = "ConvectonL10PlusRas303_7.h5"
1213-
_plot_bif(filename,point=-1)
1214-
#Cartesian_Plot(filename,frame=-1,Include_Base_State=False)
1215-
#Energy(filename,frame=-1)
1280+
filename = "Continuationl11Ras150_1.h5"
1281+
_plot_bif(filename,point=25)
1282+
#Cartesian_Plot(filename,frame=-20,Include_Base_State=False)
1283+
#Energy(filename,frame=-20)
12161284
# %%
12171285

12181286
# Fix these they should be the same

Paper_Figures/Plot_figures_L10_bifurcation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,4 @@ def Add_Label(X_folds, Nr_folds, Nfm_folds, Ra_folds, ax):
188188
axins_1.plot(np.arange(8000, 8500), 0*np.arange(8000, 8500), 'k-')
189189

190190
plt.savefig('Bifurcation_L10_Ras400.png', format='png', dpi=100)
191-
#plt.show()
191+
plt.show()

Paper_Figures/Plot_figures_L11_bifurcation.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ def add_to_fig(obj):
8989
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(16, 6), layout='constrained')
9090

9191
# A) Plot the bifurcation diagram
92-
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Minus/', ax, line='k-')
93-
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Plus/', ax, line='k-.')
92+
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Minus_old/', ax, line='k-')
93+
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Plus_old/', ax, line='k-.')
9494

9595
ax.set_ylabel(r'$\mathcal{E}$', fontsize=25)
9696
ax.set_xlabel(r'$Ra_T$', fontsize=25)
@@ -101,8 +101,8 @@ def add_to_fig(obj):
101101
# C) Add inset to show pitchfork
102102
axins = inset_axes(ax, width="70%", height="70%", loc='upper right', borderpad=2)
103103

104-
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Minus/', axins, line='k-')
105-
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Plus/', axins, line='k-.')
104+
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Minus_old/', axins, line='k-')
105+
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Plus_old/', axins, line='k-.')
106106

107107
axins.plot(np.arange(4515, 4528), 0*np.arange(4515, 4528), 'k-')
108108

@@ -129,35 +129,35 @@ def add_to_fig(obj):
129129
fig, ax = plt.subplots(nrows=1, ncols=6, figsize=(16, 6), layout='constrained')
130130

131131
# A) Plot the bifurcation diagram
132-
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Minus/', ax[0], line='r-')
133-
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Plus/', ax[0], line='b-.')
132+
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Minus_old/', ax[0], line='r-')
133+
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Plus_old/', ax[0], line='b-.')
134134
ax[0].set_xlim([2800, 3250])
135135
ax[0].set_ylim([0, 1])
136136

137-
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Minus/', ax[1], line='r-')
138-
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Plus/', ax[1], line='b-.')
137+
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Minus_old/', ax[1], line='r-')
138+
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Plus_old/', ax[1], line='b-.')
139139
ax[1].set_xlim([3250,3650])
140140
ax[1].set_ylim([0, 0.025])
141141

142142

143-
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Minus/', ax[2], line='r-')
144-
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Plus/', ax[2], line='b-.')
143+
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Minus_old/', ax[2], line='r-')
144+
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Plus_old/', ax[2], line='b-.')
145145
ax[2].set_xlim([3650,4000])
146146
ax[2].set_ylim([0, 0.007])
147147

148-
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Minus/', ax[3], line='r-')
149-
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Plus/', ax[3], line='b-.')
148+
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Minus_old/', ax[3], line='r-')
149+
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Plus_old/', ax[3], line='b-.')
150150
ax[3].set_xlim([4000, 4400])
151151
ax[3].set_ylim([0.0005, 0.003])
152152

153153

154-
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Minus/', ax[4], line='r-')
155-
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Plus/', ax[4], line='b-.')
154+
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Minus_old/', ax[4], line='r-')
155+
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Plus_old/', ax[4], line='b-.')
156156
ax[4].set_xlim([4400, 4520])
157157
ax[4].set_ylim([0.0002, 0.001])
158158

159-
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Minus/', ax[5], line='r-')
160-
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Plus/', ax[5], line='b-.')
159+
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Minus_old/', ax[5], line='r-')
160+
X_folds, Nr_folds, Nfm_folds, Ra_folds = Plot_full_bif(dir + 'Anti_Convectons_Plus_old/', ax[5], line='b-.')
161161
ax[5].set_xlim([4513, 4520])
162162
ax[5].set_ylim([0.0002, 0.00035])
163163

@@ -167,4 +167,7 @@ def add_to_fig(obj):
167167
ax_i.tick_params(axis='both', labelsize=25)
168168

169169
plt.savefig('L11_bifurcation_Ras150_branch_details.png', format='png', dpi=100)
170-
plt.show()
170+
plt.show()
171+
172+
173+

0 commit comments

Comments
 (0)