@@ -42,39 +42,20 @@ function test_goddard_indirect()
4242 end
4343
4444 # tests
45- t1 = 0.025246759388000528
46- t2 = 0.061602092906721286
47- t3 = 0.10401664867856217
48- tf = 0.20298394547952422
49- p0 = [ 3.9428857983400074 , 0.14628855388160236 , 0.05412448008321635 ]
45+ p0 = [ 3.9457646586891744 , 0.15039559623165552 , 0.05371271293970545 ]
46+ t1 = 0.023509684041879215
47+ t2 = 0.059737380899876
48+ t3 = 0.10157134842432228
49+ tf = 0.20204744057100849
5050
51- # test shooting function
51+ # test shooting function with solve from NonlinearSolve
5252 s = zeros (eltype (p0), 7 )
53- shoot! (s, p0, t1, t2, t3, tf)
54- s_guess_sol = [
55- - 0.02456074767656735 ,
56- - 0.05699760226157302 ,
57- 0.0018629693253921868 ,
58- - 0.027013078908634858 ,
59- - 0.21558816838342798 ,
60- - 0.0121146739026253 ,
61- 0.015713236406057297 ,
62- ]
63- @test s ≈ s_guess_sol atol = 1e-6
64-
65- # solve and compare
6653 ξ0 = [p0; t1; t2; t3; tf]
67- backend = AutoForwardDiff ()
68- nle! = (s, ξ) -> shoot! (s, ξ[1 : 3 ], ξ[4 ], ξ[5 ], ξ[6 ], ξ[7 ])
69- jnle! = (js, ξ) -> jacobian! (nle!, similar (ξ), js, backend, ξ)
70- indirect_sol = fsolve (nle!, jnle!, ξ0; show_trace= true )
71-
72- p0 = indirect_sol. x[1 : 3 ]
73- t1 = indirect_sol. x[4 ]
74- t2 = indirect_sol. x[5 ]
75- t3 = indirect_sol. x[6 ]
76- tf = indirect_sol. x[7 ]
77-
78- shoot! (s, p0, t1, t2, t3, tf)
54+ shoot! (s, ξ, λ) = shoot! (s, ξ[1 : 3 ], ξ[4 ], ξ[5 ], ξ[6 ], ξ[7 ])
55+ prob = NonlinearProblem (shoot!, ξ0)
56+ sol = solve (prob)
57+ ξ = sol. u
58+ p0, t1, t2, t3, tf = ξ[1 : 3 ], ξ[4 ], ξ[5 ], ξ[6 ], ξ[7 ]
7959 @test norm (s) < 1e-6
60+
8061end
0 commit comments