Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Possible upper/lower triangle storage inconsistency in rates() in multi-phase equilibrium solver

オープン
#331 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
50/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
cpp
領域
backend

調査の方向性

The suspect code is in rates() in src/thermo/MultiPhaseEquilSolver.cpp: the loop assembling A(m,p) only fills the lower triangle, and the solve near line 1136 uses selfadjointView<Upper>(). Read the assembly loop and that solve to confirm whether the upper triangle is filled elsewhere before the solve. Done means either switching to selfadjointView<Lower>() or populating the upper triangle, with a maintainer confirming which one is intended and the solver results checked against a known equilibrium case.

索引モデルが issue の本文から書いたものです。

説明

I believe there may be an inconsistency in the rates() routine between the way the matrix A is assembled and the triangular part subsequently used by Eigen's self-adjoint solver.

A is populated with:

for (int p = 0; p < npr; ++p) {
    for (int m = p; m < npr; ++m) {
        for (int j = p_sizes[m]; j < p_sizes[m+1]; ++j) {
            sum = 0.0;
            for (int i = 0; i < ncr; ++i)
                sum += H(j,i)*dlamy(i,p);
            A(m,p) += y[j]*sum;
        }
    }
}

Since m >= p, this explicitly computes the lower triangular part of A, i.e. A(m,p) for m >= p. This appears intentional, since A is expected to be symmetric.

However, the resulting system is then solved with
https://github.com/mutationpp/Mutationpp/blob/7607ef4d67f4de115705f78f467b1ea48bf02c26/src/thermo/MultiPhaseEquilSolver.cpp#L1136

As I understand Eigen's SelfAdjointView, selfadjointView<Upper>() treats the upper triangular portion of the matrix as the stored representation of the self-adjoint matrix and does not use the corresponding entries in the lower triangle. I believe this is therefore causing the off-diagonal elements to be discarded in the calculation of dx.

In other words, since the assembly produces

[ a  0  0
  b  c  0
  d  e  f ]

the intended symmetric matrix is presumably

[ a  b  d
  b  c  e
  d  e  f ]

However, since the upper-triangular off-diagonal elements remain zero, selfadjointView<Upper>() represents the matrix as

[ a  0  0
  0  c  0
  0  0  f ]

instead.

Should selfadjointView<Lower>() be used here instead? Alternatively, is there some reason the upper triangle is expected to be populated elsewhere before this solve?

主要言語
C++
スター
145
フォーク
79
平均マージ
1日 15時間
マージ済み PR(30日)
2

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

mutationpp/Mutationpp のほかの issue

mutationpp/Mutationpp の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。