Skip to content

Commit

Permalink
Allow storing a trace object in NonlinearSolution
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Nov 22, 2023
1 parent f6b059c commit 740db3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SciMLBase"
uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
authors = ["Chris Rackauckas <[email protected]> and contributors"]
version = "2.8.2"
version = "2.9.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
13 changes: 7 additions & 6 deletions src/solutions/nonlinear_solutions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ or the steady state solution to a differential equation defined by a SteadyState
- `right`: if the solver is bracketing method, this is the final right bracket value.
- `stats`: statistics of the solver, such as the number of function evaluations required.
"""
struct NonlinearSolution{T, N, uType, R, P, A, O, uType2, S} <:
struct NonlinearSolution{T, N, uType, R, P, A, O, uType2, S, Tr} <:
AbstractNonlinearSolution{T, N}
u::uType
resid::R
Expand All @@ -63,6 +63,7 @@ struct NonlinearSolution{T, N, uType, R, P, A, O, uType2, S} <:
left::uType2
right::uType2
stats::S
trace::Tr
end

TruncatedStacktraces.@truncate_stacktrace NonlinearSolution 1 2
Expand All @@ -78,14 +79,14 @@ function build_solution(prob::AbstractNonlinearProblem,
left = nothing,
right = nothing,
stats = nothing,
trace = nothing,
kwargs...)
T = eltype(eltype(u))
N = ndims(u)

NonlinearSolution{T, N, typeof(u), typeof(resid), typeof(prob), typeof(alg),
typeof(original), typeof(left), typeof(stats)}(u, resid, prob, alg,
retcode, original,
left, right, stats)
typeof(original), typeof(left), typeof(stats), typeof(trace)}(u, resid, prob, alg,
retcode, original, left, right, stats, trace)
end

function sensitivity_solution(sol::AbstractNonlinearSolution, u)
Expand All @@ -94,6 +95,6 @@ function sensitivity_solution(sol::AbstractNonlinearSolution, u)

NonlinearSolution{T, N, typeof(u), typeof(sol.resid), typeof(sol.prob),
typeof(sol.alg), typeof(sol.original), typeof(sol.left),
typeof(sol.stats)}(u, sol.resid, sol.prob, sol.alg, sol.retcode,
sol.original, sol.left, sol.right, sol.stats)
typeof(sol.stats), trace(sol.trace)}(u, sol.resid, sol.prob, sol.alg, sol.retcode,
sol.original, sol.left, sol.right, sol.stats, sol.trace)
end

0 comments on commit 740db3d

Please sign in to comment.