66from pySDC .implementations .problem_classes .RayleighBenard3D import RayleighBenard3D
77from mpi4py import MPI
88import matplotlib .pyplot as plt
9- from pySDC .helpers .plot_helper import setup_mpl , figsize_by_journal
9+ from pySDC .helpers .plot_helper import figsize_by_journal
10+ from pySDC .projects .GPU .analysis_scripts .RBC3D_plotting_utils import get_plotting_style , savefig
1011
1112step_sizes = {
1213 'RBC3DG4R4Ra1e5' : [8e-2 , 4e-2 , 2e-2 , 1e-2 , 5e-3 ],
@@ -53,7 +54,6 @@ def compute_errors(args, dts, Tend):
5354
5455
5556def plot_error_all_components (args ): # pragma: no cover
56- setup_mpl ()
5757 fig , ax = plt .subplots ()
5858 with open (get_path (args ), 'rb' ) as file :
5959 errors = pickle .load (file )
@@ -72,27 +72,24 @@ def plot_error_all_components(args): # pragma: no cover
7272
7373
7474def compare_order (Ra ): # pragma: no cover
75- setup_mpl ()
7675 fig , ax = plt .subplots (figsize = figsize_by_journal ('Nature_CS' , 1 , 0.6 ))
77- ls = {'SD' : '-' , 'RK' : '--' , 'Eu' : '-.' }
7876 if Ra == 1e5 :
79- labels = ['RK443' , 'Euler' , 'SDC23' , 'SDC34' , 'SDC44' ][::- 1 ]
8077 names = ['RK' , 'Euler' , 'SDC23' , 'SDC34' , 'SDC44' ][::- 1 ]
81- markers = ['>' , '.' , 'o' , '<' , 'x' ][:: - 1 ]
78+ configs = [f'RBC3DG4R4 { me } Ra1e5' for me in names ]
8279 paths = [f'./data/RBC3DG4R4{ me } Ra1e5-res-1-order.pickle' for me in names ]
8380
8481 else :
8582 raise NotImplementedError
8683
87- for path , label , marker in zip (paths , labels , markers , strict = True ):
84+ for path , config in zip (paths , configs , strict = True ):
8885 with open (path , 'rb' ) as file :
8986 errors = pickle .load (file )
9087
9188 e = np .array (errors ['T' ])
9289 dt = np .array (errors ['dt' ])
9390 order = np .log (e [1 :] / e [:- 1 ]) / np .log (dt [1 :] / dt [:- 1 ])
94- print (f'{ label } : order: mean={ np .mean (order ):.1f} / median={ np .median (order ):.1f} ' )
95- ax .loglog (dt , e , label = f' { label } ' , ls = ls [ label [: 2 ]], marker = marker , markersize = 6 )
91+ print (f'{ config } : order: mean={ np .mean (order ):.1f} / median={ np .median (order ):.1f} ' )
92+ ax .loglog (dt , e , ** get_plotting_style ( config ) )
9693
9794 for _dt in dt :
9895 for i in [1 , 3 , 4 ]:
@@ -102,7 +99,7 @@ def compare_order(Ra): # pragma: no cover
10299 ax .legend (frameon = False )
103100 ax .set_xlabel (r'$\Delta t$' )
104101 ax .set_ylabel (r'$e$' )
105- fig . savefig ('plots/SDC_order_Ra1e5.pdf' , bbox_inches = 'tight ' )
102+ savefig (fig , 'RBC3D_order_Ra1e5 ' )
106103
107104
108105def run (args , dt , Tend ):
@@ -140,13 +137,15 @@ def run(args, dt, Tend):
140137 from pySDC .projects .GPU .run_experiment import parse_args
141138
142139 args = parse_args ()
143- config = get_config (args )
144140
145- dts = step_sizes [type (config ).__name__ ]
146141 if args ['mode' ] == 'run' :
142+ config = get_config (args )
143+ dts = step_sizes [type (config ).__name__ ]
147144 compute_errors (args , dts , max (dts ))
148145
149- plot_error_all_components (args )
146+ if args ['config' ] is not None :
147+ plot_error_all_components (args )
148+
150149 compare_order (1e5 )
151150 if MPI .COMM_WORLD .rank == 0 :
152151 plt .show ()
0 commit comments