Skip to content

Commit ba362cd

Browse files
committed
More plotting
1 parent 83b2578 commit ba362cd

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

pySDC/projects/RayleighBenard/analysis_scripts/RBC3D_order.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from pySDC.projects.RayleighBenard.analysis_scripts.plotting_utils import get_plotting_style, savefig
1111

1212
step_sizes = {
13-
'RBC3DG4R4Ra1e5': [8e-2, 4e-2, 2e-2, 1e-2, 5e-3],
1413
'RBC3DG4R4SDC23Ra1e5': [5e-3 * 2**i for i in range(8)],
1514
'RBC3DG4R4SDC34Ra1e5': [5e-3 * 2**i for i in range(8)],
1615
'RBC3DG4R4SDC44Ra1e5': [5e-3 * 2**i for i in range(8)],
@@ -74,7 +73,7 @@ def plot_error_all_components(args): # pragma: no cover
7473
def compare_order(Ra): # pragma: no cover
7574
fig, ax = plt.subplots(figsize=figsize_by_journal('Nature_CS', 1, 0.6))
7675
if Ra == 1e5:
77-
names = ['RK', 'Euler', 'SDC23', 'SDC34', 'SDC44'][::-1]
76+
names = ['RK', 'Euler', 'SDC22', 'SDC23', 'SDC34', 'SDC44'][::-1]
7877
configs = [f'RBC3DG4R4{me}Ra1e5' for me in names]
7978
paths = [f'./data/RBC3DG4R4{me}Ra1e5-res-1-order.pickle' for me in names]
8079

@@ -92,7 +91,7 @@ def compare_order(Ra): # pragma: no cover
9291
ax.loglog(dt, e, **get_plotting_style(config))
9392

9493
for _dt in dt:
95-
for i in [1, 3, 4]:
94+
for i in [1, 2, 3, 4]:
9695
ax.text(_dt, _dt**i, i, fontweight='bold', fontsize=14, ha='center', va='center')
9796
ax.loglog(dt, dt**i, ls=':', color='black')
9897

pySDC/projects/RayleighBenard/analysis_scripts/plot_Nu.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def plot_Nu(res, dts, config_name, ref, ax, title): # pragma: no cover
3939
if any(error > 1e-2):
4040
deviates = min(t_i[error > 1e-2])
4141
ax.axvline(deviates, color=last_line.get_color(), ls=':')
42-
print(f'{title} dt={dt} Nu={Nu_mean:.3f}+={Nu_std:.3f}, deviates more than 1% from t={deviates:.2f}')
42+
print(f'{title} dt={dt:.4f} Nu={Nu_mean:.3f}+={Nu_std:.3f}, deviates more than 1% from t={deviates:.2f}')
4343
else:
44-
print(f'{title} dt={dt} Nu={Nu_mean:.3f}+={Nu_std:.3f}')
44+
print(f'{title} dt={dt:.4f} Nu={Nu_mean:.3f}+={Nu_std:.3f}')
4545
ax.legend(frameon=True, loc='upper left')
4646

4747

@@ -50,12 +50,13 @@ def plot_Nu_over_time_Ra1e5(): # pragma: no cover
5050

5151
res = 32
5252

53-
ref_data = get_pySDC_data(res=res, dt=0.01, config_name='RBC3DG4R4Ra1e5')
53+
ref_data = get_pySDC_data(res=res, dt=0.01, config_name='RBC3DG4R4SDC44Ra1e5')
5454

5555
plot_Nu(32, [0.06, 0.04, 0.02], 'RBC3DG4R4SDC34Ra1e5', ref_data, Nu_axs[0], 'SDC34')
5656
plot_Nu(32, [0.06, 0.05, 0.02, 0.01], 'RBC3DG4R4SDC23Ra1e5', ref_data, Nu_axs[1], 'SDC23')
5757
plot_Nu(32, [0.05, 0.04, 0.02, 0.01, 0.005], 'RBC3DG4R4RKRa1e5', ref_data, Nu_axs[2], 'RK443')
5858
plot_Nu(32, [0.02, 0.01, 0.005], 'RBC3DG4R4EulerRa1e5', ref_data, Nu_axs[3], 'RK111')
59+
plot_Nu(32, [0.04, 0.02], 'RBC3DG4R4SDC22Ra1e5', ref_data, Nu_axs[3], 'SDC22')
5960

6061
Nu_axs[-1].set_xlabel('$t$')
6162
Nu_axs[-1].set_ylabel('$Nu$')

pySDC/projects/RayleighBenard/analysis_scripts/plotting_utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from pySDC.helpers.plot_helper import figsize_by_journal, setup_mpl
22
import warnings
3+
import os
34

45
setup_mpl()
56

@@ -8,7 +9,12 @@ def get_plotting_style(config): # pragma: no cover
89

910
args = {'color': None, 'ls': None, 'marker': None, 'markersize': 6, 'label': None}
1011

11-
if config == 'RBC3DG4R4SDC23Ra1e5':
12+
if config == 'RBC3DG4R4SDC22Ra1e5':
13+
args['color'] = 'tab:brown'
14+
args['ls'] = '-'
15+
args['marker'] = '3'
16+
args['label'] = 'SDC22'
17+
elif config == 'RBC3DG4R4SDC23Ra1e5':
1218
args['color'] = 'tab:blue'
1319
args['ls'] = '-'
1420
args['marker'] = 'o'
@@ -18,7 +24,7 @@ def get_plotting_style(config): # pragma: no cover
1824
args['ls'] = '-'
1925
args['marker'] = '<'
2026
args['label'] = 'SDC34'
21-
elif config in ['RBC3DG4R4SDC44Ra1e5', 'RBC3DG4R4Ra1e5']:
27+
elif config == 'RBC3DG4R4SDC44Ra1e5':
2228
args['color'] = 'tab:green'
2329
args['ls'] = '-'
2430
args['marker'] = 'x'
@@ -40,6 +46,8 @@ def get_plotting_style(config): # pragma: no cover
4046

4147

4248
def savefig(fig, name, format='pdf', base_path='./plots', **kwargs): # pragma: no cover
49+
os.makedirs(base_path, exist_ok=True)
50+
4351
path = f'{base_path}/{name}.{format}'
4452
fig.savefig(path, bbox_inches='tight', **kwargs)
4553
print(f'Saved figure {path!r}')

pySDC/projects/RayleighBenard/run_experiment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def str_to_procs(me):
1515
'--mode',
1616
type=str,
1717
help='Mode for this script',
18-
default='run',
19-
choices=['run'],
18+
default=None,
19+
choices=['run', 'plot'],
2020
)
2121
parser.add_argument('--config', type=str, help='Configuration to load', default=None)
2222
parser.add_argument('--restart_idx', type=int, help='Restart from file by index', default=0)

0 commit comments

Comments
 (0)