Skip to content

Commit c3df0ef

Browse files
committed
removed GE4 for clarity
1 parent ea99cdb commit c3df0ef

2 files changed

Lines changed: 37 additions & 26 deletions

File tree

python/plot_convergence_JAES.py

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy as np
77
from helper_plots import set_size
88

9-
#%% Settings
9+
# %% Settings
1010
result_folder = "results/conv_full_2"
1111

1212
with h5py.File(join(result_folder, "settings.h5"), "r") as f:
@@ -17,19 +17,22 @@
1717
modes = json.loads(f.attrs["modes"])
1818
A0s = json.loads(f.attrs["A0s"])
1919

20+
modes = ["Linear", "KC", "GE4"]
21+
2022
lambda0s = lambda0s[-1:]
2123
print(lambda0s)
22-
#%% Init plot
23-
Nrows = 2
24-
Ncols = 2
24+
# %% Init plot
25+
Nrows = 3
26+
Ncols = 1
2527

26-
fig, axs = plt.subplots(Nrows, Ncols, sharex=True, sharey=False, figsize = set_size("JAES", fraction=1, height_ratio=0.6))
28+
fig, axs = plt.subplots(Nrows, Ncols, sharex=True, sharey=False,
29+
figsize=set_size("JAES", fraction=1, height_ratio=0.7))
2730
colors = plt.rcParams['axes.prop_cycle'].by_key()['color']
2831
markers = ['*', '+', '.', '1', 'o', 'v']
2932

3033
for k, mode in enumerate(modes):
3134
for l, A0 in enumerate(A0s):
32-
#%% Retrieve reference data at midpoint
35+
# %% Retrieve reference data at midpoint
3336
with h5py.File(join(result_folder, f"{mode}/{A0}/ref.h5"), "r") as f:
3437
q_ref = f["q"][...]
3538
model_setting = json.loads(f.attrs['model_dict'])
@@ -54,35 +57,38 @@ def compute_error(q, qref):
5457
errors[i, j] = compute_error(q, q_ref)
5558
else:
5659
errors[i, j] = np.nan()
57-
58-
#%% Plot
59-
ax = axs[k//2, k%2]
60+
61+
# %% Plot
62+
ax = axs[k]
6063
ax.set_xscale("log")
6164
ax.set_yscale("log")
6265
for i, lambda0 in enumerate(lambda0s):
63-
ax.plot(hs, errors[:, i], label=r"$Q_0 = $" + f"{A0} m", ls="dotted", marker = markers[l], markersize = 10, color = colors[l])
66+
ax.plot(hs, errors[:, i], label=r"$Q_0 = $" +
67+
f"{A0} m", ls="dotted", marker=markers[l], markersize=10, color=colors[l])
6468
if (k == 3):
6569
# legend
66-
ax.legend(bbox_to_anchor=(1, 0.5), loc = "lower left", frameon = True)
70+
ax.legend(bbox_to_anchor=(1, 0.5), loc="lower left", frameon=True)
6771

6872
# ax.legend(frameon = True) #, ncol=3, bbox_to_anchor=(0.5, 1.05), loc = "upper center")
6973
# ax.set_ylim([np.min(errors) * 0.5, np.max(errors) * 2])
7074

71-
ax.plot([hs[-1], hs[0]], [errors[-1, 0], errors[-1, 0]/ (hs[-1] / hs[0])**2], linestyle = "--", color="gray")
75+
ax.plot([hs[-1], hs[0]], [errors[-1, 0], errors[-1, 0] /
76+
(hs[-1] / hs[0])**2], linestyle="--", color="gray")
7277

73-
ax.text(0.1, 0.8, mode, transform = ax.transAxes)
78+
ax.text(0.1, 0.7, mode, transform=ax.transAxes)
7479
# Set x-axis ticks to align with data points
7580
stride = 2
76-
if (k//2 == 1):
81+
if (k == 2):
7782
ax.xaxis.set_minor_formatter(NullFormatter())
7883
ax.xaxis.set_tick_params(which='minor', size=0)
79-
ax.xaxis.set_tick_params(which='minor', width=0)
84+
ax.xaxis.set_tick_params(which='minor', width=0)
8085
ax.set_xticks(hs[::stride])
8186
ax.set_xticklabels([f"{x:.2e}" for x in hs[::stride]])
82-
else:
87+
elif (k == 0):
8388
# Add a secondary x axis with sampling frequency
8489
def forward(x):
8590
return x
91+
8692
def backward(x):
8793
return x
8894
secax = ax.secondary_xaxis('top', functions=(forward, backward))
@@ -94,10 +100,10 @@ def backward(x):
94100
secax.xaxis.set_tick_params(which='minor', width=0)
95101
# plt.xlabel("h (m)")
96102
# plt.ylabel("Relative error e")
97-
fig.text(0.47, 0.01, 'h (m)', ha='center')
98-
fig.text(0.47, 0.95, r'$f_{\rm s}$ (Hz)', ha='center')
103+
fig.text(0.52, 0.01, 'h (m)', ha='center')
104+
fig.text(0.52, 0.95, r'$f_{\rm s}$ (Hz)', ha='center')
99105
fig.text(0.01, 0.5, 'Relative error e', va='center', rotation='vertical')
100106
plt.tight_layout()
101-
fig.subplots_adjust(left = 0.1, hspace=0.05, wspace=0.2)
107+
fig.subplots_adjust(left=0.1, hspace=0.05, wspace=0.2)
102108

103-
plt.show(block = True)
109+
plt.show(block=True)

python/plot_drift_JAES.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
model = FD_string_model(44100, **StringParams)
4949

50-
modes = ["KC", "GE", "GE4"] # Nonlinear modes
50+
modes = ["KC", "GE4"] # Nonlinear modes
5151

5252
# %%
5353
# Simulation parameters
@@ -81,7 +81,7 @@ def Fext(t):
8181

8282
# %% Run simulations and plot results
8383
fig, axs = plt.subplots(1 + 2*len(lambda0s), 1,
84-
figsize=set_size("JAES", height_ratio=0.6), sharex=True)
84+
figsize=set_size("JAES", height_ratio=0.7), sharex=True)
8585
linestyles = [":", "--", "-."]
8686
for i, lambda0 in enumerate(lambda0s):
8787

@@ -122,10 +122,15 @@ def Fext(t):
122122
axs[2*i+2].set_ylim([1e-4, 1.5e3])
123123
axs[2*i+2].set_yticks([1e-4, 1e-1, 1e2])
124124
axs[2*i+2].set_yticklabels([1e-4, 1e-1, 1e2])
125-
axs[2*i+1].text(0.8, 0.6, fr"$\lambda_0 = {lambda0} s^{-1}$", transform=axs[2*i+1].transAxes,
126-
color="red", bbox=dict(facecolor='white', edgecolor='black', boxstyle='round'))
127-
axs[2*i+2].text(0.8, 0.6, fr"$\lambda_0 = {lambda0} s^{-1}$", transform=axs[2*i+2].transAxes,
128-
color="red", bbox=dict(facecolor='white', edgecolor='black', boxstyle='round'))
125+
axs[1].text(1.05, 0, "Original \n algorithm", transform=axs[1].transAxes,
126+
color="red", bbox=dict(facecolor='white', edgecolor='black', boxstyle='round'), horizontalalignment="center", verticalalignment="center", rotation=90)
127+
# axs[2].text(0.95, 0.6, fr"Original algorithm", transform=axs[2].transAxes,
128+
# color="red", bbox=dict(facecolor='white', edgecolor='black', boxstyle='round'), horizontalalignment="right")
129+
130+
axs[3].text(1.035, 0, fr"$\tau_0 = 0.001$ s", transform=axs[3].transAxes,
131+
color="red", bbox=dict(facecolor='white', edgecolor='black', boxstyle='round'), horizontalalignment="center", verticalalignment="center", rotation=90)
132+
# axs[4].text(0.95, 0.6, fr"$\tau_0 = 0.001 s$", transform=axs[4].transAxes,
133+
# color="red", bbox=dict(facecolor='white', edgecolor='black', boxstyle='round'), horizontalalignment="right")
129134

130135
axs[1].legend(loc="lower center", frameon=True, fancybox=True,
131136
bbox_to_anchor=(0.5, 2.1), ncol=3)

0 commit comments

Comments
 (0)