11from numba import njit
22import numpy as np
33import matplotlib .pyplot as plt
4- from Matrix_Operators import cheb_radial
4+ from Matrix_Operators import cheb_radial , Vecs_to_X , X_to_Vecs
55import os
66import time
77import 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 )
42107def 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
0 commit comments