Succesful MBH runs, with some improvements
This commit is contained in:
@@ -11,53 +11,32 @@
|
||||
norm_mass = (m.start_mass - prop(m)[7]) / m.start_mass
|
||||
norm_C3 = ( m.launch_v∞ ⋅ m.launch_v∞ ) / C3
|
||||
norm_v∞ = norm(m.phases[end].v∞_in) / v∞
|
||||
return 3norm_mass + norm_C3 + norm_v∞
|
||||
return norm_mass + norm_C3 + norm_v∞
|
||||
end
|
||||
|
||||
# Mission Parameters that won't change (they're very lenient)
|
||||
sc, fuel = bepi, 3_600.
|
||||
c3, v∞ = 100., 20.
|
||||
sc, fuel = bepi, 2_000.
|
||||
max_c3, max_v∞ = 100., 20.
|
||||
launch_window = DateTime(2022,1,1), DateTime(2024,12,25)
|
||||
latest_arrival = DateTime(2034,12,25)
|
||||
|
||||
# Convenience function for these tests
|
||||
Thesis.mbh(fbs, lw, la, sp, dp) = mbh(fbs, sc, fuel, lw, c3, v∞, la, easy_cost,
|
||||
search_patience=sp, drill_patience=dp, verbose=true)
|
||||
Thesis.mbh(fbs) = mbh(fbs, sc, sc.dry_mass + fuel, launch_window, max_c3, max_v∞, latest_arrival,
|
||||
easy_cost, search_patience=500, drill_patience=20, verbose=true, test=true)
|
||||
function log(m::Mission, archive::Vector{Mission})
|
||||
p = plot(m, title="MBH Test Solution")
|
||||
savefig(p,"../plots/mbh_test_$(length(m.phases))_phase.html")
|
||||
store(m, "missions/mbh_$(length(m.phases))_phase_best")
|
||||
store(archive, "missions/mbh_$(length(m.phases))_phase_archive")
|
||||
end
|
||||
|
||||
# Again, we're going to test a simple case first
|
||||
# This one seems to converge really easily, so we don't search much
|
||||
# For all of these, this is a test, not actual optimization, so we don't drill much either
|
||||
launch_window = DateTime(1992,11,1), DateTime(1992,12,1)
|
||||
latest_arrival = DateTime(1993,6,1)
|
||||
planets = [ Earth, Venus ]
|
||||
best, archive = mbh(planets, launch_window, latest_arrival, 10, 5)
|
||||
@test typeof(best) == Mission
|
||||
p = plot(best, title="MBH Test Solution")
|
||||
savefig(p,"../plots/mbh_test_1_phase.html")
|
||||
store(best, "missions/mbh_1_phase_best")
|
||||
store(archive, "missions/mbh_1_phase_archive")
|
||||
# Start simple and get more complex
|
||||
tests = [Earth, Jupiter], [Earth, Mars, Jupiter], [Earth, Mars, Mars, Jupiter]
|
||||
|
||||
# Now for a more complicated two-phase mission, with a bigger date range
|
||||
# This is known to have a solution though
|
||||
planets = [Earth, Venus, Mars]
|
||||
launch_window = DateTime(2021,6,1), DateTime(2022,6,1)
|
||||
latest_arrival = DateTime(2024,1,1)
|
||||
best, archive = mbh(planets, launch_window, latest_arrival, 20, 5)
|
||||
@test typeof(best) == Mission
|
||||
p = plot(best, title="MBH Test Solution")
|
||||
savefig(p,"../plots/mbh_test_2_phase.html")
|
||||
store(best, "missions/mbh_2_phase_best")
|
||||
store(archive, "missions/mbh_2_phase_archive")
|
||||
|
||||
# Now for a real stress test - the old ten-year, 5-phase Jovian mission
|
||||
# This is known to have a solution... tough to find though
|
||||
# I'll give it a tight launch window to be nice
|
||||
planets = [Earth, Venus, Earth, Mars, Earth, Jupiter]
|
||||
launch_window = DateTime(2023,4,1), DateTime(2023,7,1)
|
||||
latest_arrival = DateTime(2033,1,1)
|
||||
best, archive = mbh(planets, launch_window, latest_arrival, 200, 10)
|
||||
@test typeof(best) == Mission
|
||||
p = plot(best, title="MBH Test Solution")
|
||||
savefig(p,"../plots/mbh_test_5_phase.html")
|
||||
store(best, "missions/mbh_5_phase_best")
|
||||
store(archive, "missions/mbh_5_phase_archive")
|
||||
for planets in tests
|
||||
best, archive = mbh(planets)
|
||||
@test typeof(best) == Mission
|
||||
log(best, archive)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -46,29 +46,30 @@
|
||||
store(m, "missions/nlp_2_phase")
|
||||
|
||||
# Here is the final, most complicated, trajectory to test
|
||||
flybys = [Earth, Venus, Earth, Mars, Earth, Jupiter]
|
||||
launch_window = DateTime(2023,1,1), DateTime(2024,1,1)
|
||||
latest_arrival = DateTime(2031,1,1)
|
||||
dates = [DateTime(2023,5,23),
|
||||
DateTime(2023,10,21),
|
||||
DateTime(2024,8,24),
|
||||
DateTime(2025,2,13),
|
||||
DateTime(2026,11,22),
|
||||
DateTime(2032,1,1)]
|
||||
phases = Vector{Phase}()
|
||||
launch_v∞, _, tof1 = Thesis.lamberts(flybys[1], flybys[2], dates[1], dates[2])
|
||||
for i in 1:length(dates)-2
|
||||
v∞_out1, v∞_in1, tof1 = Thesis.lamberts(flybys[i], flybys[i+1], dates[i], dates[i+1])
|
||||
v∞_out2, v∞_in2, tof2 = Thesis.lamberts(flybys[i+1], flybys[i+2], dates[i+1], dates[i+2])
|
||||
push!(phases, Phase(flybys[i+1], 1.02v∞_in1, 0.98v∞_out2, 1.02tof1, 0.02*ones(20,3)))
|
||||
end
|
||||
v∞_out, v∞_in, tof = Thesis.lamberts(flybys[end-1], flybys[end], dates[end-1], dates[end])
|
||||
push!(phases, Phase(flybys[end], v∞_in, v∞_in, tof, 0.01*ones(20,3)))
|
||||
guess = Mission_Guess(bepi, 3_600., dates[1], launch_v∞, phases)
|
||||
m = solve_mission(guess, launch_window, latest_arrival, verbose=true)
|
||||
@test typeof(m) == Mission
|
||||
p = plot(m, title="NLP Test Solution (5 Phases)")
|
||||
savefig(p,"../plots/nlp_test_5_phase.html")
|
||||
store(m, "missions/nlp_5_phase")
|
||||
# Ignoring for now as the initial guess makes the test take too long to converge with mbh settings
|
||||
# flybys = [Earth, Venus, Earth, Mars, Earth, Jupiter]
|
||||
# launch_window = DateTime(2023,1,1), DateTime(2024,1,1)
|
||||
# latest_arrival = DateTime(2031,1,1)
|
||||
# dates = [DateTime(2023,5,23),
|
||||
# DateTime(2023,10,21),
|
||||
# DateTime(2024,8,24),
|
||||
# DateTime(2025,2,13),
|
||||
# DateTime(2026,11,22),
|
||||
# DateTime(2032,1,1)]
|
||||
# phases = Vector{Phase}()
|
||||
# launch_v∞, _, tof1 = Thesis.lamberts(flybys[1], flybys[2], dates[1], dates[2])
|
||||
# for i in 1:length(dates)-2
|
||||
# v∞_out1, v∞_in1, tof1 = Thesis.lamberts(flybys[i], flybys[i+1], dates[i], dates[i+1])
|
||||
# v∞_out2, v∞_in2, tof2 = Thesis.lamberts(flybys[i+1], flybys[i+2], dates[i+1], dates[i+2])
|
||||
# push!(phases, Phase(flybys[i+1], 1.02v∞_in1, 0.98v∞_out2, 1.02tof1, 0.02*ones(20,3)))
|
||||
# end
|
||||
# v∞_out, v∞_in, tof = Thesis.lamberts(flybys[end-1], flybys[end], dates[end-1], dates[end])
|
||||
# push!(phases, Phase(flybys[end], v∞_in, v∞_in, tof, 0.01*ones(20,3)))
|
||||
# guess = Mission_Guess(bepi, 3_600., dates[1], launch_v∞, phases)
|
||||
# m = solve_mission(guess, launch_window, latest_arrival, verbose=true)
|
||||
# @test typeof(m) == Mission
|
||||
# p = plot(m, title="NLP Test Solution (5 Phases)")
|
||||
# savefig(p,"../plots/nlp_test_5_phase.html")
|
||||
# store(m, "missions/nlp_5_phase")
|
||||
|
||||
end
|
||||
|
||||
@@ -16,6 +16,6 @@
|
||||
|
||||
# Test that mass is reduced properly
|
||||
state = prop_one([1., 0., 0.], start, bepi, stepsize)
|
||||
@test state[7] == start_mass - bepi.mass_flow_rate*stepsize
|
||||
@test state[7] == start_mass - mfr(bepi)*stepsize
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user