Skip to content

Commit 9e06736

Browse files
committed
Plotting
#!!!!!!!!!! WARNING: RUFF FAILED !!!!!!!!!!: #pySDC/projects/GPU/analysis_scripts/compare_RBC3D.py:494:9: E722 Do not use bare `except` # | Parallel-in-Time#492 | k[_s > 1e-16], _s[_s > 1e-16], color=last_line.get_color(), ls=last_line.get_linestyle(), label=label Parallel-in-Time#493 | ) Parallel-in-Time#494 | except: # | ^^^^^^ E722 Parallel-in-Time#495 | pass # | # #pySDC/projects/GPU/analysis_scripts/compare_RBC3D.py:593:5: F841 Local variable `Delta_Nu` is assigned to but never used # | Parallel-in-Time#591 | t = data['t'] Parallel-in-Time#592 | avg_Nu = np.array([np.mean(Nu[40 : 40 + i + 1]) for i in range(len(Nu[40:]))]) Parallel-in-Time#593 | Delta_Nu = np.array([abs(avg_Nu[i + 1] - avg_Nu[i]) for i in range(len(avg_Nu) - 1)]) # | ^^^^^^^^ F841 Parallel-in-Time#594 | # ax.plot(data['t'][40:-1], Delta_Nu / avg_Nu[:-1]) Parallel-in-Time#595 | # ax.plot(data['t'], np.abs(avg_Nu - avg_Nu[-1]) / avg_Nu[-1]) # | # = help: Remove assignment to unused variable `Delta_Nu`:
1 parent 7398fe2 commit 9e06736

File tree

1 file changed

+76
-3
lines changed

1 file changed

+76
-3
lines changed

pySDC/projects/GPU/analysis_scripts/compare_RBC3D.py

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def compare_Nusselt_over_time1e7_old():
204204
ax.set_ylabel('Nu')
205205

206206

207-
def compare_Nusselt_over_time1e5():
207+
def compare_Nusselt_over_time1e5_old():
208208
fig, axs = plt.subplots(2, 1, sharex=True)
209209
Ra = '1e5'
210210
res = 32
@@ -281,6 +281,79 @@ def interpolate_NuV_to_reference_times(data, reference_data, order=12):
281281
return interpolation_matrix @ t_in, interpolation_matrix @ data['Nu']['V']
282282

283283

284+
def compare_Nusselt_over_time1e5():
285+
fig, Nu_ax = plt.subplots()
286+
_, axs = plt.subplots(1, 3, figsize=(10, 3))
287+
prof_ax = axs[0]
288+
rms_ax = axs[1]
289+
spectrum_ax = axs[2]
290+
291+
Ra = '1e5'
292+
res = 32
293+
294+
data = []
295+
labels = []
296+
linestyles = []
297+
298+
ref_data = get_pySDC_data(Ra, res=res, dt=0.01, config_name='RBC3DG4R4')
299+
300+
for dt in [0.06, 0.02, 0.01]:
301+
data.append(get_pySDC_data(Ra, res=res, dt=dt, config_name='RBC3DG4R4'))
302+
labels.append(f'SDC, dt={dt:.4f}')
303+
linestyles.append('-')
304+
305+
# # ----------------- RK ------------------------
306+
307+
for dt in [0.05, 0.04, 0.02, 0.01, 0.005]:
308+
data.append(get_pySDC_data(Ra, res=res, dt=dt, RK=True, config_name='RBC3DG4R4'))
309+
labels.append(f'RK, dt={dt:.3f}')
310+
linestyles.append('--')
311+
312+
for dat, label, linestyle in zip(data, labels, linestyles):
313+
Nu = np.array(dat['Nu']['V'])
314+
t = dat['t']
315+
Nu_ref = np.array(ref_data['Nu']['V'])
316+
t_i, Nu_i = interpolate_NuV_to_reference_times(dat, ref_data)
317+
Nu_ax.plot(t, Nu, label=label, ls=linestyle)
318+
319+
error = np.maximum.accumulate(np.abs(Nu_ref[: Nu_i.shape[0]] - Nu_i) / np.abs(Nu_ref[: Nu_i.shape[0]]))
320+
321+
# compute mean Nu
322+
mask = np.logical_and(t >= 20, t <= 200)
323+
Nu_mean = np.mean(Nu[mask])
324+
Nu_std = np.std(Nu[mask])
325+
326+
last_line = Nu_ax.get_lines()[-1]
327+
if any(error > 1e-2):
328+
deviates = min(t_i[error > 1e-2])
329+
Nu_ax.axvline(deviates, color=last_line.get_color(), ls=last_line.get_linestyle())
330+
print(f'{label} Nu={Nu_mean:.3f}+={Nu_std:.3f}, deviates more than 1% from t={deviates:.2f}')
331+
else:
332+
print(f'{label} Nu={Nu_mean:.3f}+={Nu_std:.3f}')
333+
334+
k = dat['k']
335+
spectrum = np.array(dat['spectrum'])
336+
u_spectrum = np.mean(spectrum, axis=0)[1]
337+
idx = dat['res_in_boundary_layer']
338+
_s = u_spectrum[idx]
339+
spectrum_ax.loglog(
340+
k[_s > 1e-16], _s[_s > 1e-16], color=last_line.get_color(), ls=last_line.get_linestyle(), label=label
341+
)
342+
343+
prof_ax.plot(dat['profile_T'], dat['z'], color=last_line.get_color(), ls=last_line.get_linestyle(), label=label)
344+
rms_ax.plot(
345+
dat['rms_profile_T'], dat['z'], color=last_line.get_color(), ls=last_line.get_linestyle(), label=label
346+
)
347+
348+
Nu_ax.legend(frameon=True)
349+
Nu_ax.set_xlabel('t')
350+
Nu_ax.set_ylabel('Nu')
351+
352+
spectrum_ax.legend(frameon=False)
353+
spectrum_ax.set_xlabel('$k$')
354+
spectrum_ax.set_ylabel(r'$\|\hat{u}_x\|$')
355+
356+
284357
def compare_Nusselt_over_time1e6():
285358
fig, Nu_ax = plt.subplots()
286359
_, axs = plt.subplots(1, 3, figsize=(10, 3))
@@ -611,12 +684,12 @@ def compare_spectra(Ra=1e8):
611684
if __name__ == '__main__':
612685
# plot_Ra_Nusselt_scaling()
613686

614-
# compare_Nusselt_over_time1e5()
687+
compare_Nusselt_over_time1e5()
615688
# compare_Nusselt_over_time1e6()
616689
# compare_Nusselt_over_time1e7()
617690
# compare_Nusselt_over_time1e8()
618691
# plot_thibaut_stuff()
619692
# plot_spectrum_over_time1e6R4()
620-
compare_spectra(Ra=1e5)
693+
# compare_spectra(Ra=1e5)
621694

622695
plt.show()

0 commit comments

Comments
 (0)