temporary point on the inner loop wrapper
This commit is contained in:
@@ -4,6 +4,7 @@ authors = ["Connor Johnstone <richard.johnstone@colorado.edu>"]
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
|
||||||
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
|
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
|
||||||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
||||||
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
|
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ module Thesis
|
|||||||
include("./spacecraft.jl")
|
include("./spacecraft.jl")
|
||||||
include("./conversions.jl")
|
include("./conversions.jl")
|
||||||
include("./plotting.jl")
|
include("./plotting.jl")
|
||||||
include("./laguerre-conway.jl")
|
include("./inner_loop/laguerre-conway.jl")
|
||||||
include("./propagator.jl")
|
include("./inner_loop/propagator.jl")
|
||||||
include("./find_closest.jl")
|
include("./inner_loop/find_closest.jl")
|
||||||
include("./monotonic_basin_hopping.jl")
|
include("./inner_loop/monotonic_basin_hopping.jl")
|
||||||
|
include("./inner_loop/phase.jl")
|
||||||
|
include("./inner_loop/inner_loop.jl")
|
||||||
end
|
end
|
||||||
25
julia/src/inner_loop/inner_loop.jl
Normal file
25
julia/src/inner_loop/inner_loop.jl
Normal 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
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
export mbh
|
||||||
|
|
||||||
function pareto(α::Float64, n::Int)
|
function pareto(α::Float64, n::Int)
|
||||||
s = rand((-1,1), (n,3))
|
s = rand((-1,1), (n,3))
|
||||||
r = rand(Float64, (n,3))
|
r = rand(Float64, (n,3))
|
||||||
@@ -54,10 +56,9 @@ function mbh(start::AbstractVector,
|
|||||||
end
|
end
|
||||||
push!(archive, x_current)
|
push!(archive, x_current)
|
||||||
end
|
end
|
||||||
if i >= num_iters
|
if i >= num_iters break end
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
if verbose println() end
|
||||||
|
|
||||||
current_best_mass = 1e8
|
current_best_mass = 1e8
|
||||||
best = archive[1]
|
best = archive[1]
|
||||||
9
julia/src/inner_loop/phase.jl
Normal file
9
julia/src/inner_loop/phase.jl
Normal 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
|
||||||
@@ -18,7 +18,6 @@ end
|
|||||||
|
|
||||||
function plot_orbits(paths::Vector{Vector{Vector{Float64}}};
|
function plot_orbits(paths::Vector{Vector{Vector{Float64}}};
|
||||||
primary::String="Earth",
|
primary::String="Earth",
|
||||||
plot_theme::Symbol=:juno,
|
|
||||||
labels::Vector{String}=Vector{String}(),
|
labels::Vector{String}=Vector{String}(),
|
||||||
title::String="Spacecraft Position",
|
title::String="Spacecraft Position",
|
||||||
colors::Vector{String}=Vector{String}())
|
colors::Vector{String}=Vector{String}())
|
||||||
@@ -49,7 +48,7 @@ function plot_orbits(paths::Vector{Vector{Vector{Float64}}};
|
|||||||
showscale=false,
|
showscale=false,
|
||||||
colorscale = p_colors[primary])
|
colorscale = p_colors[primary])
|
||||||
|
|
||||||
layout = Layout(;title="Orbit Plot",
|
layout = Layout(;title=title,
|
||||||
width=1000,
|
width=1000,
|
||||||
height=600,
|
height=600,
|
||||||
paper_bgcolor="#222529",
|
paper_bgcolor="#222529",
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
export Sc
|
export Sc
|
||||||
|
|
||||||
struct Sc{T <: Real}
|
struct Sc{T <: Real}
|
||||||
mass::T
|
mass::T
|
||||||
mass_flow_rate::Float64
|
mass_flow_rate::Float64
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
@testset "Find Closest" begin
|
@testset "Find Closest" begin
|
||||||
|
|
||||||
|
println("Testing NLP solver")
|
||||||
|
|
||||||
using NLsolve, PlotlyJS
|
using NLsolve, PlotlyJS
|
||||||
|
|
||||||
# Initial Setup
|
# Initial Setup
|
||||||
sc = Sc("test")
|
sc = Sc("test")
|
||||||
a = rand(15000:1.:40000)
|
a = rand(25000:1.:40000)
|
||||||
e = rand(0.01:0.01:0.5)
|
e = rand(0.01:0.01:0.05)
|
||||||
i = rand(0.01:0.01:π/6)
|
i = rand(0.01:0.01:π/6)
|
||||||
T = 2π*√(a^3/μs["Earth"])
|
T = 2π*√(a^3/μs["Earth"])
|
||||||
prop_time = 2T
|
prop_time = T
|
||||||
n = 20
|
n = 10
|
||||||
|
|
||||||
# A simple orbit raising
|
# A simple orbit raising
|
||||||
start = oe_to_xyz([ a, e, i, 0., 0., 0. ], μs["Earth"])
|
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),
|
Tx, Ty, Tz = conv_T(repeat([0.6], n), repeat([0.], n), repeat([0.], n),
|
||||||
start,
|
start,
|
||||||
sc.mass,
|
sc.mass,
|
||||||
@@ -23,7 +24,7 @@
|
|||||||
final = prop(hcat(Tx, Ty, Tz), start, sc, μs["Earth"], prop_time)[3]
|
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"])
|
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),
|
Tx, Ty, Tz = conv_T(repeat([0.59], n), repeat([0.01], n), repeat([0.], n),
|
||||||
start,
|
start,
|
||||||
sc.mass,
|
sc.mass,
|
||||||
13
julia/test/inner_loop/inner_loop.jl
Normal file
13
julia/test/inner_loop/inner_loop.jl
Normal 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
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
@testset "Laguerre-Conway" begin
|
@testset "Laguerre-Conway" begin
|
||||||
|
|
||||||
|
println("Testing LaGuerre-Conway")
|
||||||
|
|
||||||
using Thesis: laguerre_conway
|
using Thesis: laguerre_conway
|
||||||
|
|
||||||
# Test that the propagator produces good periodic orbits (forwards and backwards)
|
# Test that the propagator produces good periodic orbits (forwards and backwards)
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
@testset "Monotonic Basin Hopping" begin
|
@testset "Monotonic Basin Hopping" begin
|
||||||
|
|
||||||
using Thesis: mbh
|
println("Testing Monotonic Basin Hopper")
|
||||||
|
|
||||||
# Initial Setup
|
# Initial Setup
|
||||||
sc = Sc("test")
|
sc = Sc("test")
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
@testset "Propagator" begin
|
@testset "Propagator" begin
|
||||||
|
|
||||||
|
println("Testing propagator")
|
||||||
|
|
||||||
using Thesis: prop_one
|
using Thesis: prop_one
|
||||||
|
|
||||||
# Set up
|
# Set up
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
@testset "Plotting" begin
|
@testset "Plotting" begin
|
||||||
|
|
||||||
|
println("Testing plotting features")
|
||||||
|
|
||||||
using PlotlyJS
|
using PlotlyJS
|
||||||
|
|
||||||
# First some setup
|
# First some setup
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ using Thesis
|
|||||||
# Tests
|
# Tests
|
||||||
@testset "All Tests" begin
|
@testset "All Tests" begin
|
||||||
include("spacecraft.jl")
|
include("spacecraft.jl")
|
||||||
include("laguerre-conway.jl")
|
|
||||||
include("propagator.jl")
|
|
||||||
include("plotting.jl")
|
include("plotting.jl")
|
||||||
include("find_closest.jl")
|
include("inner_loop/laguerre-conway.jl")
|
||||||
include("monotonic_basin_hopping.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
|
end
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
@testset "Spacecraft Construction" begin
|
@testset "Spacecraft Construction" begin
|
||||||
|
|
||||||
|
println("Testing spacecraft")
|
||||||
|
|
||||||
# Test that the standard spacecraft can be created
|
# Test that the standard spacecraft can be created
|
||||||
craft = Sc("test")
|
craft = Sc("test")
|
||||||
@test craft.mass == 10000.
|
@test craft.mass == 10000.
|
||||||
|
|||||||
17
readme.md
17
readme.md
@@ -9,18 +9,31 @@ this readme as I flush out the plan a little better and then as I begin producin
|
|||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
For now, this just generates pdf files from the markdown files that I used to take notes. If you'd
|
### Generate PDFs
|
||||||
like to do that, though, you'll need:
|
|
||||||
|
To generate the PDFs (currently just the notes, but soon to include the thesis paper) you'll need:
|
||||||
|
|
||||||
- pandoc
|
- pandoc
|
||||||
- a working LaTeX installation
|
- a working LaTeX installation
|
||||||
- Roboto font
|
- Roboto font
|
||||||
- make
|
- make
|
||||||
|
|
||||||
|
### Julia Code
|
||||||
|
|
||||||
|
In order to run the Julia code, you'll need Julia v1.6 or higher. This project is packaged as a package, so installing the dependencies (and the project itself) is simple. Just run:
|
||||||
|
|
||||||
|
```julia
|
||||||
|
Pkg.import(); Pkg.activate("julia"); Pkg.build()
|
||||||
|
```
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
### Generate PDFs
|
||||||
|
|
||||||
To produce the pdfs, simply run:
|
To produce the pdfs, simply run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
### Julia Code
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user