I’m solving a differential equation that has been nondimensionalized, so I’d like to change the scaling of the dependent variable for plotting. Here is my example.
using DifferentialEquations
using Plots
using Accessors
f(u, p, t) = 1.01 * u
u0 = 1 / 2
tspan = (0.0, 1.0)
prob = ODEProblem(f, u0, tspan)
sol = solve(prob, Tsit5(), reltol = 1e-8, abstol = 1e-8)
myscalingfactor = 1e2
@reset sol.t = sol.t .* myscalingfactor
plot(sol)
At the @reset
statement, I get this error:
MethodError: no method matching ODESolution(::Vector{Float64}, ::Nothing, ::Nothing, ::Vector{Float64}, ::Vector{Vector{Float64}}, ::ODEProblem{Float64, Tuple{Float64, Float64}, false, SciMLBase.NullParameters, ODEFunction{false, SciMLBase.AutoSpecialize, typeof(f), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}}, SciMLBase.StandardODEProblem}, ::Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, ::OrdinaryDiffEq.InterpolationData{ODEFunction{false, SciMLBase.AutoSpecialize, typeof(f), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Vector{Float64}, Vector{Float64}, Vector{Vector{Float64}}, OrdinaryDiffEq.Tsit5ConstantCache}, ::Bool, ::Int64, ::DiffEqBase.DEStats, ::Nothing, ::SciMLBase.ReturnCode.T)
I see this solution, but I’m not sure how to define a constructor for the complicated structure above and why it doesn’t exist in the first place if it was created by solve
?