Skip to content

Conversation

@TorkelE
Copy link
Member

@TorkelE TorkelE commented Sep 12, 2023

Enable WP-diagrams to be created from NonlinearProblems.

Sample code:

# Fetch pakages.
using NonlinearSolve, StaticArrays, DiffEqDevTools, Plots

# Prepares NonlinearProblem.
f(u, p) = u .* u .- p
u0 = @SVector[1.0, 1.0]
p = 2.0
static_prob = NonlinearProblem(f, u0, p)
real_sol = solve(static_prob, NewtonRaphson(), reltol = 1e-15, abstol = 1e-15)

# Sets WP input.
abstols = 1.0 ./ 10.0 .^ (4:12)
reltols = 1.0 ./ 10.0 .^ (4:12)
setups = [Dict(:alg=>NewtonRaphson())
          Dict(:alg=>TrustRegion())]
solnames = ["NewtonRaphson";"TrustRegion"]

# Plots WP-diagram.
wp = WorkPrecisionSet(static_prob, abstols, reltols, setups; names=solnames, numruns=100, appxsol=real_sol, error_estimate=:l2) # Only l2 currently supported.
plot(wp)

The output here is trivial (since all cases solves the problem perfectly, giving all errors = 0.0). However, if I give the wrong input real solution we can get something like:
image

@TorkelE
Copy link
Member Author

TorkelE commented Sep 12, 2023

is it currently safe to run using JulaiFormater; format("."); to format repos? I know we currently have some problems with that for Catalyst.

@avik-pal
Copy link
Member

Format check is broken on master, so I would hold off doing that here

@ChrisRackauckas ChrisRackauckas merged commit 8f01c90 into SciML:master Sep 13, 2023
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