Skip to content

Conversation

@Keno
Copy link
Contributor

@Keno Keno commented Jun 17, 2023

This corrects two issues with the DAE init integration added in #401:

  1. It makes sure that shadow copy of the state in the integrator struct is reflected back into IDA (with Set u_modified in DAE initialization if the u was changed OrdinaryDiffEq.jl#1969). This needs to handle two distinct cases:
    a. Where a DiffEq DAE initialization algorithm is used directly (handled by checking u modified after the call to DAE init)
    b. Where a DiffEq DAE init is chained into the IDA default init (handled by the check at the top of IDADefaultInit.
    It also needs to make sure to reflect the values that IDADefaultInit came up with back into integrator.u to make sure that it can be read from there for anybody who might wish to inspect it.

  2. The order of save_start and initialize_dae! was reversed, causing the first entry of the solution to always be prob.u0 rather than the result of DAE initialization.

@Keno
Copy link
Contributor Author

Keno commented Jun 17, 2023

@oscardssmith Can you put together some reduced tests for all this?

Keno added a commit to Keno/OrdinaryDiffEq.jl that referenced this pull request Jun 17, 2023
Found by inspection - I think this acidentally had the same bug as
SciML/Sundials.jl#407 if save_idxs is not
`nothing`.
@Keno Keno force-pushed the kf/correctdaeinit branch from 1d231bd to cf55e8e Compare June 17, 2023 05:02
@oscardssmith
Copy link
Member

oscardssmith commented Jun 21, 2023

test added.

@ChrisRackauckas
Copy link
Member

Test fails

@oscardssmith
Copy link
Member

yeah a different test is failing. I'm pretty sure some of the changes here are invalid, but I'm investigating.

Keno and others added 4 commits July 1, 2023 10:19
Sundials.jl got an implementation of the OrdinaryDiffEq DAE initialization
interface in SciML#401. Unfortunately, it turns out that this doesn't quite work,
because the u/du in Sundials' integrator struct are not the actual memory
that IDA uses (it has an internal copy). In [1], I propose re-using `u_modified`
to inform us that the shadow copy was modified during initialization. This
is the Sundials side of that interface.

[1] SciML/OrdinaryDiffEq.jl#1969
As in OrdinaryDiffEq's version of this function, we should save_start
after DAE initialization has had a chance to change the initial guess.
@codecov
Copy link

codecov bot commented Jul 1, 2023

Codecov Report

Merging #407 (eecd601) into master (f86eea7) will increase coverage by 0.28%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #407      +/-   ##
==========================================
+ Coverage   81.44%   81.72%   +0.28%     
==========================================
  Files          11       11              
  Lines        1428     1428              
==========================================
+ Hits         1163     1167       +4     
+ Misses        265      261       -4     
Impacted Files Coverage Δ
src/common_interface/integrator_utils.jl 86.66% <100.00%> (+0.45%) ⬆️
src/common_interface/solve.jl 83.06% <100.00%> (+0.41%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ChrisRackauckas ChrisRackauckas merged commit e762f9a into SciML:master Jul 1, 2023
@oscardssmith oscardssmith deleted the kf/correctdaeinit branch July 1, 2023 15:35
@Keno
Copy link
Contributor Author

Keno commented Jul 1, 2023

SciML/OrdinaryDiffEq.jl#1969 is required for this to actually do something with the OrdinaryDiffEq inits. @oscardssmith can you make sure to add a test case that exercises that path?

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.

3 participants