Ok, now open loop is working, sc mass changed to state, and other updates

This commit is contained in:
Connor
2021-09-21 22:14:49 -06:00
parent 982440c976
commit eaae54ac59
16 changed files with 320 additions and 373 deletions

View File

@@ -8,6 +8,7 @@ there's only the outer loop left to do. And that's pretty easy.
"""
function inner_loop(launch_date::DateTime,
craft::Sc,
start_mass::Float64,
phases::Vector{Phase};
min_flyby::Float64=1000.,
mbh_specs=nothing,
@@ -38,36 +39,32 @@ function inner_loop(launch_date::DateTime,
δ = acos((phases[i].v∞_outgoing phases[i-1].v∞_incoming)/v∞^2)
flyby = μs[phases[i].from_planet]/v∞^2 * (1/sin(δ/2) - 1)
true_min = rs[phases[i].from_planet] + min_flyby
if flyby <= true_min
error("Flyby was too low between phase $(i-1) and $(i): $(flyby) / $(true_min)")
end
flyby <= true_min || error("Flyby too low from phase $(i-1) to $(i): $(flyby) / $(true_min)")
end
end
time = utc2et(Dates.format(launch_date,"yyyy-mm-ddTHH:MM:SS"))
thrust_profiles = []
try
for phase in phases
planet1_state = spkssb(ids[phase.from_planet], time, "J2000")
time += phase.time_of_flight
planet2_state = spkssb(ids[phase.to_planet], time, "J2000")
# 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
num_iters, sil, dil = mbh_specs
best = mbh(start, final, craft, μs["Sun"], 0.0, phase.time_of_flight, 10,
verbose=verbose, num_iters=num_iters, search_patience_lim=sil,
drill_patience_lim=dil)
end
push!(thrust_profiles, best)
craft.mass = prop(tanh.(best.zero), planet1_state, sc, μs["Sun"], prop_time)[2][end]
for phase in phases
planet1_state = [spkssb(ids[phase.from_planet], time, "J2000"); 0.0]
time += phase.time_of_flight
planet2_state = [spkssb(ids[phase.to_planet], time, "J2000"); 0.0]
start = planet1_state + [0., 0., 0., phase.v∞_outgoing..., start_mass]
final = planet2_state + [0., 0., 0., phase.v∞_incoming..., start_mass]
println(start)
println(final)
# TODO: Come up with improved method of calculating "n"
if mbh_specs === nothing
best = mbh(start, final, craft, μs["Sun"], 0.0, phase.time_of_flight, 20,
verbose=verbose)[1]
else
sil, dil = mbh_specs
best = mbh(start, final, craft, μs["Sun"], 0.0, phase.time_of_flight, 20,
verbose=verbose, search_patience_lim=sil, drill_patience_lim=dil)[1]
end
return craft.mass, thrust_profiles
catch
return "One path did not converge"
push!(thrust_profiles, best.zero)
end
return thrust_profiles
end