88import pickle
99import os
1010
11+
1112def process_RBC3D_data (base_path = './data/RBC_time_averaged' , plot = True , args = None , config = None ):
1213 # prepare problem instance
1314 args = args if args else parse_args ()
@@ -30,10 +31,9 @@ def process_RBC3D_data(base_path='./data/RBC_time_averaged', plot=True, args=Non
3031 # prepare paths
3132 os .makedirs (base_path , exist_ok = True )
3233 fname = config .get_file_name ()
33- fname_trim = fname [fname .index ('RBC3D' ): fname .index ('.pySDC' )]
34+ fname_trim = fname [fname .index ('RBC3D' ) : fname .index ('.pySDC' )]
3435 path = f'{ base_path } /{ fname_trim } .pickle'
3536
36-
3737 # open simulation data
3838 data = FieldsIO .fromFile (fname )
3939
@@ -51,7 +51,6 @@ def process_RBC3D_data(base_path='./data/RBC_time_averaged', plot=True, args=Non
5151 spectrum = []
5252 spectrum_all = []
5353
54-
5554 # try to load time averaged values
5655 u_mean_profile = P .u_exact ()
5756 if os .path .isfile (path ):
@@ -97,7 +96,6 @@ def process_RBC3D_data(base_path='./data/RBC_time_averaged', plot=True, args=Non
9796 spectrum .append (s_mean )
9897 spectrum_all .append (s )
9998
100-
10199 # make a plot of the results
102100 t = xp .array (t )
103101 z = P .axes [- 1 ].get_1dgrid ()
@@ -136,7 +134,6 @@ def process_RBC3D_data(base_path='./data/RBC_time_averaged', plot=True, args=Non
136134 f'With Ra={ P .Rayleigh :.0e} got Nu={ avg_Nu ["V" ]:.2f} +-{ std_Nu ["V" ]:.2f} with errors: Top { rel_error ["t" ]:.2e} , bottom: { rel_error ["b" ]:.2e} , thermal: { rel_error ["thermal" ]:.2e} , kinetic: { rel_error ["kinetic" ]:.2e} '
137135 )
138136
139-
140137 # compute average profiles
141138 avg_profiles = {}
142139 for key , values in profiles .items ():
@@ -149,7 +146,6 @@ def process_RBC3D_data(base_path='./data/RBC_time_averaged', plot=True, args=Non
149146 values_from_convergence = [values [i ] for i in range (len (values )) if t [i ] >= config .converged ]
150147 avg_rms_profiles [key ] = xp .sqrt (xp .mean (values_from_convergence , axis = 0 ))
151148
152-
153149 # average T
154150 avg_T = avg_profiles ['T' ]
155151 axs [1 ].axvline (0.5 , color = 'black' )
@@ -163,7 +159,9 @@ def process_RBC3D_data(base_path='./data/RBC_time_averaged', plot=True, args=Non
163159 res_in_boundary_layer = max_idx if max_idx < len (z ) / 2 else len (z ) - max_idx
164160 boundary_layer = z [max_idx ] if max_idx > len (z ) / 2 else P .axes [- 1 ].L - z [max_idx ]
165161 if comm .rank == 0 :
166- print (f'Thermal boundary layer of thickness { boundary_layer :.2f} is resolved with { res_in_boundary_layer } points' )
162+ print (
163+ f'Thermal boundary layer of thickness { boundary_layer :.2f} is resolved with { res_in_boundary_layer } points'
164+ )
167165 axs [2 ].axhline (z [max_idx ], color = 'black' )
168166 axs [2 ].plot (avg_T , z )
169167 axs [2 ].scatter (avg_T , z )
@@ -205,5 +203,6 @@ def process_RBC3D_data(base_path='./data/RBC_time_averaged', plot=True, args=Non
205203 plt .show ()
206204 return path
207205
206+
208207if __name__ == '__main__' :
209208 process_RBC3D_data ()
0 commit comments