Skip to content

Commit

Permalink
Update paper
Browse files Browse the repository at this point in the history
  • Loading branch information
s9latimm committed Oct 19, 2024
1 parent ef1dd54 commit 3c80a55
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 77 deletions.
2 changes: 1 addition & 1 deletion resources
Submodule resources updated 112 files
4 changes: 2 additions & 2 deletions src/base/view/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import colors
from matplotlib import colors, font_manager

COLORS: list[tuple[float, float, float, float]] = [plt.get_cmap('tab10')(i) for i in range(10)]

Expand All @@ -18,7 +18,7 @@

PHI = (1. + np.sqrt(5.)) / 2.

# print(sorted(mpl.font_manager.get_font_names()))
print(sorted(font_manager.get_font_names()))
plt.rcParams['font.family'] = 'cmr10'
plt.rcParams['mathtext.fontset'] = 'cm'
plt.rcParams['axes.unicode_minus'] = False
Expand Down
2 changes: 1 addition & 1 deletion src/nse/model/experiments/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(
Axis('x', 0, 10),
Axis('y', 0, 2),
Figure(Line((0, 0), (10, 0)), Line((0, 2), (10, 2))),
Figure(Rectangle((4 + 2 / 3, 2 / 3), (5 + 1 / 3, 4 / 3))),
Figure(Rectangle((4.7, .7), (5.3, 1.3))),
nu,
rho,
Parabola(0, 2, flow),
Expand Down
2 changes: 1 addition & 1 deletion src/nse/model/experiments/slit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(
Axis('x', 0, 10),
Axis('y', 0, 2),
Figure(Line((0, 0), (10, 0)), Line((0, 2), (10, 2))),
Figure(Rectangle((4 + 2 / 3, 0), (5 + 1 / 3, 2 / 3)), Rectangle((4 + 2 / 3, 4 / 3), (5 + 1 / 3, 2))),
Figure(Rectangle((4.7, 0), (5.3, .7)), Rectangle((4.7, 1.3), (5.3, 2))),
nu,
rho,
Parabola(0, 2, flow),
Expand Down
118 changes: 53 additions & 65 deletions src/nse/view/paper/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __plot_parameters_mean(data: list[list[tuple[Integer, Record]]]):
import matplotlib.font_manager as font_manager
ax1.legend(frameon=False, prop=font_manager.FontProperties(family='cmmi10'))

save_fig(fig1, OUTPUT_DIR / 'paper' / 'meta_parameters.pdf')
save_fig(fig1, OUTPUT_DIR / 'paper' / 'meta' / 'parameters.pdf')

plt.clf()
plt.close()
Expand All @@ -60,7 +60,7 @@ def __plot_time_loss(data: list[list[tuple[Real, int, Record, Record, Record, In
fig8, ax8 = plt.subplots(figsize=(PHI * SCALE, SCALE))
fig9, ax9 = plt.subplots(figsize=(PHI * SCALE, SCALE))

x = arrange(25, 150, 25)
x = arrange(25, 200, 25)

for i, series in enumerate(data):
y = [float(i / 60) for i, *_ in series]
Expand Down Expand Up @@ -89,50 +89,50 @@ def __plot_time_loss(data: list[list[tuple[Real, int, Record, Record, Record, In
ax9.annotate(f'{(j + 1) * 25}', (y[j], v[j]), fontsize=5, ha='center', va='center', zorder=i)

ax1.set_ylabel('Training Steps')
ax1.set_ylim([0, 3.3e4])
ax1.plot(25, 3.3e4, "^k", clip_on=False)
ax1.plot(162.5, 0, ">k", clip_on=False)
ax1.set_yticks([0, 1e4, 2e4, 3e4])
ax1.set_yticklabels(['0', '1e4', '2e4', '3e4'])
ax1.set_ylim([0, 4.4e4])
ax1.plot(25, 4.4e4, "^k", clip_on=False)
ax1.plot(220, 0, ">k", clip_on=False)
ax1.set_yticks([0, 2e4, 4e4])
ax1.set_yticklabels(['0', '2e4', '4e4'])

ax2.set_ylabel('Training Time [min]')
ax2.set_ylim([0, 35])
ax2.plot(25, 35, "^k", clip_on=False)
ax2.plot(162.5, 0, ">k", clip_on=False)
ax2.set_yticks([0, 15, 30])
ax2.set_ylim([0, 66])
ax2.plot(25, 66, "^k", clip_on=False)
ax2.plot(220, 0, ">k", clip_on=False)
ax2.set_yticks([0, 30, 60])

ax3.set_ylabel(r'$\Delta u$')
ax3.set_ylim([0, 4.4e-2])
ax3.plot(25, 4.4e-2, "^k", clip_on=False)
ax3.plot(162.5, 0, ">k", clip_on=False)
ax3.plot(220, 0, ">k", clip_on=False)
ax3.set_yticks([0, 2e-2, 4e-2])
ax3.set_yticklabels(['0', '2e-2', '4e-2'])

ax4.set_ylabel(r'$\Delta v$')
ax4.set_ylim([0, 1.1e-2])
ax4.plot(25, 1.1e-2, "^k", clip_on=False)
ax4.plot(162.5, 0, ">k", clip_on=False)
ax4.plot(220, 0, ">k", clip_on=False)
ax4.set_yticks([0, 5e-3, 1e-2])
ax4.set_yticklabels(['0', '5e-3', '1e-2'])

ax5.set_ylabel(r'$\Delta \hat{u}$')
ax5.set_ylim([0, 8.8e-4])
ax5.plot(25, 8.8e-4, "^k", clip_on=False)
ax5.plot(162.5, 0, ">k", clip_on=False)
ax5.plot(220, 0, ">k", clip_on=False)
ax5.set_yticks([0, 4e-4, 8e-4])
ax5.set_yticklabels(['0', '4e-4', '8e-4'])

ax6.set_ylabel(r'$\Delta \hat{v}$')
ax6.set_ylim([0, 8.8e-4])
ax6.plot(25, 8.8e-4, "^k", clip_on=False)
ax6.plot(162.5, 0, ">k", clip_on=False)
ax6.plot(220, 0, ">k", clip_on=False)
ax6.set_yticks([0, 4e-4, 8e-4])
ax6.set_yticklabels(['0', '4e-4', '8e-4'])

ax7.set_ylabel(r'$u_{\text{rev}}$')
ax7.set_ylim([7, 11])
ax7.plot(25, 11, "^k", clip_on=False)
ax7.plot(162.5, 7, ">k", clip_on=False)
ax7.plot(220, 7, ">k", clip_on=False)
ax7.set_yticks([7, 8, 9, 10])
ax7.set_yticklabels(['0', '8', '9', '10'])
ax7.plot(
Expand All @@ -148,70 +148,52 @@ def __plot_time_loss(data: list[list[tuple[Real, int, Record, Record, Record, In
)

ax8.set_xlabel('Training Time [min]')
ax8.set_xlim([0, 35])
ax8.set_xticks([0, 15, 30])
ax8.set_xlim([0, 66])
ax8.set_xticks([0, 30, 60])
ax8.set_ylabel(r'$\Delta u$')
ax8.set_ylim([1.5e-2, 4.4e-2])
ax8.set_yticks([1.5e-2, 2e-2, 3e-2, 4e-2])
ax8.set_yticklabels(['0', '2e-2', '3e-2', '4e-2'])
ax8.plot(
[0, 0],
[1.71e-2, 1.75e-2],
marker=[(-1, -.5), (1, .5)],
markersize=8,
linestyle="none",
color='k',
mec='k',
mew=1,
clip_on=False,
)
ax8.set_ylim([2e-2, 4.4e-2])
ax8.set_yticks([2e-2, 3e-2, 4e-2])
ax8.set_yticklabels(['2e-2', '3e-2', '4e-2'])
ax8.tick_params(axis='y', labelrotation=90)
for t in ax8.get_yticklabels():
t.set_verticalalignment('center')
ax8.spines['top'].set_visible(False)
ax8.spines['right'].set_visible(False)
ax8.plot(0, 4.4e-2, "^k", clip_on=False)
ax8.plot(35, 1.5e-2, ">k", clip_on=False)
ax8.plot(66, 2e-2, ">k", clip_on=False)

ax9.set_xlabel('Training Time [min]')
ax9.set_xlim([0, 35])
ax9.set_xticks([0, 15, 30])
ax9.set_xlim([0, 66])
ax9.set_xticks([0, 30, 60])
ax9.set_ylabel(r'$\Delta v$')
ax9.set_ylim([3e-3, 1.1e-2])
ax9.set_yticks([3e-3, 4e-3, 7e-3, 1e-2])
ax9.set_yticklabels(['0', '4e-3', '7e-3', '1e-2'])
ax9.plot(
[0, 0],
[3.38e-3, 3.5e-3],
marker=[(-1, -.5), (1, .5)],
markersize=8,
linestyle="none",
color='k',
mec='k',
mew=1,
clip_on=False,
)
ax9.set_ylim([4e-3, 1.1e-2])
ax9.set_yticks([4e-3, 7e-3, 1e-2])
ax9.set_yticklabels(['4e-3', '7e-3', '1e-2'])
ax9.tick_params(axis='y', labelrotation=90)
for t in ax9.get_yticklabels():
t.set_verticalalignment('center')
ax9.spines['top'].set_visible(False)
ax9.spines['right'].set_visible(False)
ax9.plot(0, 1.1e-2, "^k", clip_on=False)
ax9.plot(35, 3e-3, ">k", clip_on=False)
ax9.legend(loc='center left', bbox_to_anchor=(1, 0.5), frameon=True, fancybox=False).get_frame().set_edgecolor('k')
ax9.plot(66, 4e-3, ">k", clip_on=False)
ax9.legend(loc='center left', bbox_to_anchor=(1, 0.5), frameon=True, fancybox=False,
title="Number of Layers").get_frame().set_edgecolor('k')

def __default(ax: plt.Axes, legend: bool):
ax.set_xticks(x)
ax.set_xlim([25, 163])
ax.set_xlim([25, 220])
ax.set_xlabel('Layer Size')
ax.tick_params(axis='y', labelrotation=90)
for tick in ax.get_yticklabels():
tick.set_verticalalignment('center')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
if legend:
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5), frameon=True,
fancybox=False).get_frame().set_edgecolor('k')
ax.legend(loc='center left',
bbox_to_anchor=(1, 0.5),
frameon=True,
fancybox=False,
title="Number of Layers").get_frame().set_edgecolor('k')

__default(ax1, False)
__default(ax2, True)
Expand All @@ -221,15 +203,15 @@ def __default(ax: plt.Axes, legend: bool):
__default(ax6, True)
__default(ax7, True)

save_fig(fig1, OUTPUT_DIR / 'paper' / 'meta_steps.pdf')
save_fig(fig2, OUTPUT_DIR / 'paper' / 'meta_time.pdf')
save_fig(fig3, OUTPUT_DIR / 'paper' / 'meta_mesh_error_u.pdf')
save_fig(fig4, OUTPUT_DIR / 'paper' / 'meta_mesh_error_v.pdf')
save_fig(fig5, OUTPUT_DIR / 'paper' / 'meta_boundary_error_u.pdf')
save_fig(fig6, OUTPUT_DIR / 'paper' / 'meta_boundary_error_v.pdf')
# save_fig(fig7, OUTPUT_DIR / 'paper' / 'meta_reverse.pdf')
save_fig(fig8, OUTPUT_DIR / 'paper' / 'meta_error_time_u.pdf')
save_fig(fig9, OUTPUT_DIR / 'paper' / 'meta_error_time_v.pdf')
save_fig(fig1, OUTPUT_DIR / 'paper' / 'meta' / 'steps.pdf')
save_fig(fig2, OUTPUT_DIR / 'paper' / 'meta' / 'time.pdf')
save_fig(fig3, OUTPUT_DIR / 'paper' / 'meta' / 'mesh_error_u.pdf')
save_fig(fig4, OUTPUT_DIR / 'paper' / 'meta' / 'mesh_error_v.pdf')
save_fig(fig5, OUTPUT_DIR / 'paper' / 'meta' / 'boundary_error_u.pdf')
save_fig(fig6, OUTPUT_DIR / 'paper' / 'meta' / 'boundary_error_v.pdf')
# save_fig(fig7, OUTPUT_DIR / 'paper' / 'meta' / 'reverse.pdf')
save_fig(fig8, OUTPUT_DIR / 'paper' / 'meta' / 'error_time_u.pdf')
save_fig(fig9, OUTPUT_DIR / 'paper' / 'meta' / 'error_time_v.pdf')

plt.clf()
plt.close()
Expand All @@ -242,12 +224,14 @@ def __default(ax: plt.Axes, legend: bool):
def main():
data = [
[
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_025-02_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_025-02_050000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_050-02_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_075-02_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_100-02_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_125-02_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_150-02_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_175-02_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_200-02_030000',
],
[
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_025-03_030000',
Expand All @@ -256,14 +240,18 @@ def main():
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_100-03_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_125-03_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_150-03_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_175-03_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_200-03_030000',
],
[
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_025-04_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_025-04_050000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_050-04_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_075-04_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_100-04_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_125-04_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_150-04_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_175-04_030000',
RESULT_DIR / 'step-0_100-0_010-1_000_cuda_200-04_030000',
],
]

Expand Down
39 changes: 32 additions & 7 deletions src/nse/view/paper/paper.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ def plot_inlets(experiments: list[Experiment]):
ax.set_yticks([0, 1, 2])
ax.set_ylim([0, 2.2])

# ax.set_title(str(experiment.inlet_f))
ax.tick_params(axis='y', labelrotation=90)
for t in ax.get_yticklabels():
t.set_verticalalignment('center')

fig.tight_layout()
save_fig(fig, OUTPUT_DIR / 'paper' / 'inlets.pdf')

plt.clf()
Expand Down Expand Up @@ -67,7 +70,18 @@ def plot_grid(experiment: Experiment):
ys.append(y)

ax.scatter(xs, ys, color=COLORS[1], marker='+', s=20, linewidth=.5)
ax.scatter(xs, ys, color=COLORS[1], marker='o', s=2.5, linewidth=.5)
ax.scatter(xs, ys, color=COLORS[1], marker='o', s=2.5, linewidth=.5, label='training')

xs = []
ys = []
for x in experiment.x.arrange(.1, True):
for y in experiment.y.arrange(.1, True):
if experiment.x.start < x and experiment.y.start < y < experiment.y.stop:
if (x, y) not in experiment.obstruction:
xs.append(x)
ys.append(y)

ax.scatter(xs, ys, color='k', marker='x', s=10, linewidth=.5, label='evaluation')

xs = []
ys = []
Expand All @@ -86,7 +100,7 @@ def plot_grid(experiment: Experiment):
xs.append(1)
ys.append(y)

ax.scatter(xs, ys, color='k', marker='D', s=2.5, linewidth=.5, zorder=9999)
ax.scatter(xs, ys, color='k', marker='D', s=2.5, linewidth=.5, zorder=9999, label='boundary')

xs = []
ys = []
Expand All @@ -95,7 +109,7 @@ def plot_grid(experiment: Experiment):
xs.append(0)
ys.append(y)

ax.scatter(xs, ys, color=COLORS[2], marker='>', s=2.5, linewidth=.5, zorder=999)
ax.scatter(xs, ys, color=COLORS[2], marker='>', s=2.5, linewidth=.5, zorder=999, label='inlet')

ax.spines['top'].set_visible(False)
ax.spines['bottom'].set_visible(False)
Expand All @@ -112,7 +126,13 @@ def plot_grid(experiment: Experiment):
ax.set_yticks([0, 1, 2])
ax.set_ylim([-.05, 2.05])

save_fig(fig, OUTPUT_DIR / 'paper' / 'grid.pdf')
ax.tick_params(axis='y', labelrotation=90)
for t in ax.get_yticklabels():
t.set_verticalalignment('center')

ax.legend(loc='center left', bbox_to_anchor=(1, 0.5), frameon=True, fancybox=False).get_frame().set_edgecolor('k')

save_fig(fig, OUTPUT_DIR / 'paper' / 'step_mesh.pdf')

plt.clf()
plt.close()
Expand Down Expand Up @@ -175,12 +195,17 @@ def plot_experiments(experiments: list[Experiment]):
ax.set_xticks([0, 1, 5, 10])
ax.set_xlim([-.05, 10.05])

ax.set_ylabel('u', fontname='cmmi10')
ax.set_ylabel('y', fontname='cmmi10')
ax.set_yticks([0, 1, 2])
ax.set_ylim([-.05, 2.05])

ax.set_title(experiment.name, fontname='cmss10')
ax.tick_params(axis='y', labelrotation=90)
for t in ax.get_yticklabels():
t.set_verticalalignment('center')

ax.set_title(experiment.name.lower(), fontname='cmtt10')

fig.tight_layout()
save_fig(fig, OUTPUT_DIR / 'paper' / 'experiments.pdf')

plt.clf()
Expand Down

0 comments on commit 3c80a55

Please sign in to comment.