@@ -171,7 +171,7 @@ p0 = p0 / norm(p0) # Normalization |p0|=1 for free final time
171
171
jshoot(ξ) = ForwardDiff.jacobian(shoot, ξ)
172
172
shoot!(s, ξ) = (s[:] = shoot(ξ); nothing)
173
173
jshoot!(js, ξ) = (js[:] = jshoot(ξ); nothing)
174
- # bvp_sol = fsolve(shoot!, jshoot!, ξ; show_trace=true); println(bvp_sol)
174
+ bvp_sol = fsolve(shoot!, jshoot!, ξ; show_trace=true); println(bvp_sol)
175
175
nothing # hide
176
176
```
177
177
@@ -199,37 +199,36 @@ tf = 1.210e3; p0 =-[-2.215319700438820e+01, -4.347109477345140e+01, 9.6131888072
199
199
p0 = p0 / norm(p0) # Normalization |p0|=1 for free final time
200
200
ξ = [tf; p0]; # Initial guess
201
201
202
- # bvp_sol = fsolve(shoot!, jshoot!, ξ; show_trace=true); println(bvp_sol)
202
+ bvp_sol = fsolve(shoot!, jshoot!, ξ; show_trace=true); println(bvp_sol)
203
203
nothing # hide
204
204
```
205
205
206
206
## Plots
207
207
208
208
``` @example main
209
- # tf = bvp_sol.x[1]
210
- # p0 = bvp_sol.x[2:end]
211
- # ode_sol = fr((0, tf), x0, p0)
212
- # t = ode_sol.t; N = size(t, 1)
213
- # P = ode_sol[1, :]
214
- # ex = ode_sol[2, :]
215
- # ey = ode_sol[3, :]
216
- # hx = ode_sol[4, :]
217
- # hy = ode_sol[5, :]
218
- # L = ode_sol[6, :]
219
- # cL = cos.(L)
220
- # sL = sin.(L)
221
- # w = @. 1 + ex * cL + ey * sL
222
- # Z = @. hx * sL - hy * cL
223
- # C = @. 1 + hx^2 + hy^2
224
- # q1 = @. P *((1 + hx^2 - hy^2) * cL + 2 * hx * hy * sL) / (C * w)
225
- # q2 = @. P *((1 - hx^2 + hy^2) * sL + 2 * hx * hy * cL) / (C * w)
226
- # q3 = @. 2 * P * Z / (C * w)
227
-
228
- # plt1 = plot3d(1; xlim = (-60, 60), ylim = (-60, 60), zlim = (-5, 5), title = "Orbit transfer", legend=false)
229
- # @gif for i = 1:N
230
- # push!(plt1, q1[i], q2[i], q3[i])
231
- # end every N ÷ min(N, 100)
232
- nothing
209
+ tf = bvp_sol.x[1]
210
+ p0 = bvp_sol.x[2:end]
211
+ ode_sol = fr((0, tf), x0, p0)
212
+ t = ode_sol.t; N = size(t, 1)
213
+ P = ode_sol[1, :]
214
+ ex = ode_sol[2, :]
215
+ ey = ode_sol[3, :]
216
+ hx = ode_sol[4, :]
217
+ hy = ode_sol[5, :]
218
+ L = ode_sol[6, :]
219
+ cL = cos.(L)
220
+ sL = sin.(L)
221
+ w = @. 1 + ex * cL + ey * sL
222
+ Z = @. hx * sL - hy * cL
223
+ C = @. 1 + hx^2 + hy^2
224
+ q1 = @. P *((1 + hx^2 - hy^2) * cL + 2 * hx * hy * sL) / (C * w)
225
+ q2 = @. P *((1 - hx^2 + hy^2) * sL + 2 * hx * hy * cL) / (C * w)
226
+ q3 = @. 2 * P * Z / (C * w)
227
+
228
+ plt1 = plot3d(1; xlim = (-60, 60), ylim = (-60, 60), zlim = (-5, 5), title = "Orbit transfer", legend=false)
229
+ @gif for i = 1:N
230
+ push!(plt1, q1[i], q2[i], q3[i])
231
+ end every N ÷ min(N, 100)
233
232
```
234
233
235
234
## References
0 commit comments