diff --git a/compute.py b/compute.py index f639e35..aef23cc 100644 --- a/compute.py +++ b/compute.py @@ -697,8 +697,6 @@ def run_from_config(config, out_dir=None): global GRAVITY_FIELD, GRAVITY_INTERACTION, ELASTIC_FORCE, DAMPING_FORCE, GRAVITY_STRENGTH global DRIVING_FORCE, DRIVER_DATA - global use_marker - ... box_a = float(config.get("box_a", 10.0)) raw_alpha = config.get("alpha", 0.2) if isinstance(raw_alpha, (list, tuple)): diff --git a/dynamics.py b/dynamics.py index b2919cc..a6d59f3 100644 --- a/dynamics.py +++ b/dynamics.py @@ -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: diff --git a/examples/case06/input/bond.txt b/examples/case06/input/bond.txt index f3b4d21..2a14f8d 100644 --- a/examples/case06/input/bond.txt +++ b/examples/case06/input/bond.txt @@ -1,2 +1,2 @@ bond_name k rest_length -k1 1.0 1.0 +k1 10.0 1.0 diff --git a/examples/case06/input/input.txt b/examples/case06/input/input.txt index 95cbaf0..fa039e5 100644 --- a/examples/case06/input/input.txt +++ b/examples/case06/input/input.txt @@ -72,7 +72,7 @@ T_total: 100.0 NSTEP: 100 # ── 时间步长 ────────────────────────────────── -DT: 0.01 # 时间步长 (s) +DT: 0.001 # 时间步长 (s) # 抽帧范围:只保存 [sample_start, sample_end) 区间内的帧 sample_start: null # null 表示从头开始(帧索引从 0 起)