Skip to content

Commit 60e4723

Browse files
committedJan 17, 2025
Format
1 parent f5937ae commit 60e4723

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
 

‎test/extensions/ad.jl

+4-3
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ fwd, back = ChainRulesCore.rrule(remake_buffer, sys, ps, idxs, vals)
115115

116116
# Find initial throw velocity that reaches exactly 10 m after 1 s
117117
dprob0 = ODEProblem(sys, [D(y) => NaN], (0.0, 1.0), []; guesses = [y => 0.0])
118-
nprob = NonlinearProblem((ics, _) -> begin
118+
function f(ics, _)
119119
dprob = remake(dprob0, u0 = Dict(D(y) => ics[1]))
120120
dsol = solve(dprob, Tsit5())
121121
return [dsol[y][end] - 10.0]
122-
end, [1.0])
122+
end
123+
nprob = NonlinearProblem(f, [1.0])
123124
nsol = solve(nprob, NewtonRaphson())
124-
@test nsol[1] 10.0/1.0 + 9.81*1.0/2 # anal free fall solution is y = v0*t - g*t^2/2 -> v0 = y/t + g*t/2
125+
@test nsol[1] 10.0 / 1.0 + 9.81 * 1.0 / 2 # anal free fall solution is y = v0*t - g*t^2/2 -> v0 = y/t + g*t/2
125126
end

0 commit comments

Comments
 (0)