Update for meeting with Bosanac
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
export Phase, Mission_Guess, Mission, Bad_Mission
|
||||
export test_phase1, test_phase2
|
||||
export test_mg, test_mission
|
||||
export Vector
|
||||
|
||||
struct Phase
|
||||
planet::Body
|
||||
@@ -55,6 +56,51 @@ function Mission_Guess(sc::Sc, mass::Float64, date::DateTime, v∞::Vector{Float
|
||||
Mission_Guess(sc, mass, date, v∞, phases, false)
|
||||
end
|
||||
|
||||
"""
|
||||
This is the opposite of the function below. It takes a vector and any other necessary information and outputs a mission guess
|
||||
"""
|
||||
function Mission_Guess(x::Vector{Float64}, sc::Sc, mass::Float64, flybys::Vector{Body})
|
||||
# Variable mission params
|
||||
launch_date = Dates.unix2datetime(x[1])
|
||||
launch_v∞ = x[2:4]
|
||||
|
||||
# Try to intelligently determine n
|
||||
three_n = ((length(x)-4)/length(flybys)) - 7
|
||||
three_n % 3 == 0 || throw(Mission_Creation_Error(three_n))
|
||||
n::Int = three_n/3
|
||||
|
||||
# Build the phases
|
||||
i = 0
|
||||
phases = Vector{Phase}()
|
||||
for flyby in flybys
|
||||
phase_params = x[ 5 + (3n+7) * i : 5 + (3n+7) * (i+1) - 1 ]
|
||||
v∞_in = phase_params[1:3]
|
||||
v∞_out = phase_params[4:6]
|
||||
tof = phase_params[7]
|
||||
thrusts = reshape(phase_params[8:end], (n,3))
|
||||
push!(phases, Phase(flyby, v∞_in, v∞_out, tof, thrusts))
|
||||
i += 1
|
||||
end
|
||||
return Mission_Guess(sc, mass, launch_date, launch_v∞, phases, false)
|
||||
end
|
||||
|
||||
"""
|
||||
This is a function to convert a mission guess into an nlp-ready vector. It doesn't contain all
|
||||
information from the guess though.
|
||||
"""
|
||||
function Base.Vector(g::Mission_Guess)
|
||||
result = Vector{Float64}()
|
||||
push!(result, Dates.datetime2unix(g.launch_date))
|
||||
push!(result, g.launch_v∞...)
|
||||
for phase in g.phases
|
||||
push!(result,phase.v∞_in...)
|
||||
push!(result,phase.v∞_out...)
|
||||
push!(result,phase.tof)
|
||||
push!(result,phase.thrust_profile...)
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
const test_mg = Mission_Guess(bepi, 12_000., DateTime(1992,11,19), [-3.4,1.2,0.1], test_phases)
|
||||
|
||||
struct Mission
|
||||
|
||||
Reference in New Issue
Block a user