-
Notifications
You must be signed in to change notification settings - Fork 132
Improve computation of epsilon in jacobian_fd #2522
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
Conversation
Review checklistThis checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging. Purpose and scope
Code quality
Documentation
Testing
Performance
Verification
Created with ❤️ by the Trixi.jl community. |
|
Something in SciML broke again. Seems like a problem with a |
|
Sorry, thanks for pointing that out. Should be fixed now. Though...
How were you doing that before? It has been a known issue that doing this was not autodiff compatible since it was built. The PRs referenced make it so that it works with autodiff. Were you testing this just with finite differencing or IMEX? Since before the fallback cache wouldn't resize for autodiff automatically. |
|
Thanks! We used finite differences, but good to know that AD should work now👍 |
|
Change to forwarddiff now! |
|
The main thing caught here is we need to better test resizing in the SciML interface. Resizing has tests in OrdinaryDiffEq but isn't actually a listed part of the interface, and there's no trait stuff for "is resizable" and what that all means. We should flesh out that interface a bit and add some earlier testing that |
Sorry for bothering again @ChrisRackauckas. Can you point me to a PR that fixed this issue? We still have the same issue in CI after rerunning. |
|
SciML/PreallocationTools.jl#135
|
|
I did a hotfix to SciMLBase that will make I think the core of your problems might be that
I assume (1) might be what you want, which is where the issues are actually all stemming from. And this may be my issue for telling @ranocha this is the path we've got to go 😅 . I still think we need to make sure the https://docs.sciml.ai/SciMLBase/stable/interfaces/Array_and_Number/ (though it's not complete, we need to define things around resizability etc.) But one of the things we have also learned from this exercise of getting better at interfaces is that I'm not sure if the linear index fix is enough to make this the right type for you though, since it would be more like (3). Right now it's more like (2) but the ragged interface is not fully complete. |
|
Thanks again. This fixed the tests. Just as a small clarification: SciML/RecursiveArrayTools.jl#454 and SciML/RecursiveArrayTools.jl#453 are not required for Trixi.jl right now, but these issues arise from another of my projects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Do you have an idea how to test this? Can we use some property of the plots you showed here and in the previous PR to catch errors introduced by chaning this again?
|
Yes, that should be possible. |
|
Great! Could you please add such a test (that fails with the previous versions), add it here, and ping me for a review afterward? |
|
Yes. |
|
I added some tests also testing properties of the spectra, which failed with the previous two implementations. This is ready for a review, @ranocha. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2522 +/- ##
==========================================
+ Coverage 95.20% 96.71% +1.51%
==========================================
Files 512 512
Lines 42446 42448 +2
==========================================
+ Hits 40410 41051 +641
+ Misses 2036 1397 -639
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@ChrisRackauckas: Thanks a lot for your help! I cannot comment on the needs of @JoshuaLampert in the other project he mentioned that triggered SciML/RecursiveArrayTools.jl#454 and SciML/RecursiveArrayTools.jl#453, but here are some thoughts on Trixi.jl: In Trixi.jl, we have a few solvers with different memory layouts. One class uses plain arrays of numbers (like Another solver class used multi-dimensional arrays of Based on your list in #2522 (comment), option 1 is fine with us as long as we can extract underlying data or view them in the multi-dimensional way we do right now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot, @JoshuaLampert!
Based on #2514 (comment)
Multiplying the initial condition in examples/tree_1d_fdsbp/elixir_advection_upwind.jl with 1e9, gives for the spectra of the Jacobian:
old version:

new version: