From 70fda0ecf925fb5010b2e23cbdbc4e2076715958 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 24 Jun 2026 22:11:24 +0200 Subject: Adding python script for the graph generation --- scripts/python/graph.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 scripts/python/graph.py (limited to 'scripts') diff --git a/scripts/python/graph.py b/scripts/python/graph.py new file mode 100755 index 0000000..ab42154 --- /dev/null +++ b/scripts/python/graph.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +import numpy as np +import matplotlib.pyplot as plt + +x = np.linspace(0, 1, 1000) + +# Linear function +y_linear = x + +# Step function +y_step = np.piecewise( + x, + [ + x < 0.125, + (x >= 0.125) & (x < 0.375), + (x >= 0.375) & (x < 0.625), + (x >= 0.625) & (x < 0.875), + x >= 0.875 + ], + [0.0, 1/4, 2/4, 3/4, 1.0] +) + +y_step2 = np.piecewise( + x, + [ + x < 0.0625, + (x >= 0.0625) & (x < 0.1875), + (x >= 0.1875) & (x < 0.3125), + (x >= 0.3125) & (x < 0.4375), + (x >= 0.4375) & (x < 0.5625), + (x >= 0.5625) & (x < 0.6875), + (x >= 0.6875) & (x < 0.8125), + (x >= 0.8125) & (x < 0.9375), + x >= 0.9375 + ], + [0/8, 1/8, 2/8, 3/8, 4/8, 5/8, 6/8, 7/8, 1.0] +) + +# Smooth cos²-like ramp from 0 → 1 over full domain +y_cos2 = np.sin((np.pi / 2.0) * x) ** 2 + +y_cos2_shift = np.sin((np.pi / 2.0) * (x+0.125)/1.25) ** 2 + + + +# Plot +plt.figure(figsize=(8, 6)) + +plt.plot(x, y_linear, label="y = x", linewidth=2) +plt.step(x, y_step, where="post", label="PSM subgrid of 8", linewidth=2) +plt.step(x, y_step2, where="post", label="PSM subgrid of 8", linewidth=2) +plt.plot(x, y_cos2, label=r'HLBM e_h:cell size 1:1', linewidth=2) +plt.plot(x, y_cos2_shift, label=r'HLBM e_h:cell size 1.25:1', linewidth=2) + +plt.xlim(0, 1) +plt.ylim(0, 1) +plt.grid(True) +plt.legend() + +plt.xlabel("x") +plt.ylabel("y") +plt.title("Linear + Step + Smooth Cos² Ramp") + +plt.show() -- cgit v1.2.3 From e6e9cc9ce84539813e7e14fae5cdf3d4466fdeaf Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 26 Jun 2026 15:21:26 +0200 Subject: Added runs and script --- scripts/python/graph.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/python/graph.py b/scripts/python/graph.py index ab42154..cb3802d 100755 --- a/scripts/python/graph.py +++ b/scripts/python/graph.py @@ -42,16 +42,18 @@ y_cos2 = np.sin((np.pi / 2.0) * x) ** 2 y_cos2_shift = np.sin((np.pi / 2.0) * (x+0.125)/1.25) ** 2 +y_cos2_shift_15 = np.sin((np.pi / 2.0) * (x+0.25)/1.5) ** 2 # Plot plt.figure(figsize=(8, 6)) -plt.plot(x, y_linear, label="y = x", linewidth=2) -plt.step(x, y_step, where="post", label="PSM subgrid of 8", linewidth=2) +plt.plot(x, y_linear, label="Real fill", linewidth=2) +plt.step(x, y_step, where="post", label="PSM subgrid of 4", linewidth=2) plt.step(x, y_step2, where="post", label="PSM subgrid of 8", linewidth=2) plt.plot(x, y_cos2, label=r'HLBM e_h:cell size 1:1', linewidth=2) plt.plot(x, y_cos2_shift, label=r'HLBM e_h:cell size 1.25:1', linewidth=2) +plt.plot(x, y_cos2_shift_15, label=r'HLBM e_h:cell size 1.5:1', linewidth=2) plt.xlim(0, 1) plt.ylim(0, 1) @@ -60,6 +62,6 @@ plt.legend() plt.xlabel("x") plt.ylabel("y") -plt.title("Linear + Step + Smooth Cos² Ramp") +plt.title("Fill level depending on used method") plt.show() -- cgit v1.2.3