diff --git a/dynamics.py b/dynamics.py index 030092b..b2919cc 100644 --- a/dynamics.py +++ b/dynamics.py @@ -245,12 +245,15 @@ def run_case(config_path, runtime_base, input_dir="input", output_dir="output", else: print("[run] 步骤 [模拟] 已跳过") - # 3. 检查 display.txt(新格式),不存在则从 trajectory.txt 抽帧生成 + # 3. 生成 display.txt:模拟完成后总是刷新,避免参数变更后缓存过时 disp_path_new = os.path.join(output_dir_abs, "display.txt") - if os.path.exists(disp_path_new): - print(f"[run] 发现已有 display.txt(引擎直接抽帧)") + + if engine == "python": + # Python 引擎在 run_simulation 内部已写入 display.txt + if os.path.exists(disp_path_new): + print(f"[run] 发现已有 display.txt(引擎直接抽帧)") else: - # 从 trajectory.txt 抽帧(外部引擎) + # 外部引擎:从 trajectory.txt 重新抽帧(覆盖旧的 display.txt) traj_path = os.path.join(output_dir_abs, "trajectory.txt") if not os.path.exists(traj_path): print(f"[run] 错误: 找不到 trajectory.txt 或 display.txt") diff --git a/examples/case06/input/input.txt b/examples/case06/input/input.txt index bab4691..95cbaf0 100644 --- a/examples/case06/input/input.txt +++ b/examples/case06/input/input.txt @@ -10,7 +10,7 @@ step_sample: 0 # (旧版)从 trajectory.txt 重新抽帧,默认0=不 step_plot: 0 # 绘制轨迹/能量图 → output/trajectory_plots.png step_animation: 1 # 自动播放 VisPy 3D 动画窗口(需安装 vispy) step_plot_wave: 0 # 绘制波形能量动画 -force_calc: 0 # 强制重新计算:1=跳过缓存强算,0=自动使用已有输出 +force_calc: 1 # 强制重新计算:1=跳过缓存强算,0=自动使用已有输出 plot_wave_save_gif: 1 # 输出波形 GIF(需 step_plot_wave=1) plot_wave_save_mp4: 1 # 输出波形 MP4(需 step_plot_wave=1) @@ -66,10 +66,10 @@ warmup_steps: 0 # 默认 0(立即开始记录) # 总模拟时间(秒),程序自动计算 NT = T_total / DT # 如果同时指定了 NT,以 NT 为准 -T_total: 20.0 +T_total: 100.0 # 抽帧间隔(每 NSTEP 步取一帧用于动画) -NSTEP: 10 +NSTEP: 100 # ── 时间步长 ────────────────────────────────── DT: 0.01 # 时间步长 (s)