fix(c): read_bonds 中 rewind 后未跳过表头行导致成键数据全为空
rewind(f) 将文件指针拉回开头(含表头 'n1 n2 bond_name'), 后续 fscanf 试图将 'n1' 解析为 %d 全部失败,导致: - bond_pairs 直接用未初始化的栈垃圾 → 随机索引 - bond_stiffness/rest_lengths 保持默认值 1.0/2.0 - 弹簧力无法正确传播 → 第一个原子动后后面全不动 修复:rewind 后加 fgets(line, ...) 再次跳过表头。
This commit is contained in:
@@ -389,6 +389,7 @@ static BondData read_bonds(const char *input_dir, const AtomData *atoms) {
|
||||
char bond_name[256];
|
||||
while (fscanf(f, "%d %d %s", &tmp_a, &tmp_b, bond_name) == 3) n_lines++;
|
||||
rewind(f);
|
||||
fgets(line, sizeof(line), f); // 再次跳过表头
|
||||
|
||||
if (n_lines == 0) { fclose(f); return b; }
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ plot_wave_save_mp4: 1 # 输出波形 MP4(需 step_plot_wave=1)
|
||||
|
||||
# ── 计算引擎 ──────────────────────────────────
|
||||
# 可选: python, c, cpp, fortran, java
|
||||
engine: fortran # 默认使用 python 引擎
|
||||
engine: c # 默认使用 python 引擎
|
||||
|
||||
# ── 盒子 ──────────────────────────────────────
|
||||
box_a: 80.0 # 立方体半边长,粒子被限制在 [-box_a, box_a]³ 内
|
||||
|
||||
+60007
-60007
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user