-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about KINSOL behavior #500
Comments
You should not be seeing |
The second call you are seeing is in fact for a finite difference approximation.
Your log is not quite right (logically) w.r.t. the actual control flow. Here is a better representation that might make things seem more sensible:
First, see this section in the KINSOL docs for an outline of the KINSOL Picard scheme. For Iteration 1, the first call from For Iteration 2, the first call to |
Hi @balos1 -- many thanks for helping me through this. I have to admit that I am quite confused by what it is that I saw on Sunday because I can no longer reproduce the backtraces; I didn't change any of my codes, just recompiled everything on my system and something in there led to a change that ensured that I really do get the Newton scheme now. Anyway, that's my problem :-( That said, here's now the backtrace:
This backtrace looks more like a Newton method, but two questions remain for me:
|
A quick answer to your first question - if you are using Picard (and not regular fixed point) and have set things up to use the Jacobian for L then the Picard iteration is exactly Newton's method. |
I suspect the second residual computation is still coming from a finite difference approximation. Also, it would be helpful to know where your print statements are occurring in relation to KINSOL. I assume:
|
On 6/4/24 15:32, cswoodward wrote:
A quick answer to your first question - if you are using Picard (and not
regular fixed point) and have set things up to use the Jacobian for L then the
Picard iteration is exactly Newton's method.
Excellent, thank you -- yes, we are providing the Jacobian
(geodynamics/aspect#5698 (comment)), so
that makes sense.
|
As for the other issue: I have those print statements in the user-provided callbacks. When providing backtraces, I put a breakpoint on the line that prints the output and drop all frames not pertinent. This is the full backtrace for the first call (at
Frame 9 is the The second call to the residual function (at the slightly perturbed point
Here, frame 12 is In other words, the call that surprises me happens from |
I am suspicious that there is a bug in the interfacing to KINSOL or perhaps in KINSOL itself. Specifically, I see that you're providing a custom @gardner48 What do you think? |
Yea, good question. I don't think we ever really understood what to pass there. We store, apply, access, and solve with solvers ourselves. All this happens in what users provide in the Let me know if you'd like me to try anything else and I'd be happy to report back! |
@balos1 I assume you mean something like this?
This works in the sense that it doesn't trigger the UNREACHABLE position (so the callback is never invoked) but it also does not change the output. I should say, in case it matters, that I'm using SUNDIALS 5.7. If you think that would help, I would gladly update to a newer version. |
@bangerth I can't say I am sure it would help, but if you are able to try out the latest 6.x or 7.0.0 that would be great. |
@balos1 I will give this a try next week. Let me ask this differently: I take it from your comments that you don't expect the second and fourth call to the residual, and in fact that you didn't expect In our interfaces, we (perhaps an oversight?) don't make the |
@bangerth Yes, I did not expect What I am not sure about now (and what I will be talking about with the team) is if this really is desired behavior. |
I see. Thanks for inquiring -- I look forward to hearing back what you learn from your team then! |
I played some more with this and added the following code block to our KINSOL interfaces:
The intent is to set a function that would perform the |
Background: We are trying to convert a number of places in the ASPECT project (https://github.com/geodynamics/aspect/) to use KINSOL instead of hand-rolled nonlinear solvers. ASPECT is a code for large-scale simulation of processes in the Earth based on deal.II.
In a test case for a really simple case extracted by my colleague @bobmyhill (reduced from geodynamics/aspect#5698), we are trying to solve for a root of a one-argument function
f(x)
for which we get the following sequence of callbacks when usingKIN_NONE
(=Newton):I've got a number of questions about this sort of log:
KIN_NONE
(=Newton) orKIN_PICARD
. This is surprising.If it is of any help, I've annotated every one of the residual calls above with the last KINSOL functions that invoked the call to the user-supplied residual:
I assume (but don't know) that the functions named "Picard" are also doing the Newton method?
The text was updated successfully, but these errors were encountered: