You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is a simple throw-ball-straight-up-into-the-air example (2nd order ODE)
using ModelingToolkit, OrdinaryDiffEq, NonlinearSolve
using ModelingToolkit: t_nounits as t, D_nounits as D
# Throw ball straight up into the air@variablesy(t)
@named sys =ODESystem([
D(D(y)) ~-9.81
], t; initialization_eqs = [
y^2~0# initialize y = 0 in a way that builds an initialization problem
])
sys =structural_simplify(sys)
# Find initial throw velocity that reaches exactly 100 m after 1 s
dprob0 =ODEProblem(sys, [D(y) =>NaN], (0.0, 1.0), []; guesses = [y =>0.0])
nprob =NonlinearProblem((ics, _) ->begin
dprob =remake(dprob0, u0 =Dict(D(y) => ics[1]))
dsol =solve(dprob, Tsit5())
return [dsol[y][end] -100.0]
end, [1.0])
nsol =solve(nprob, NewtonRaphson())
This crashes with
ERROR: MethodError: no method matching Float64(::ForwardDiff.Dual{ForwardDiff.Tag{DifferentiationInterface.FixTail{…}, Float64}, Float64, 1})
The type `Float64` exists, but no method is defined for this combination of argument types when trying to construct it.
Closest candidates are:
(::Type{T})(::Real, ::RoundingMode) where T<:AbstractFloat
@ Base rounding.jl:265
(::Type{T})(::T) where T<:Number
@ Core boot.jl:900
Float64(::Float16)
@ Base float.jl:342
...
Stacktrace:
[1] #1117
@ C:\Users\herma\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1386 [inlined]
[2] (::ModelingToolkit.var"#1117#1120")(::Pair{Any, Any})
@ ModelingToolkit .\none:0
[3] iterate
@ .\generator.jl:48 [inlined]
[4] grow_to!(dest::Dict{Any, Any}, itr::Base.Generator{Dict{Any, Any}, ModelingToolkit.var"#1117#1120"})
@ Base .\abstractdict.jl:587
[5] dict_with_eltype
@ .\abstractdict.jl:641 [inlined]
[6] Dict
@ .\dict.jl:117 [inlined]
[7] ModelingToolkit.InitializationProblem{…}(sys::ODESystem, t::Float64, u0map::Dict{…}, parammap::Dict{…}; guesses::Dict{…}, check_length::Bool, warn_initialize_determined::Bool, initialization_eqs::Vector{…}, fully_determined::Nothing, check_units::Bool, use_scc::Bool, kwargs::@Kwargs{})
@ ModelingToolkit C:\Users\herma\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1385
[8] InitializationProblem
@ C:\Users\herma\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1287 [inlined]
[9] #_#1112
@ C:\Users\herma\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1265 [inlined]
[10] InitializationProblem
@ C:\Users\herma\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1264 [inlined]
[11] #InitializationProblem#1110
@ C:\Users\herma\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1253 [inlined]
[12] InitializationProblem
@ C:\Users\herma\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1252 [inlined]
[13] maybe_build_initialization_problem(sys::ODESystem, op::Dict{…}, u0map::Dict{…}, pmap::Dict{…}, t::Float64, defs::Dict{…}, guesses::Dict{…}, missing_unknowns::Set{…}; implicit_dae::Bool, kwargs::@Kwargs{…})
@ ModelingToolkit C:\Users\herma\.julia\dev\ModelingToolkit\src\systems\problem_utils.jl:546
[14] remake_initialization_data(sys::ODESystem, odefn::Function, u0::Dict{…}, t0::Float64, p::Missing, newu0::Vector{…}, newp::MTKParameters{…})
@ ModelingToolkit C:\Users\herma\.julia\dev\ModelingToolkit\src\systems\nonlinear\initializesystem.jl:343
[15] remake(prob::ODEProblem{…}; f::Missing, u0::Dict{…}, tspan::Missing, p::Missing, kwargs::Missing, interpret_symbolicmap::Bool, build_initializeprob::Bool, use_defaults::Bool, lazy_initialization::Nothing, _kwargs::@Kwargs{})
@ SciMLBase C:\Users\herma\.julia\packages\SciMLBase\XzPx0\src\remake.jl:230
...
The text was updated successfully, but these errors were encountered:
Here is a simple throw-ball-straight-up-into-the-air example (2nd order ODE)
This crashes with
The text was updated successfully, but these errors were encountered: