Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link

Summary

  • Fixes issue SCC does not transfer residuals to solution object #706 where residuals were not being transferred to solution object when using SCC algorithm
  • Computes residuals for linear problems as resid = A*u - b
  • Ensures all residuals are properly computed and transferred to the solution object

Details

Previously, when solving SCC problems that contained LinearProblem components, the residuals were being passed as nothing in the build_linear_solution call. This resulted in a solution object with nothing values in the residuals array.

The fix computes the residuals for linear problems using the formula resid = A*u - b after solving, and passes them to build_linear_solution.

Test plan

  • Added a new test case "SCC Residuals Transfer" that verifies:
    • Residuals are not nothing
    • No nothing values exist in the residuals array
    • Residuals have the correct length
    • Residuals are near zero for converged solutions
    • Residuals match manually computed values
  • Verified existing tests still pass
  • Tested locally with sample SCC problem containing both linear and nonlinear components

🤖 Generated with Claude Code

Previously, when using the SCC algorithm with linear problems,
residuals were not computed and passed as nothing, resulting in
a vector with nothing values in the solution object.

This fix checks if sol.resid is nothing (which it often is for
LinearSolution) and computes residuals using the formula
`resid = A*u - b` when needed, then properly transfers them
to the solution object.

Fixes SciML#706

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@ChrisRackauckas-Claude
Copy link
Author

Updated the fix based on feedback. The LinearSolution object does have a field, but it's often by default. The updated fix now checks if is and only computes the residuals manually when needed using . This is more robust and handles both cases where the linear solver might or might not provide residuals.

@ChrisRackauckas-Claude
Copy link
Author

Updated the fix based on feedback. The LinearSolution object does have a resid field, but it's often nothing by default. The updated fix now checks if sol.resid is nothing and only computes the residuals manually when needed using resid = A*u - b. This is more robust and handles both cases where the linear solver might or might not provide residuals.

@ChrisRackauckas ChrisRackauckas merged commit f7b6add into SciML:master Sep 28, 2025
35 of 48 checks passed
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.

2 participants