Spaces:
Sleeping
Sleeping
Commit
·
091edc3
1
Parent(s):
d6700a9
Time Slider Labels, Job Initiated Logging
Browse files
qlbm.py
CHANGED
|
@@ -154,6 +154,7 @@ state.update({
|
|
| 154 |
"simulation_has_run": False,
|
| 155 |
"time_val": 0,
|
| 156 |
"max_time_step": 0,
|
|
|
|
| 157 |
"simulation_backend_ready": _SIMULATION_CAN_RUN,
|
| 158 |
"simulation_backend_note": _SIMULATION_BACKEND_NOTE,
|
| 159 |
"simulation_backend_mode": _SIMULATION_MODE_LABEL,
|
|
@@ -755,7 +756,19 @@ def run_simulation():
|
|
| 755 |
state.simulation_progress = 0
|
| 756 |
state.status_message = "Running simulation..."
|
| 757 |
state.status_type = "info"
|
| 758 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 759 |
|
| 760 |
last_logged_percent = 0
|
| 761 |
def _progress_callback(percent):
|
|
@@ -836,6 +849,8 @@ def run_simulation():
|
|
| 836 |
|
| 837 |
state.max_time_step = len(frames) - 1
|
| 838 |
state.time_val = 0
|
|
|
|
|
|
|
| 839 |
state.simulation_has_run = True
|
| 840 |
|
| 841 |
# The plotter is already updated by the function, but we ensure view update
|
|
@@ -1000,9 +1015,10 @@ def update_time_frame(time_val, **_):
|
|
| 1000 |
plotter.add_axes()
|
| 1001 |
plotter.show_grid()
|
| 1002 |
|
| 1003 |
-
# Update time label
|
| 1004 |
t_val = simulation_times[idx] if idx < len(simulation_times) else idx
|
| 1005 |
-
|
|
|
|
| 1006 |
|
| 1007 |
# Enable picking
|
| 1008 |
_ensure_point_picking(on_pick_point)
|
|
@@ -1255,7 +1271,7 @@ with SinglePageLayout(server) as layout:
|
|
| 1255 |
with vuetify3.VCard(classes="mb-2"):
|
| 1256 |
vuetify3.VCardTitle("Time", classes="text-subtitle-2 font-weight-bold text-primary")
|
| 1257 |
with vuetify3.VCardText():
|
| 1258 |
-
vuetify3.VSlider(label="Time
|
| 1259 |
vuetify3.VAlert(v_if="time_steps > 100", type="warning", variant="tonal", density="compact", children=["Warning: High time steps may increase runtime."], classes="mt-2")
|
| 1260 |
|
| 1261 |
# Backends
|
|
@@ -1374,17 +1390,21 @@ with SinglePageLayout(server) as layout:
|
|
| 1374 |
|
| 1375 |
# Time Slider (visible only after simulation run)
|
| 1376 |
with vuetify3.VContainer(v_if="simulation_has_run", classes="px-4 pb-4", style="width: 90%; flex: 0 0 auto;"):
|
| 1377 |
-
vuetify3.VSlider(
|
| 1378 |
v_model=("time_val", 0),
|
| 1379 |
min=0,
|
| 1380 |
max=("max_time_step", 10),
|
| 1381 |
step=1,
|
| 1382 |
-
label="Time
|
| 1383 |
thumb_label="always",
|
| 1384 |
density="compact",
|
| 1385 |
hide_details=True,
|
| 1386 |
color="primary"
|
| 1387 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1388 |
|
| 1389 |
# Console Window (In-column)
|
| 1390 |
with vuetify3.VCard(classes="mt-1", style="font-size: 0.8rem; flex: 0 0 auto;"):
|
|
|
|
| 154 |
"simulation_has_run": False,
|
| 155 |
"time_val": 0,
|
| 156 |
"max_time_step": 0,
|
| 157 |
+
"time_slider_labels": [], # Formatted time labels for slider thumb
|
| 158 |
"simulation_backend_ready": _SIMULATION_CAN_RUN,
|
| 159 |
"simulation_backend_note": _SIMULATION_BACKEND_NOTE,
|
| 160 |
"simulation_backend_mode": _SIMULATION_MODE_LABEL,
|
|
|
|
| 756 |
state.simulation_progress = 0
|
| 757 |
state.status_message = "Running simulation..."
|
| 758 |
state.status_type = "info"
|
| 759 |
+
|
| 760 |
+
# Log initial configuration
|
| 761 |
+
config_lines = [
|
| 762 |
+
"Job Initiated",
|
| 763 |
+
f" Grid Size: {state.grid_size} × {state.grid_size} × {state.grid_size}",
|
| 764 |
+
f" Time Steps: {state.time_steps}",
|
| 765 |
+
f" Distribution: {state.dist_type}",
|
| 766 |
+
f" Boundary: {state.boundary_condition}",
|
| 767 |
+
f" Backend: {state.selected_backend}",
|
| 768 |
+
f" Velocity: vx={state.vx_expr}, vy={state.vy_expr}, vz={state.vz_expr}",
|
| 769 |
+
]
|
| 770 |
+
for line in config_lines:
|
| 771 |
+
log_to_console(line)
|
| 772 |
|
| 773 |
last_logged_percent = 0
|
| 774 |
def _progress_callback(percent):
|
|
|
|
| 849 |
|
| 850 |
state.max_time_step = len(frames) - 1
|
| 851 |
state.time_val = 0
|
| 852 |
+
# Build formatted time labels for slider thumb (e.g., "0.0", "0.5", "1.0", ...)
|
| 853 |
+
state.time_slider_labels = [f"{t:.1f}" for t in times] if times else [str(i) for i in range(len(frames))]
|
| 854 |
state.simulation_has_run = True
|
| 855 |
|
| 856 |
# The plotter is already updated by the function, but we ensure view update
|
|
|
|
| 1015 |
plotter.add_axes()
|
| 1016 |
plotter.show_grid()
|
| 1017 |
|
| 1018 |
+
# Update time label (use actual time from simulation_times)
|
| 1019 |
t_val = simulation_times[idx] if idx < len(simulation_times) else idx
|
| 1020 |
+
state.current_time_label = f"{t_val:.2f}" if isinstance(t_val, float) else str(t_val)
|
| 1021 |
+
plotter.add_text(f"Time: {t_val:.2f}" if isinstance(t_val, float) else f"Time: {t_val}", name="time_label", position="upper_right")
|
| 1022 |
|
| 1023 |
# Enable picking
|
| 1024 |
_ensure_point_picking(on_pick_point)
|
|
|
|
| 1271 |
with vuetify3.VCard(classes="mb-2"):
|
| 1272 |
vuetify3.VCardTitle("Time", classes="text-subtitle-2 font-weight-bold text-primary")
|
| 1273 |
with vuetify3.VCardText():
|
| 1274 |
+
vuetify3.VSlider(label="Total Time", v_model=("time_steps", 10), min=0, max=2000, step=10, thumb_label="always", show_ticks="always", color="primary", density="compact", hide_details=True)
|
| 1275 |
vuetify3.VAlert(v_if="time_steps > 100", type="warning", variant="tonal", density="compact", children=["Warning: High time steps may increase runtime."], classes="mt-2")
|
| 1276 |
|
| 1277 |
# Backends
|
|
|
|
| 1390 |
|
| 1391 |
# Time Slider (visible only after simulation run)
|
| 1392 |
with vuetify3.VContainer(v_if="simulation_has_run", classes="px-4 pb-4", style="width: 90%; flex: 0 0 auto;"):
|
| 1393 |
+
with vuetify3.VSlider(
|
| 1394 |
v_model=("time_val", 0),
|
| 1395 |
min=0,
|
| 1396 |
max=("max_time_step", 10),
|
| 1397 |
step=1,
|
| 1398 |
+
label="Time",
|
| 1399 |
thumb_label="always",
|
| 1400 |
density="compact",
|
| 1401 |
hide_details=True,
|
| 1402 |
color="primary"
|
| 1403 |
+
):
|
| 1404 |
+
vuetify3.Template(
|
| 1405 |
+
v_slot_thumb_label="{ modelValue }",
|
| 1406 |
+
children=["{{ time_slider_labels[modelValue] || modelValue }}"]
|
| 1407 |
+
)
|
| 1408 |
|
| 1409 |
# Console Window (In-column)
|
| 1410 |
with vuetify3.VCard(classes="mt-1", style="font-size: 0.8rem; flex: 0 0 auto;"):
|