Got MBH working! It can find better-than-basic-spiral trajectories
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
@testset "Find Closest" begin
|
||||
|
||||
using JuMP
|
||||
using NLsolve, PlotlyJS
|
||||
|
||||
# Initial Setup
|
||||
sc = Sc("test")
|
||||
@@ -9,10 +9,11 @@
|
||||
i = rand(0.01:0.01:π/6)
|
||||
T = 2π*√(a^3/μs["Earth"])
|
||||
prop_time = 2T
|
||||
n = 30
|
||||
n = 20
|
||||
|
||||
# A simple orbit raising
|
||||
start = oe_to_xyz([ a, e, i, 0., 0., 0. ], μs["Earth"])
|
||||
# T_craft = hcat(repeat([0.6], n), repeat([0.], n), repeat([0.], n))
|
||||
Tx, Ty, Tz = conv_T(repeat([0.6], n), repeat([0.], n), repeat([0.], n),
|
||||
start,
|
||||
sc.mass,
|
||||
@@ -23,35 +24,26 @@
|
||||
new_T = 2π*√(xyz_to_oe(final, μs["Earth"])[1]^3/μs["Earth"])
|
||||
|
||||
# This should be close enough to 0.6
|
||||
Tx, Ty, Tz = conv_T(repeat([0.6], n), repeat([0.], n), repeat([0.], n),
|
||||
Tx, Ty, Tz = conv_T(repeat([0.59], n), repeat([0.01], n), repeat([0.], n),
|
||||
start,
|
||||
sc.mass,
|
||||
sc,
|
||||
prop_time,
|
||||
μs["Earth"])
|
||||
result, solution = nlp_solve(start,
|
||||
final,
|
||||
sc,
|
||||
μs["Earth"],
|
||||
0.0,
|
||||
prop_time,
|
||||
Tx,
|
||||
Ty,
|
||||
Tz)
|
||||
# solver_options=("max_cpu_time" => 30.))
|
||||
result = nlp_solve(start, final, sc, μs["Earth"], 0.0, prop_time, hcat(Tx, Ty, Tz))
|
||||
|
||||
# Test and plot
|
||||
@test JuMP.termination_status(result) == MOI.OPTIMAL
|
||||
@test converged(result)
|
||||
path1 = prop(zeros((100,3)), start, sc, μs["Earth"], T)[1]
|
||||
path2, mass, calc_final = prop(treat_inputs(JuMP.value.(solution)), start, sc, μs["Earth"], prop_time)
|
||||
path2, mass, calc_final = prop(tanh.(result.zero), start, sc, μs["Earth"], prop_time)
|
||||
path3 = prop(zeros((100,3)), calc_final, sc, μs["Earth"], new_T)[1]
|
||||
path4 = prop(zeros((100,3)), final, sc, μs["Earth"], new_T)[1]
|
||||
savefig(plot_orbits([path1, path2, path3, path4],
|
||||
labels=["initial", "transit", "after transit", "final"],
|
||||
colors=["#FFFFFF","#FF4444","#44FF44","#4444FF"]),
|
||||
"../plots/find_closest_test.html")
|
||||
# if termination_status(result) == :OPTIMAL
|
||||
# @test norm(calc_final - final) < 1e-4
|
||||
# end
|
||||
if converged(result)
|
||||
@test norm(calc_final - final) < 1e-4
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user