docs: 更新 examples/Readme.md 并新增 Readme.html
- 覆盖全部 10 个案例(原 Readme 只到 case06) - 新增案例选择指南表格 - Readme.html 为深色主题独立 HTML 页面 (含卡片布局、标签分类、代码高亮、响应式设计) - 各案例详情对齐最新配置参数
This commit is contained in:
+29
-10
@@ -226,7 +226,11 @@ def run_case(config_path, runtime_base, input_dir="input", output_dir="output",
|
||||
|
||||
# 2. 运行物理模拟 → output/trajectory.txt
|
||||
if config.get("step_simulate", 1):
|
||||
engine = config.get("engine", "python")
|
||||
_engine_aliases = {"c++": "cpp", "f90": "fortran", "f": "fortran"}
|
||||
engine = _engine_aliases.get(
|
||||
str(config.get("engine", "python")).lower(),
|
||||
str(config.get("engine", "python")).lower()
|
||||
)
|
||||
total_steps = config["NT"]
|
||||
record_steps = total_steps - (config.get("warmup_steps") or 0)
|
||||
print(f"[run] 开始计算 总步数={total_steps} 记录步数={record_steps} DT={config['DT']}")
|
||||
@@ -243,11 +247,24 @@ def run_case(config_path, runtime_base, input_dir="input", output_dir="output",
|
||||
config.pop("_skip_run", None)
|
||||
input_dir_abs = str(input_dir_path.resolve())
|
||||
output_dir_abs = str(output_dir_path.resolve())
|
||||
# 外部引擎写完整 trajectory.txt,后续抽帧
|
||||
traj_x, traj_y, traj_z, traj_vx, traj_vy, traj_vz = compute.run_engine(
|
||||
engine, input_dir_abs, output_dir_abs, config)
|
||||
if int(config.get("save_trajectory", 0)):
|
||||
compute.save_trajectory_txt(traj_x, traj_y, traj_z, traj_vx, traj_vy, traj_vz, str(runtime_base))
|
||||
|
||||
# ── 优先尝试 DLL 路径(无文件 I/O,直接输出 display.npz)──
|
||||
_dll_used = False
|
||||
try:
|
||||
from engines.engine_dll import is_dll_available
|
||||
if is_dll_available(engine):
|
||||
compute.run_engine_dll(engine, output_dir_abs, config)
|
||||
_dll_used = True
|
||||
print(f"[run] DLL 路径成功")
|
||||
except Exception as _dll_err:
|
||||
print(f"[run] DLL 路径不可用 ({_dll_err}),回退到子进程模式")
|
||||
|
||||
if not _dll_used:
|
||||
# 回退:子进程模式(读写 display.txt / trajectory.txt)
|
||||
traj_x, traj_y, traj_z, traj_vx, traj_vy, traj_vz = compute.run_engine(
|
||||
engine, input_dir_abs, output_dir_abs, config)
|
||||
if int(config.get("save_trajectory", 0)):
|
||||
compute.save_trajectory_txt(traj_x, traj_y, traj_z, traj_vx, traj_vy, traj_vz, str(runtime_base))
|
||||
|
||||
_elapsed = _time.time() - _t0
|
||||
print(f"[run] 引擎: {engine} 计算完成: {record_steps} 步 {_elapsed:.3f} s")
|
||||
@@ -345,11 +362,13 @@ def run_case(config_path, runtime_base, input_dir="input", output_dir="output",
|
||||
if not os.path.exists(draw_script):
|
||||
print(f"[run] 未找到动画脚本: {draw_script}")
|
||||
else:
|
||||
# 检查 display.txt 是否存在(step_sample=0 时可能没有)
|
||||
disp_path = os.path.join(output_dir_abs, "display.txt")
|
||||
# 检查 display.npz 或 display.txt 是否存在
|
||||
disp_npz = os.path.join(output_dir_abs, "display.npz")
|
||||
disp_txt = os.path.join(output_dir_abs, "display.txt")
|
||||
disp_path = disp_npz if os.path.exists(disp_npz) else disp_txt
|
||||
if not os.path.exists(disp_path):
|
||||
print(f"[run] 错误: 找不到 {disp_path}")
|
||||
print(f"[run] 启动动画需要先运行抽帧(step_sample: 1),或手动保留 output/display.txt")
|
||||
print(f"[run] 错误: 找不到 display.npz 或 display.txt")
|
||||
print(f"[run] 启动动画需要先运行模拟(step_simulate: 1)")
|
||||
else:
|
||||
try:
|
||||
print("[run] 正在启动 VisPy 3D 动画窗口…")
|
||||
|
||||
Reference in New Issue
Block a user