Skip to content

perf(modal): shift-invert block Lanczos eigenvalues for long lines - #116

Merged
SMI-Lab-Inha merged 2 commits into
devfrom
perf/modal-eigensolver
Nov 8, 2026
Merged

SMI-Lab-Inha merged 2 commits into
devfrom
perf/modal-eigensolver

Conversation

@SMI-Lab-Inha

Copy link
Copy Markdown
Owner

The nModes eigenvalue stage used LAPACK DSBGVX. That routine reduces the whole band to tridiagonal form, which costs O(n² kd) even when only a few modes are wanted. On lazy_wave_modes.dat it took 86 % of the run.

Change

The new eigenvalue stage, lanczos_lowest in CD_Modal_Solve_Band, serves every modal route: EI = 0, Hermite, and the twist variant.

  • Iteration: shift-invert block Lanczos, block size 2, so exactly repeated transverse pairs are found. It applies K⁻¹M through the banded Cholesky factor of K (DPBTRF/DPBTRS).
  • Accuracy: full M-reorthogonalisation and Rayleigh–Ritz (DSYEV). A Ritz value is accepted at a residual below 1e-10 of the eigenvalue.
  • Count certified: the Cholesky factors of K and M must exist, and an LDLᵀ inertia count of K − σM must equal the number of Ritz values below σ. σ sits in a gap above the wanted values.
  • Unchanged: shapes still come from the existing inverse iteration, and ω² from the quadruple-precision Rayleigh quotient. Ordering, normalisation, output format and fail-closed messages are the same.
  • Fallback to DSBGVX: small systems (< 200 free DOFs); many modes relative to line length; a basis above 256 MB; K or M not positive definite (slack or compressed lines); an uncertified iteration; and an inverse-iteration failure, which reruns on the DSBGVX values.
  • Sign rule: a deterministic tie-break. When two components are equal within 1e-6, the first in DOF order is made positive. Before, round-off decided the sign on symmetric lines.

Accuracy

  • On identical matrices: ω² agrees with the old stage to 0 on every modal test deck, and to 7e-16 on lazy_wave_modes.
  • Shapes: agree to 1e-13–6e-11 on the small decks and to 2.6e-8 of the largest component on the lazy wave. There the quadruple-precision eigen-residual is lower than before.
  • Printed frequencies: identical on all 13 modal decks.

Speed

Eigen-solve time, before → after, one thread:

Line Free DOFs 1 mode 10 modes 50 modes
Hermite, 1024 elements 6144 3.7 → 0.020 s 3.7 → 0.14 s 4.2 → 0.73 s
Hermite, 4000 elements 24000 57.8 → 0.079 s 55.0 → 0.51 s 58.8 → 2.85 s
EI = 0 chain, 4000 elements 11997 6.4 → 0.023 s 6.5 → 0.16 s 7.2 → 0.85 s

lazy_wave_modes.dat end to end: 4.5 s → 0.93 s.

Tests

  • test_modal checks both stages explicitly:
    • band against dense;
    • a slack string that must hand over to the band reduction;
    • a 1024-element beam that must take Lanczos;
    • two sagged lines where the stages must agree to 1e-10 in frequency and 1e-8 in shape;
    • a sixfold repeated frequency, plus an indefinite variant.
  • test_lapack_guard_pages: now covers DPBTRF, DPBTRS and DSYEV.
  • Suites: Release 365/365 on the default and Prescott kernels; Debug 365/365 with no warnings; pytest 2872 passed; Sphinx -W clean.

Effect on results

No deck-syntax change. Mode shapes differ at round-off. On symmetric lines, a few tied modes now flip sign deterministically.

The banded modal solver took its lowest eigenvalues from LAPACK DSBGVX, whose
band reduction costs O(n^2 kd) for n free DOFs and dominated the modal analysis
of a long refined line (86 % of lazy_wave_modes.dat). The eigenvalue stage is now
a block Lanczos iteration (block 2, full M-reorthogonalisation) on K^-1 M with the
banded Cholesky factor of K, at O(n) cost per vector. A Ritz value is accepted on
its residual (1e-10 of its eigenvalue); the count is certified by the Cholesky
factor (no eigenvalue at or below zero) and by the inertia of K - sigma M (an
unpivoted banded LDL^T) at a shift in a gap above the wanted values, so a
repeated frequency beyond the block size or a missed eigenvector is never
accepted. DSBGVX remains for short lines, many modes of a short line, an
indefinite or singular K, a basis that would exceed 256 MB, and an iteration
that is not certified within its basis bound; the inverse iteration, the
quadruple-precision Rayleigh quotient, the ordering and the messages are
unchanged, and a shape the Lanczos eigenvalues do not give is solved again on
the band reduction's eigenvalues.

On identical matrices the frequencies agree with the band-reduction route to
7e-16 (lazy_wave_modes.dat) and bit for bit (torsion lazy wave, synthetic lines of
100 to 4000 elements), the shapes to 2.6e-8 of their largest component, with a
smaller quadruple-precision residual than before. 10 modes of a 1024-element
finite-EI line: 3.7 s -> 0.14 s; of a 4000-element line: 55 s -> 0.51 s
(50 modes: 59 s -> 2.9 s), one thread.

A mode whose largest components are equal to round-off (the mirrored nodes of a
symmetric line) now takes its sign from the first of them, not from round-off.

CD_Modal_Solve_Band takes optional eig_method / eig_used arguments to select and
report the eigenvalue stage. test_modal runs both stages against the dense
reference, on sagged lines and on a sixfold repeated frequency;
lapack_guard_pages covers DPBTRF, DPBTRS and DSYEV.

Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T10:36:32.284193Z 3c49c5e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@read-the-docs-community

read-the-docs-community Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 CableDyn | 🛠️ Build #35731464 | 📁 Comparing 3c49c5e against latest (e8f88f5)

  🔍 Preview build  

5 files changed · ± 5 modified

± Modified

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 8d663791e4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

The [Unreleased] entries of the open changes are added together in one
change, so that they do not conflict with each other.

Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 3c49c5e0a2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@SMI-Lab-Inha
SMI-Lab-Inha merged commit 65a740e into dev Nov 8, 2026
20 of 21 checks passed
@SMI-Lab-Inha
SMI-Lab-Inha deleted the perf/modal-eigensolver branch November 9, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant