Skip to content

Implement Discontinuity Detection Algorithm#3121

Open
Shreyas-Ekanathan wants to merge 37 commits into
SciML:masterfrom
Shreyas-Ekanathan:fresh-disco
Open

Implement Discontinuity Detection Algorithm#3121
Shreyas-Ekanathan wants to merge 37 commits into
SciML:masterfrom
Shreyas-Ekanathan:fresh-disco

Conversation

@Shreyas-Ekanathan
Copy link
Copy Markdown
Contributor

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

A preliminary implementation of autonomous discontinuity detection in Radau. Uses a PR to SciML base at SciML/SciMLBase.jl#1219 to modify callbacks to support a is_discontinuous flag.

@ChrisRackauckas
Copy link
Copy Markdown
Member

disco_handling should be discontinuity_detection, and needs a docstring, then I think this is good to go.

Comment thread lib/OrdinaryDiffEqCore/test/disco_benchmarks.jl Outdated
Comment thread lib/OrdinaryDiffEqCore/test/disco_benchmarks.jl Outdated
Comment thread lib/OrdinaryDiffEqCore/test/disco_tests.jl
Comment thread lib/OrdinaryDiffEqCore/test/disco_benchmarks.jl Outdated
fsallast::FSALType
rng::RNGType
#disco_prob::IntervalNonlinearProblem
disco_probs::Vector{IntervalNonlinearProblem} #should we change this?
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this isn't concrete

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah what Oscar and I had discussed was that once the callbacks are function wrapped we would store a single disco_prob and remake it each time, instead of storing a vector of all of them. Not sure if you had another approach in mind though

@inline zero_condition(cb::ContinuousCallback, out::Nothing, u, t, z, ind) = cb.condition(u, t, z)
@inline function zero_condition(cb::VectorContinuousCallback, out, u, t, z, ind)
cb.condition(out, u, t, z)
return out[ind]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

how is the ind chosen?

Comment on lines +40 to +44
return zero_condition(z.callback, z.out, z.u₁, z.dt + θ * z.dt, z, z.ind)
end

@inline zero_condition(cb::ContinuousCallback, out::Nothing, u, t, z, ind) = cb.condition(u, t, z)
@inline function zero_condition(cb::VectorContinuousCallback, out, u, t, z, ind)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this seems like code smell... it needs to do the whole array not an ind.

Copy link
Copy Markdown
Contributor Author

@Shreyas-Ekanathan Shreyas-Ekanathan May 8, 2026

Choose a reason for hiding this comment

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

but for a VCC we want to check per condition if it was hit, so the approach in disco is to iterate over the entire VCC and find the components that could be the discontinuity:

        i.condition(out_prev, uprev, t, integrator)
        i.condition(out_curr, u, t + dt, integrator)
        for j in 1:len_cb
            if (out_prev[j] * out_curr[j] < zero(out_prev[j]))
                disco_zero.ind = j
                sol = solve(disco_prob; bracket = bracket)
                tmp = sol[]
                if (!isnan(tmp) && (breakpointθ == -1 || tmp < breakpointθ)) 
                    breakpointθ = tmp 
                end 
            end
        end

So we do disco on each index of the VCC that could have triggered the step reject

@Shreyas-Ekanathan
Copy link
Copy Markdown
Contributor Author

@ChrisRackauckas @oscardssmith If you could review when you get a chance, that would be great. Test failures seem to be a strange error independent of this.

@ChrisRackauckas
Copy link
Copy Markdown
Member

The CI machine maybe ran out of disk space?

@ChrisRackauckas
Copy link
Copy Markdown
Member

The test failure looks real.

@Shreyas-Ekanathan
Copy link
Copy Markdown
Contributor Author

The test failure looks real.

I'm not really sure what is failing here (e.g. failure in AD test), DummyControllerCache does have the discontinuity_detection field and we import set_discontinuity into BDF, so little lost with this one.

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