fix: save_trajectory=0 时删除 trajectory.txt,所有引擎保持一致

Python 引擎:run_simulation 已正确支持 save_trajectory 
外部引擎(C/C++/Fortran):save_trajectory_txt 仅在
  save_trajectory=1 时调用;display.txt 生成后删除 trajectory.txt
补充:移除 compute.py 中重复的 'global use_marker' 和占位符
This commit is contained in:
2026-06-12 08:18:07 +08:00
parent 6298ed5b34
commit 41790a782a
4 changed files with 14 additions and 5 deletions
+12 -1
View File
@@ -238,7 +238,8 @@ def run_case(config_path, runtime_base, input_dir="input", output_dir="output",
# 外部引擎写完整 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)
compute.save_trajectory_txt(traj_x, traj_y, traj_z, traj_vx, traj_vy, traj_vz, str(runtime_base))
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")
@@ -309,6 +310,16 @@ def run_case(config_path, runtime_base, input_dir="input", output_dir="output",
header_fields=hf)
print(f"[run] 从 trajectory.txt 抽帧生成 display.txt ({n_frames} 帧)")
# 外部引擎:save_trajectory=0 时清理 trajectory.txt
save_traj = int(config.get("save_trajectory", 0))
if engine != "python" and not save_traj:
traj_path = os.path.join(output_dir_abs, "trajectory.txt")
try:
os.remove(traj_path)
print(f"[run] save_trajectory=0,已删除 {traj_path}")
except OSError:
pass
# 4. 绘图(可选)
if not no_plot and config.get("step_plot", 1):
try: