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
910
1011step_sizes = {
1112 'RBC3DG4R4Ra1e5' : [8e-2 , 4e-2 , 2e-2 , 1e-2 , 5e-3 ],
@@ -56,6 +57,7 @@ def compute_errors(args, dts, Tend):
5657
5758
5859def plot_error_all_components (args ):
60+ setup_mpl ()
5961 fig , ax = plt .subplots ()
6062 with open (get_path (args ), 'rb' ) as file :
6163 errors = pickle .load (file )
@@ -74,27 +76,37 @@ def plot_error_all_components(args):
7476
7577
7678def compare_order (Ra ):
77- fig , ax = plt .subplots ()
78- ls = {'SDC' : '-' , 'RK' : '--' , 'Euler' : '-.' }
79+ setup_mpl ()
80+ fig , ax = plt .subplots (figsize = figsize_by_journal ('Nature_CS' , 1 , 0.6 ))
81+ ls = {'SD' : '-' , 'RK' : '--' , 'Eu' : '-.' }
7982 if Ra == 1e5 :
80- paths = [f'./data/RBC3DG4R4{ me } Ra1e5-res-1-order.pickle' for me in ['' , 'RK' , 'Euler' , 'SDC23' ]]
81- labels = ['SDC' , 'RK' , 'Euler' , 'SDC' ]
83+ labels = ['RK443' , 'Euler' , 'SDC23' , 'SDC34' , 'SDC44' ][::- 1 ]
84+ names = ['RK' , 'Euler' , 'SDC23' , 'SDC34' , 'SDC44' ][::- 1 ]
85+ markers = ['>' , '.' , 'o' , '<' , 'x' ][::- 1 ]
86+ paths = [f'./data/RBC3DG4R4{ me } Ra1e5-res-1-order.pickle' for me in names ]
8287
8388 else :
8489 raise NotImplementedError
8590
86- for path , label in zip (paths , labels , strict = True ):
91+ for path , label , marker in zip (paths , labels , markers , strict = True ):
8792 with open (path , 'rb' ) as file :
8893 errors = pickle .load (file )
8994
9095 e = np .array (errors ['T' ])
9196 dt = np .array (errors ['dt' ])
9297 order = np .log (e [1 :] / e [:- 1 ]) / np .log (dt [1 :] / dt [:- 1 ])
93- ax .loglog (dt , e , label = f'{ label } order { np .mean (order ):.1f} ' , ls = ls [label ])
98+ print (f'{ label } : order: mean={ np .mean (order ):.1f} / median={ np .median (order ):.1f} ' )
99+ ax .loglog (dt , e , label = f'{ label } ' , ls = ls [label [:2 ]], marker = marker , markersize = 6 )
100+
101+ for _dt in dt :
102+ for i in [1 , 3 , 4 ]:
103+ ax .text (_dt , _dt ** i , i , fontweight = 'bold' , fontsize = 14 , ha = 'center' , va = 'center' )
104+ ax .loglog (dt , dt ** i , ls = ':' , color = 'black' )
94105
95106 ax .legend (frameon = False )
96107 ax .set_xlabel (r'$\Delta t$' )
97108 ax .set_ylabel (r'$e$' )
109+ fig .savefig ('plots/SDC_order_Ra1e5.pdf' , bbox_inches = 'tight' )
98110
99111
100112def run (args , dt , Tend ):
@@ -107,6 +119,9 @@ def run(args, dt, Tend):
107119 config = get_config (args )
108120 config .Tend = n_freefall_times .get (type (config ).__name__ , 3 )
109121
122+ desc = config .get_description ()
123+ prob = desc ['problem_class' ](** desc ['problem_params' ])
124+
110125 ic_config_name = type (config ).__name__
111126 for name in ['RK' , 'Euler' , 'O3' , 'O4' , 'SDC23' , 'SDC34' , 'SDC44' ]:
112127 ic_config_name = ic_config_name .replace (name , '' )
@@ -118,7 +133,8 @@ def run(args, dt, Tend):
118133 config .get_LogToFile = no_logging_hook
119134 config .Tend = Tend
120135
121- u = run_experiment (args , config )
136+ u_hat = run_experiment (args , config )
137+ u = prob .itransform (u_hat )
122138 return u
123139
124140
0 commit comments