RMS reactors: hard-coded unpreconditioned GMRES linear solver makes stiff surface/electrochemical edge simulations fail

未关闭
#3,034 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@rwest 已经在做这个了。

开始于 2026年11月7日。

  • #3036 来自 @rwest —— 未关闭

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
backend, databases

调研方向

Start with Reactor.simulate in rmgpy/rmg/reactionmechanismsimulator_reactors.py and the referenced #2741 change to understand why the linear solver was set explicitly. Reproduce the reported solver comparison in the RMS standalone test described in the issue, then assess the proposed default or size-based choice, input-file option and logging change. Done means the selected solver configuration is exposed and documented, solver failures are visible in RMG.log, and the reported stiff simulations complete reliably.

由索引模型根据 Issue 内容生成。

描述

Note: This issue was drafted by Claude (Anthropic's AI assistant, via Claude Code), based on its diagnosis of the run described below, and posted at Richard West's request.

Context

Torrie Asifor's CO2RR-on-Cu(111) run (liquidSurfaceReactor, RMS backend, echem branch of RMS) slowed to ~4.4 h per iteration after 3 days. 67 of its 69 edge simulations ended with CVODE "corrector convergence test failed repeatedly or with |h| = hmin", most at t ≈ 1e-11 s with h ≈ 1e-19 s. Each failure takes RMS's "resurrect" branch, which adds the edge species with the largest rate, so the model was being grown by solver crashes, not by flux criteria (and the RMG log never says so).

Reactor.simulate in rmgpy/rmg/reactionmechanismsimulator_reactors.py always calls selectobjects with

solver=Main.Sundials.CVODE_BDF(linear_solver=Main.Symbol("GMRES")),

This came in with #2741 (commit 60c412573, "explicitly pass linear solver to CVODE to avoid it not being initialized"). Before that it was CVODE_BDF(), which uses a dense direct linear solve.

GMRES without a preconditioner is a poor fit for small, very stiff kinetic systems. The Newton iteration needs an accurate linear solve, and an unpreconditioned Krylov solve on an ill-conditioned Jacobian often fails to converge. That shows up as exactly the corrector-convergence failure above. A model with about 150 core+edge species is far too small to need a matrix-free method: a dense LU of a 150×150 Jacobian is trivial.

Evidence: standalone RMS test of the 84-species core (1785 reactions) from that run. It rebuilds the same ConstantTLiquidSurfaceReactor domains and interface and steps with step! as selectobjects does, but without edge analysis. tf = 1000 s, same initial conditions:

surfPotential GMRES, atol 1e-16 rtol 1e-8 (current) dense CVODE_BDF(), same tolerances dense, atol 1e-20 rtol 1e-6
−2.0 V ConvergenceFailure at t = 1.1e-5 s after 213,458 steps (63 s) reached tf in 3,381 steps (1.1 s) reached tf in 2,893 steps (0.3 s)
−1.5 V ConvergenceFailure at t = 1.6e-5 s after 178,765 steps (54 s) reached tf in 3,499 steps (1.2 s) reached tf in 2,706 steps (0.3 s)
−1.0 V ConvergenceFailure at t = 1.8e-5 s after 187,611 steps (58 s) reached tf in 3,155 steps (1.1 s) reached tf in 2,629 steps (0.3 s)

Same model, same tolerances: switching only the linear solver goes from failing after about 2×10⁵ steps to finishing in about 3×10³ steps, about 50× faster even ignoring the failure. In the full RMG run, with edge flux analysis after every step, each failing simulation took hours.

Proposal:

  1. Go back to a direct solver by default, or pick by size (dense below a few hundred species, :KLU sparse or GMRES with a preconditioner above). First find out what "not being initialized" meant in #2741, so we don't bring that bug back.
  2. Expose the choice in the input file, e.g. simulator(atol=..., rtol=..., linearSolver='dense'|'GMRES'|'KLU'), and document it in input.rst.
  3. Log RMS's "Solver failed with code … resurrecting job" in RMG.log (it doesn't reach the log now), so users can see when species are being added because the solver crashed.

See also: ReactionMechanismGenerator/ReactionMechanismSimulator.jl#280 (rate caps) and #3035 (diffusion interfaces), which came out of the same diagnosis.

🤖 Generated with Claude Code

主要语言
Python
星标
550
派生
267
平均合并
8 小时 49 分钟
30 天内合并 PR
1

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ReactionMechanismGenerator/RMG-Py 的其他 Issue

查看 ReactionMechanismGenerator/RMG-Py 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。