Skip to content

Conversation

@mortenengen
Copy link
Member

This is an experiment to use warnings instead of exceptions to indicate that an iterative solution does not reach convergence.

When no convergence is reached, it can be useful to return some calculation results to the user, so that these results can be examined, and measures can be implemented.

In the current implementation, no convergence is indicated by raising an exception, and therefore, no results are returned from the iterative solver. In this PR, a custom warning is shown instead, and the results at the time of the warning was shown are returned to the user.

To make sure that the warning is always shown, a custom filter is added. The user can always override this behavior, e.g. only showing it once, completely ignoring it, or even raising it as an error.

@mortenengen mortenengen added the sections Development of sections label Sep 29, 2025
@mortenengen mortenengen moved this to Under review 👀 in PR tracker Sep 29, 2025
@mortenengen mortenengen moved this from Under review 👀 to New ✨ in PR tracker Sep 29, 2025
Copy link
Collaborator

@talledodiego talledodiego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea seems solid to me.
I tested it in a jupyter notebook and it seems to show correctly warnings each time.
We can probably extend this to other algorithms where we raise an exception for reaching the maximum number of iterations.

@mortenengen
Copy link
Member Author

The idea seems solid to me. I tested it in a jupyter notebook and it seems to show correctly warnings each time. We can probably extend this to other algorithms where we raise an exception for reaching the maximum number of iterations.

Would you like to explore the idea in other algorithms? You have more insight in the other methods on the section_calculator than me, so perhaps you also have some opinions on where we could replace exceptions with warnings?

@talledodiego
Copy link
Collaborator

Would you like to explore the idea in other algorithms? You have more insight in the other methods on the section_calculator than me, so perhaps you also have some opinions on where we could replace exceptions with warnings?

Sure! I will work on this same PR. Hopefully during tonight's session

@talledodiego
Copy link
Collaborator

@mortenengen finished here from my side.
Basically all is a warning now.
The only peculiar behavior is for moment-curvature for which if we have a NoConvergenceWarning we return the result up to the last converged step.
Meanwhile I made more robust the _prefind_range algorithm to work especially in cases with high axial load ratios.

Up for your review.

@talledodiego talledodiego marked this pull request as ready for review October 20, 2025 20:03
@mortenengen mortenengen moved this from New ✨ to Under review 👀 in PR tracker Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sections Development of sections

Projects

Status: Under review 👀

Development

Successfully merging this pull request may close these issues.

3 participants