From 740db3dbadae2f9e9aaec6aeee0939286fa32e80 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Wed, 22 Nov 2023 17:43:23 -0500 Subject: [PATCH] Allow storing a trace object in NonlinearSolution --- Project.toml | 2 +- src/solutions/nonlinear_solutions.jl | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Project.toml b/Project.toml index 408676650..8d1f8a4de 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SciMLBase" uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462" authors = ["Chris Rackauckas and contributors"] -version = "2.8.2" +version = "2.9.0" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" diff --git a/src/solutions/nonlinear_solutions.jl b/src/solutions/nonlinear_solutions.jl index ffb68f8dc..31e319105 100644 --- a/src/solutions/nonlinear_solutions.jl +++ b/src/solutions/nonlinear_solutions.jl @@ -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 @@ -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 @@ -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) @@ -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