Commit Graph

10 Commits

Author SHA1 Message Date
admin d489222eaf fix: driven atoms now oscillate around their initial equilibrium position
Previously, apply_driving_force set absolute position to A*cos(2π f t + φ),
ignoring the atom's initial coordinates. For atoms not at the origin (e.g.,
atom 120 at x=119), this incorrectly forced them back toward the origin each
step, causing severe distortion and numerical explosion.

Fix: store each driven atom's initial position as eq_pos/eq_x/eq_y/eq_z at
load time; position is now eq + A*cos(2π f t + φ) in all four engines
(Python, C, C++, Fortran).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 07:23:25 +08:00
admin e62e536cee feat: 真蛙跳法重构(Python/C/C++/Fortran 四引擎统一)
- 新增 compute_accel_conservative / accel_conservative:
  保守力加速度(弹簧+重力+原子间引力),不含阻尼,供蛙跳专用
- 重写 leapfrog_step / leapfrog_full:
  - 无阻尼:纯辛积分器,每步 1 次力计算(原 Velocity-Verlet 需 2 次)
  - 有阻尼:半隐式处理 v(t+dt/2)=[v(t-dt/2)*(1-α)+a_c*dt]/(1+α),无条件稳定
- 主循环加初始化反向半步 v(-dt/2)=v(0)-0.5*a_c(0)*dt
- 修复 C/C++ number of frames 字段写采样帧数而非总积分步数的 bug
- Python 引擎:新增 display.npz 二进制格式,draw.py/plot_wave.py 优先读取
- 编译参数统一为 -O3 -march=native -ffast-math
2026-06-12 18:36:37 +08:00
admin c158c74609 perf: 降低 JSON 输出精度 15→8 位 + 添加 I/O 阶段提示
- C/C++/Fortran 引擎:%.15g/setprecision(15)/g0 → %.8g/g0.8
- 添加 "正在写入轨迹数据…" 提示,说明 100% 后的等待原因
- trajectory.txt 文件从 419MB → 407MB(仍有优化空间)
2026-06-12 05:53:27 +08:00
admin db50ac6d4d feat: 外部引擎实时进度条 + C引擎read_bonds rewind修复
1. 引擎端:C/C++/Fortran 主循环每 1% 输出 progress 到 stdout
2. compute.py:读取 "[xxx] progress: N/total" 行更新 tqdm
3. 移除不准的时间估算逻辑,改用真实引擎进度
4. C引擎 read_bonds:rewind 后补 fgets 跳表头
5. gitignore 添加 output_test/
2026-06-11 21:36:30 +08:00
admin 1fd87cc33b fix(fortran): 修复 JSON 输出缺少逗号导致解析失败
write_json 中 bond_rest_lengths 后面缺少逗号,
导致 JSON 解码器在 driving_force 前报错:
  JSONDecodeError: Expecting ',' delimiter
将 has_next 从 .false. 改为 .true.,空数组版本也补上逗号。
2026-06-11 19:14:54 +08:00
admin b783cbb981 fix(fortran): 修复 read_coord 中 line(0:0) 字符串越界导致崩溃
错误码 3221225785 (0xC0000005 = STATUS_ACCESS_VIOLATION) 由
read_coord 中列数统计的双重条件导致:
  line(i:i) /= ' ' .and. (i == 1 .or. line(i-1:i-1) == ' ')
Fortran 不保证 .or. 短路求值,当 i=1 时 line(0:0) 触发
内存越界。拆分为嵌套 if 块,确保只有在 i>1 时才访问
line(i-1:i-1)。
2026-06-11 19:11:34 +08:00
admin b9ec622808 fix: C/C++/Fortran 引擎补齐 wrap_position 和 t=0 驱动力
- 三引擎均新增 wrap_position 周期边界回绕(调用在 limit_in_box 后)
- 三引擎均新增 t=0 驱动力初始调用(在预热循环前)
- 至此三引擎算法与 Python 完全一致
2026-06-11 18:57:41 +08:00
admin 685234c84f feat: 为 C/C++/Fortran 引擎增加驱动力(driving_force)支持
- param.json 新增 driving_force 开关
- C 引擎: 新增 DriverData 结构体、read_driver()、apply_driving_force()
- C++ 引擎: 同上(C++ 风格实现)
- Fortran 引擎: 同上(Fortran 90 风格实现)
- 修复 JSON 输出末尾逗号导致加载失败的问题
- 编译通过并验证 C 引擎运行正常(100000步/6.6s)
2026-06-11 09:19:34 +08:00
admin 5de80d4f7e modified: CMakeLists.txt
modified:   INSTALL.md
	modified:   README.md
	modified:   build_release_zip.py
	modified:   compute.py
	new file:   doc/index.html
	modified:   dynamics.py
	modified:   engines/c/main.c
	modified:   engines/cpp/main.cpp
	modified:   engines/fortran/main.f90
	modified:   examples/case01/input/coord.txt
	renamed:    examples/case01/input/parameters.yaml -> examples/case01/input/input.txt
	modified:   examples/case01/run_dynamics.py
	new file:   examples/case02/input/bond.txt
	new file:   examples/case02/input/connection.txt
	new file:   examples/case02/input/coord.txt
	new file:   examples/case02/input/input.txt
	new file:   examples/case02/run_dynamics.py
2026-05-20 16:03:59 +08:00
admin 45513fe334 init 2026-05-17 08:47:25 +08:00