Still a lot of changes to make
This commit is contained in:
@@ -2,8 +2,13 @@ module Thesis
|
||||
|
||||
using LinearAlgebra, ForwardDiff, PlotlyJS, SPICE
|
||||
|
||||
try
|
||||
furnsh("../../SPICE/naif0012.tls")
|
||||
furnsh("../../SPICE/de430.bsp")
|
||||
catch
|
||||
furnsh("SPICE/naif0012.tls")
|
||||
furnsh("SPICE/de430.bsp")
|
||||
end
|
||||
|
||||
include("./constants.jl")
|
||||
include("./spacecraft.jl")
|
||||
|
||||
@@ -7,8 +7,11 @@ This is it. The outer function call for the inner loop. After this is done,
|
||||
there's only the outer loop left to do. And that's pretty easy.
|
||||
"""
|
||||
function inner_loop(launch_date::DateTime,
|
||||
craft::Sc,
|
||||
phases::Vector{Phase};
|
||||
min_flyby::Float64=1000.)
|
||||
min_flyby::Float64=1000.,
|
||||
mbh_specs=nothing,
|
||||
verbose=false)
|
||||
|
||||
# First we need to do some quick checks that the mission is well formed
|
||||
for i in 1:length(phases)
|
||||
@@ -43,14 +46,24 @@ function inner_loop(launch_date::DateTime,
|
||||
end
|
||||
|
||||
time = utc2et(Dates.format(launch_date,"yyyy-mm-ddTHH:MM:SS"))
|
||||
thrust_profiles = []
|
||||
for phase in phases
|
||||
planet1_state = spkssb(ids[phase.from_planet], time, "J2000")
|
||||
println(planet1_state)
|
||||
time += phase.time_of_flight
|
||||
planet2_state = spkssb(ids[phase.to_planet], time, "J2000")
|
||||
println(planet2_state)
|
||||
# TODO: Come up with improved method of calculating "n"
|
||||
start = planet1_state + [0., 0., 0., phase.v∞_outgoing...]
|
||||
final = planet2_state + [0., 0., 0., phase.v∞_incoming...]
|
||||
if mbh_specs == nothing
|
||||
best = mbh(start, final, craft, μs["Sun"], 0.0, phase.time_of_flight, 10,
|
||||
verbose=verbose)[1]
|
||||
else
|
||||
best = mbh(start, final, craft, μs["Sun"], 0.0, phase.time_of_flight, 10,
|
||||
verbose=verbose, num_iters=mbh_specs[1], patience_level=mbh_specs[2])[1]
|
||||
end
|
||||
push!(thrust_profiles, best)
|
||||
craft.mass = prop(tanh.(best.zero), planet1_state, sc, μs["Sun"], prop_time)[2][end]
|
||||
end
|
||||
|
||||
|
||||
return phases[1].v∞_incoming[1]
|
||||
return craft.mass, thrust_profiles
|
||||
end
|
||||
@@ -26,8 +26,8 @@ function mbh(start::AbstractVector,
|
||||
t0::AbstractFloat,
|
||||
tf::AbstractFloat,
|
||||
n::Int;
|
||||
num_iters=50,
|
||||
patience_level::Int=400,
|
||||
num_iters=25,
|
||||
patience_level::Int=200,
|
||||
tol=1e-6,
|
||||
verbose=false)
|
||||
|
||||
@@ -38,11 +38,18 @@ function mbh(start::AbstractVector,
|
||||
while true
|
||||
i += 1
|
||||
if verbose print("\r",i) end
|
||||
# TODO: Should this be two separate "impatience" values?
|
||||
impatience = 0
|
||||
println("HERE")
|
||||
x_star = nlp_solve(start, final, craft, μ, t0, tf, new_x(n), tol=tol)
|
||||
while converged(x_star) == false
|
||||
println("THERE")
|
||||
while converged(x_star) == false && impatience < patience_level
|
||||
impatience += 1
|
||||
x_star = nlp_solve(start, final, craft, μ, t0, tf, new_x(n), tol=tol)
|
||||
println(impatience)
|
||||
end
|
||||
if impatience > patience_level break end
|
||||
impatience = 0
|
||||
if converged(x_star)
|
||||
x_current = x_star
|
||||
while impatience < patience_level
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
using Dates
|
||||
|
||||
sc = Sc("test")
|
||||
|
||||
phase1 = Phase("Earth",
|
||||
"Mars",
|
||||
3600*24*365*1.5,
|
||||
@@ -15,7 +17,8 @@
|
||||
3600*24*365*3.5,
|
||||
[2., 3.7416573867739413, 0.],
|
||||
[0.3, 1., 0.])
|
||||
inner_loop(DateTime(2024,3,5), [phase1, phase2])
|
||||
|
||||
inner_loop(DateTime(2024,3,5), sc, [phase1, phase2], verbose=true, mbh_specs=(5,100))
|
||||
|
||||
@test true
|
||||
|
||||
|
||||
@@ -4,8 +4,13 @@ using LinearAlgebra
|
||||
using SPICE
|
||||
using Thesis
|
||||
|
||||
try
|
||||
furnsh("../../SPICE/naif0012.tls")
|
||||
furnsh("../../SPICE/de430.bsp")
|
||||
catch
|
||||
furnsh("SPICE/naif0012.tls")
|
||||
furnsh("SPICE/de430.bsp")
|
||||
end
|
||||
|
||||
# Tests
|
||||
@testset "All Tests" begin
|
||||
|
||||
Reference in New Issue
Block a user