temporary point on the inner loop wrapper

This commit is contained in:
Connor
2021-09-02 21:40:19 -06:00
parent 4d180f577a
commit 9298a7a6f3
19 changed files with 96 additions and 23 deletions

View File

@@ -4,6 +4,7 @@ authors = ["Connor Johnstone <richard.johnstone@colorado.edu>"]
version = "0.1.0"
[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"

View File

@@ -6,8 +6,10 @@ module Thesis
include("./spacecraft.jl")
include("./conversions.jl")
include("./plotting.jl")
include("./laguerre-conway.jl")
include("./propagator.jl")
include("./find_closest.jl")
include("./monotonic_basin_hopping.jl")
include("./inner_loop/laguerre-conway.jl")
include("./inner_loop/propagator.jl")
include("./inner_loop/find_closest.jl")
include("./inner_loop/monotonic_basin_hopping.jl")
include("./inner_loop/phase.jl")
include("./inner_loop/inner_loop.jl")
end

View File

@@ -0,0 +1,25 @@
using Dates
export inner_loop
"""
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,
RLA::Float64,
DLA::Float64,
phases::Vector{Phase})
# First we need to do some quick checks that the mission is well formed
for i in 1:length(phases)
if i == 1
@assert phases[i].from_planet == "Earth"
else
@assert phases[i].from_planet == phases[i-1].to_planet
@assert phases[i].v∞_outgoing == phases[i-1].v∞_incoming
end
end
return RLA + DLA + phases[1].v∞_incoming
end

View File

@@ -1,3 +1,5 @@
export mbh
function pareto(α::Float64, n::Int)
s = rand((-1,1), (n,3))
r = rand(Float64, (n,3))
@@ -54,10 +56,9 @@ function mbh(start::AbstractVector,
end
push!(archive, x_current)
end
if i >= num_iters
break
end
if i >= num_iters break end
end
if verbose println() end
current_best_mass = 1e8
best = archive[1]

View File

@@ -0,0 +1,9 @@
export Phase
struct Phase
from_planet::String
to_planet::String
time_of_flight::Float64 # seconds
v∞_outgoing::Float64 # Km/s
v∞_incoming::Float64 # Km/s
end

View File

@@ -18,7 +18,6 @@ end
function plot_orbits(paths::Vector{Vector{Vector{Float64}}};
primary::String="Earth",
plot_theme::Symbol=:juno,
labels::Vector{String}=Vector{String}(),
title::String="Spacecraft Position",
colors::Vector{String}=Vector{String}())
@@ -49,7 +48,7 @@ function plot_orbits(paths::Vector{Vector{Vector{Float64}}};
showscale=false,
colorscale = p_colors[primary])
layout = Layout(;title="Orbit Plot",
layout = Layout(;title=title,
width=1000,
height=600,
paper_bgcolor="#222529",

View File

@@ -1,5 +1,4 @@
export Sc
struct Sc{T <: Real}
mass::T
mass_flow_rate::Float64

View File

@@ -1,19 +1,20 @@
@testset "Find Closest" begin
println("Testing NLP solver")
using NLsolve, PlotlyJS
# Initial Setup
sc = Sc("test")
a = rand(15000:1.:40000)
e = rand(0.01:0.01:0.5)
a = rand(25000:1.:40000)
e = rand(0.01:0.01:0.05)
i = rand(0.01:0.01:π/6)
T = 2π*(a^3/μs["Earth"])
prop_time = 2T
n = 20
prop_time = T
n = 10
# A simple orbit raising
start = oe_to_xyz([ a, e, i, 0., 0., 0. ], μs["Earth"])
# T_craft = hcat(repeat([0.6], n), repeat([0.], n), repeat([0.], n))
Tx, Ty, Tz = conv_T(repeat([0.6], n), repeat([0.], n), repeat([0.], n),
start,
sc.mass,
@@ -23,7 +24,7 @@
final = prop(hcat(Tx, Ty, Tz), start, sc, μs["Earth"], prop_time)[3]
new_T = 2π*(xyz_to_oe(final, μs["Earth"])[1]^3/μs["Earth"])
# This should be close enough to 0.6
# This should be close enough to 0.6 for convergence
Tx, Ty, Tz = conv_T(repeat([0.59], n), repeat([0.01], n), repeat([0.], n),
start,
sc.mass,

View File

@@ -0,0 +1,13 @@
@testset "Inner Loop" begin
println("Testing Inner Loop")
using Dates
phase1 = Phase("Earth", "Mars", 3600*24*365*1.5, 5., 2.)
phase2 = Phase("Mars", "Jupiter", 3600*24*365*3.5, 2., 0.1)
inner_loop(DateTime(2024,3,5), 0.3, 0.4, [phase1, phase2])
@test true
end

View File

@@ -1,4 +1,7 @@
@testset "Laguerre-Conway" begin
println("Testing LaGuerre-Conway")
using Thesis: laguerre_conway
# Test that the propagator produces good periodic orbits (forwards and backwards)

View File

@@ -1,6 +1,6 @@
@testset "Monotonic Basin Hopping" begin
using Thesis: mbh
println("Testing Monotonic Basin Hopper")
# Initial Setup
sc = Sc("test")

View File

@@ -1,5 +1,7 @@
@testset "Propagator" begin
println("Testing propagator")
using Thesis: prop_one
# Set up

View File

@@ -1,5 +1,7 @@
@testset "Plotting" begin
println("Testing plotting features")
using PlotlyJS
# First some setup

View File

@@ -7,11 +7,12 @@ using Thesis
# Tests
@testset "All Tests" begin
include("spacecraft.jl")
include("laguerre-conway.jl")
include("propagator.jl")
include("plotting.jl")
include("find_closest.jl")
include("monotonic_basin_hopping.jl")
include("inner_loop/laguerre-conway.jl")
include("inner_loop/propagator.jl")
include("inner_loop/find_closest.jl")
include("inner_loop/monotonic_basin_hopping.jl")
include("inner_loop/inner_loop.jl")
end
print()

View File

@@ -1,5 +1,7 @@
@testset "Spacecraft Construction" begin
println("Testing spacecraft")
# Test that the standard spacecraft can be created
craft = Sc("test")
@test craft.mass == 10000.