feat: 新增波形能量动画系统 plot_wave.py
- 创建 plot_wave.py: 从 display.txt 读取原子位移数据 绘制纵波(x) + 横波(y) + 横波(z) 波形随时间的动画 同时绘制系统动能/弹性势能/总能量/输入功率(dE/dt)时变曲线 输出 wave_animation.gif - 所有 input.txt 新增 step_plot_wave: 0 开关 - case05 开启 step_plot_wave: 1 - dynamics.py disp_data 新增 bond_stiffness/bond_rest_lengths - 更新案例文档
This commit is contained in:
+12
-1
@@ -125,7 +125,7 @@ def run_case(config_path, runtime_base, input_dir="input", output_dir="output",
|
||||
print(f"[run] 同时指定了 T_total 和 NT,使用 NT={config['NT']}")
|
||||
|
||||
# 显示步骤控制信息
|
||||
steps_info = {k: config.get(k, 1) for k in ["step_simulate", "step_sample", "step_plot", "step_animation"]}
|
||||
steps_info = {k: config.get(k, 1) for k in ["step_simulate", "step_sample", "step_plot", "step_plot_wave", "step_animation"]}
|
||||
step_flags = ", ".join(f"{k}={v}" for k, v in steps_info.items())
|
||||
print(f"[run] 步骤开关: {step_flags}")
|
||||
|
||||
@@ -295,6 +295,8 @@ def run_case(config_path, runtime_base, input_dir="input", output_dir="output",
|
||||
"atom_velocities": data["atom_velocities"] if "atom_velocities" in data else np.array([[float(data["VX0"]), float(data["VY0"]), float(data["VZ0"])]]),
|
||||
"atom_fixed": data["atom_fixed"] if "atom_fixed" in data else np.array([[0, 0, 0]]),
|
||||
"bond_pairs": data.get("bond_pairs", np.zeros((0, 2), dtype=np.int64)).tolist(),
|
||||
"bond_stiffness": data.get("bond_stiffness", np.zeros(0, dtype=np.float64)).tolist(),
|
||||
"bond_rest_lengths": data.get("bond_rest_lengths", np.zeros(0, dtype=np.float64)).tolist(),
|
||||
"warmup_steps": warmup_steps,
|
||||
"sample_start": sample_start,
|
||||
"sample_end": sample_end,
|
||||
@@ -500,6 +502,15 @@ def run_case(config_path, runtime_base, input_dir="input", output_dir="output",
|
||||
else:
|
||||
print("[run] 运行 python draw.py 查看动画。")
|
||||
|
||||
# 6. 波形能量动画(可选)
|
||||
if config.get("step_plot_wave", 0):
|
||||
try:
|
||||
import plot_wave as pw
|
||||
print("[run] 正在绘制波形与能量图…")
|
||||
pw.plot_wave(str(output_dir_abs))
|
||||
except Exception as e:
|
||||
print(f"[run] 绘制波形图失败: {e}")
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="物理模拟统一入口")
|
||||
|
||||
Reference in New Issue
Block a user