fix(compute): 校准测速使用真实临时目录替代 os.devnull
os.devnull 在 Windows 上为 NUL,外部引擎(C/C++/Fortran) 试图写入 NUL/trajectory.txt 会失败退出,导致校准时间 完全无效,进度条按错误估计跑(例如卡在 59% 不动)。 改为创建 _calib_out 临时目录,校准后清理。 现在进度条显示正确的剩余时间估计(如 [00:00<00:11])。
This commit is contained in:
+9
-1
@@ -719,10 +719,18 @@ def run_engine(engine, input_dir, output_dir, config):
|
||||
_calib_path = os.path.join(script_dir, "engines", engine, "_calib.json")
|
||||
with open(_calib_path, "w", encoding="utf-8") as _cf:
|
||||
json.dump(_calib_param, _cf, indent=2)
|
||||
_calib_outdir = os.path.join(script_dir, "engines", engine, "_calib_out")
|
||||
os.makedirs(_calib_outdir, exist_ok=True)
|
||||
_ct0 = time.time()
|
||||
subprocess.run(
|
||||
[engine_path, os.path.abspath(input_dir), os.devnull, _calib_path],
|
||||
[engine_path, os.path.abspath(input_dir), _calib_outdir, _calib_path],
|
||||
capture_output=True, timeout=60)
|
||||
# 清理校准临时文件
|
||||
for _f in os.listdir(_calib_outdir):
|
||||
try: os.remove(os.path.join(_calib_outdir, _f))
|
||||
except OSError: pass
|
||||
try: os.rmdir(_calib_outdir)
|
||||
except OSError: pass
|
||||
os.remove(_calib_path)
|
||||
_calib_elapsed = max(time.time() - _ct0, 0.001)
|
||||
_overhead = _calib_elapsed * 0.15
|
||||
|
||||
@@ -16,7 +16,7 @@ plot_wave_save_mp4: 1 # 输出波形 MP4(需 step_plot_wave=1)
|
||||
|
||||
# ── 计算引擎 ──────────────────────────────────
|
||||
# 可选: python, c, cpp, fortran, java
|
||||
engine: fortran # 默认使用 python 引擎
|
||||
engine: fortran # 默认使用 python 引擎
|
||||
|
||||
# ── 盒子 ──────────────────────────────────────
|
||||
box_a: 80.0 # 立方体半边长,粒子被限制在 [-box_a, box_a]³ 内
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user