Skip to content

Skip converged midpoint linear solve - #20

Closed
rogeriojorge wants to merge 1 commit into
agent/report-midpoint-nonconvergencefrom
agent/skip-converged-midpoint-gmres
Closed

rogeriojorge wants to merge 1 commit into
agent/report-midpoint-nonconvergencefrom
agent/skip-converged-midpoint-gmres

Conversation

@rogeriojorge

Copy link
Copy Markdown
Member

Summary

  • guard the Newton GMRES update with lax.cond
  • return the current iterate immediately when its scaled nonlinear residual is already below tolerance

This is stacked on #19. It changes one source file with a net two-line increase. The Newton criterion, Eisenstat–Walker forcing term, GMRES configuration, maximum iterations, and converged solution are unchanged.

Motivation

The Newton loop previously called GMRES before testing norm < 1. Every successful midpoint step therefore ended with a redundant zero-iteration linear solve. A zero-iteration Krylov solve still applies the Jacobian-vector operator to form true residuals, which is expensive for the Fourier–Hermite RHS.

A 33x33, 4^3 Orszag–Tang one-step profile over dt=1e-3 ... 1e-1 found that the useful Newton solves normally required one FGMRES iteration (at most two), followed in every case by a converged check whose GMRES result was discarded.

Performance

Five fixed midpoint steps, 33x33, 4^3, CPU, median of five cached runs:

Relative total-energy drift remained exactly 1.211254265768263e-16 in all comparisons.

Validation

  • pytest -q: 5 passed
  • ruff check spectrax/midpoint_solver.py tests/test_simulation_runs.py: passed
  • git diff --check: passed

@rogeriojorge
rogeriojorge changed the base branch from agent/report-midpoint-nonconvergence to main July 13, 2026 04:39
@rogeriojorge rogeriojorge reopened this Jul 13, 2026
@rogeriojorge
rogeriojorge changed the base branch from main to agent/report-midpoint-nonconvergence July 13, 2026 04:39
@rogeriojorge
rogeriojorge marked this pull request as ready for review July 13, 2026 04:41
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
spectrax/midpoint_solver.py 98.11% <100.00%> (+0.07%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rogeriojorge

Copy link
Copy Markdown
Member Author

Squashed into #18.

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