Update for meeting with Bosanac

This commit is contained in:
Connor
2021-10-07 15:56:11 -06:00
parent cd1806058d
commit f83d73449f
12 changed files with 2313 additions and 141 deletions

View File

@@ -0,0 +1,36 @@
@testset "Phase" begin
println("Testing NLP solver")
# We'll start by testing the mission_guess -> vector function
vec = Vector(test_mg)
@test typeof(vec) == Vector{Float64}
# Now we go in the other direction
flybys = [ p.planet for p in test_mg.phases ]
guess = Mission_Guess(vec, test_mg.sc, test_mg.start_mass, flybys)
@test typeof(guess) == Mission_Guess
@test guess.sc == test_mg.sc
@test guess.start_mass == test_mg.start_mass
@test guess.launch_date == test_mg.launch_date
@test guess.launch_v∞ == test_mg.launch_v∞
@test guess.converged == test_mg.converged
for i in 1:length(guess.phases)
@test guess.phases[i].planet == test_mg.phases[i].planet
@test guess.phases[i].v∞_in == test_mg.phases[i].v∞_in
@test guess.phases[i].v∞_out == test_mg.phases[i].v∞_out
@test guess.phases[i].tof == test_mg.phases[i].tof
@test guess.phases[i].thrust_profile == test_mg.phases[i].thrust_profile
end
# Now we test an example run of the basic "inner function"
leave, arrive = DateTime(1992,11,19), DateTime(1993,4,1)
earth_state = state(Earth, leave)
venus_state = state(Venus, arrive)
v∞_out, v∞_in, tof = Thesis.lamberts(Earth, Venus, leave, arrive)
phase = Phase(Venus, v∞_in, v∞_in, tof, zeros(20,3))
guess = Mission_Guess(bepi, 12_000., leave, v∞_out, [phase])
g = solve_mission(guess)
println(g)
end

View File

@@ -1,74 +0,0 @@
@testset "Phase" begin
println("Testing NLP solver")
using SNOW, PlotlyJS
# First we'll test an Earth case
# Initial Setup
T = rand( 8hour : second : day )
revs = 8
n = 10 * revs
start_mass = 10_000.
# A simple orbit raising
start = gen_orbit(T, start_mass, Earth)
thrust = spiral(0.9, n, start, test_sc, revs*T, Earth)
final = prop(thrust, start, test_sc, revs*T, Earth)[2]
new_T = 2π * ( xyz_to_oe(final, Earth.μ)[1]^3 / Earth.μ )
# This should be close enough to converge, but Earth orbits are picky
thrust_guess = spiral(0.89, n, start, test_sc, revs*T, Earth)
guess_final = prop(thrust_guess, start, test_sc, revs*T, Earth)[2]
result = solve_phase(start, final, test_sc, revs*T, thrust_guess, Earth, verbose=true)
calc_path, calc_final = prop(result.sol, start, test_sc, revs*T, Earth, interpolate=true)
# Test
@test norm(guess_final[1:6] - final[1:6]) > 1e-4
@test result.converged
@test norm(calc_final[1:6] - final[1:6]) < 1e-4
# Plot
paths = Pathlist()
push!(paths, prop(start, T, Earth),
calc_path,
prop(calc_final, T, Earth),
prop(final, T, Earth) )
fig = plot_orbits(paths, Earth,
labels=["init", "transit", "post-transit", "final"],
colors=["#FFF","#F44","#4F4","#44F"])
savefig(fig, "../plots/nlp_test_earth.html")
# Now the sun case
T = rand( 0.5year : hour : 1.5year )
tof = 0.7T
n = 20
start_mass = 12_000.
# A simple orbit raising again, to keep things simple
start = gen_orbit(T, start_mass)
thrust = spiral(0.6, n, start, bepi, tof)
final = prop(thrust, start, bepi, tof)[2]
new_T = 2π * ( xyz_to_oe(final, Sun.μ)[1]^3 / Sun.μ )
# This should be close enough to converge
thrust_guess = spiral(0.55, n, start, bepi, tof)
guess_final = prop(thrust_guess, start, bepi, tof)[2]
result = solve_phase(start, final, bepi, tof, thrust_guess, verbose=true)
calc_path, calc_final = prop(result.sol, start, bepi, tof, interpolate=true)
# Test
@test norm(guess_final[1:6] - final[1:6]) > 1e-4
@test result.converged
@test norm(calc_final[1:6] - final[1:6]) < 1e-4
# Plot
paths = Pathlist()
push!(paths, prop(start, T), calc_path, prop(calc_final, T), prop(final, T) )
fig = plot_orbits(paths,
labels=["init", "transit", "post-transit", "final"],
colors=["#FFF","#F44","#4F4","#44F"])
savefig(fig, "../plots/nlp_test_sun.html")
end

View File

@@ -14,9 +14,9 @@ catch
end
@testset "All Tests" begin
include("plotting.jl")
include("inner_loop/laguerre-conway.jl")
include("inner_loop/propagator.jl")
include("inner_loop/phase.jl")
include("inner_loop/monotonic_basin_hopping.jl")
# include("plotting.jl")
# include("inner_loop/laguerre-conway.jl")
# include("inner_loop/propagator.jl")
include("inner_loop/nlp_solver.jl")
# include("inner_loop/monotonic_basin_hopping.jl")
end