I THINK that the single shooter is ok. I can always improve it later
This commit is contained in:
@@ -2,15 +2,16 @@
|
||||
|
||||
# First some setup
|
||||
sc = Sc("test")
|
||||
T = rand(3600*1.5:0.01:3600*4)
|
||||
T = rand(3600*2:0.01:3600*4)
|
||||
start = oe_to_xyz([ (μs["Earth"]*(T/(2π))^2)^(1/3),
|
||||
0.3,
|
||||
0.1,
|
||||
π/4,
|
||||
0.,
|
||||
0.,
|
||||
1. ], μs["Earth"])
|
||||
ΔVs = [ [1., 1., 1.]/20 for _ in 1:40 ]
|
||||
path = prop(ΔVs, start, sc, μs["Earth"], 0.9T, 40)[1]
|
||||
n = 100
|
||||
ΔVs = repeat([0.5, 0., 0.]', outer=(n,1))
|
||||
path = prop(ΔVs, start, sc, μs["Earth"], 3T)[1]
|
||||
p = plot_orbits([path])
|
||||
savefig(p,"plot_test.html")
|
||||
@test typeof(p) == PlotlyJS.SyncPlot
|
||||
|
||||
@@ -15,19 +15,23 @@
|
||||
|
||||
# Test that Laguerre-Conway is the default propagator for spacecrafts
|
||||
craft = Sc("no_thrust")
|
||||
start_mass = craft.mass
|
||||
state, craft = prop_one([0., 0., 0.], start, craft, μs["Earth"], stepsize)
|
||||
@test laguerre_conway(start, μs["Earth"], stepsize) ≈ state
|
||||
@test craft.mass == 1000.
|
||||
@test craft.mass == start_mass
|
||||
|
||||
# Test that mass is reduced properly
|
||||
craft = Sc("test")
|
||||
start_mass = craft.mass
|
||||
state, craft = prop_one([1., 1., 1.]/√(3), start, craft, μs["Earth"], stepsize)
|
||||
state, craft = prop_one([1., 0., 0.], start, craft, μs["Earth"], stepsize)
|
||||
@test craft.mass == start_mass - craft.mass_flow_rate*stepsize
|
||||
|
||||
# Test that a bad ΔV throws an error
|
||||
craft = Sc("test")
|
||||
start_mass = craft.mass
|
||||
@test_throws ErrorException prop_one([1., 1., -1.], start, craft, μs["Earth"], stepsize)
|
||||
@test_throws ErrorException prop_one([1.5, 0., 0.], start, craft, μs["Earth"], stepsize)
|
||||
|
||||
# Test that a full propagation doesn't take too long
|
||||
|
||||
|
||||
end
|
||||
|
||||
16
julia/test/result.jl
Normal file
16
julia/test/result.jl
Normal file
@@ -0,0 +1,16 @@
|
||||
@testset "Result Construction" begin
|
||||
|
||||
# Test that the standard results can be created
|
||||
result = Result("test_converged")
|
||||
@test result.converged == true
|
||||
@test length(result.ΔVs) == 0
|
||||
@test length(result.start) == 0
|
||||
@test length(result.final) == 0
|
||||
|
||||
result = Result("test_unconverged")
|
||||
@test result.converged == false
|
||||
@test length(result.ΔVs) == 0
|
||||
@test length(result.start) == 0
|
||||
@test length(result.final) == 0
|
||||
|
||||
end
|
||||
31
julia/test/single_shoot.jl
Normal file
31
julia/test/single_shoot.jl
Normal file
@@ -0,0 +1,31 @@
|
||||
@testset "Single Shooting" begin
|
||||
|
||||
# Initial Setup
|
||||
sc = Sc("test")
|
||||
a = rand(15000:1.:40000)
|
||||
e = rand(0.01:0.01:0.5)
|
||||
i = rand(0.01:0.01:π/6)
|
||||
T = 2π*√(a^3/μs["Earth"])
|
||||
n = 50
|
||||
|
||||
# A simple orbit raising
|
||||
start = oe_to_xyz([ a, e, i, 0., 0., 0. ], μs["Earth"])
|
||||
ΔVs = repeat([0.6, 0., 0.]', outer=(n,1))
|
||||
final = prop(ΔVs, start, sc, μs["Earth"], T)[1][end,:]
|
||||
|
||||
# This should be close enough to 0.6
|
||||
x0 = repeat([atanh((0.4-0.5)/0.5), 0., 0.], n)
|
||||
result = single_shoot(start, final, sc, μs["Earth"], 0.0, T, n, x0)
|
||||
|
||||
# Test and plot
|
||||
@test converged(result)
|
||||
path1 = prop(zeros((100,3)), start, sc, μs["Earth"], T)[1]
|
||||
path2, mass = prop(treat_inputs(result.zero, n), start, sc, μs["Earth"], T)
|
||||
path3 = prop(zeros((100,3)), path2[end,:], sc, μs["Earth"], T)[1]
|
||||
savefig(plot_orbits([path1, path2, path3]), "single_shoot_test.html")
|
||||
if converged(result)
|
||||
@test norm(path2[end,:] - final) < 2e-2
|
||||
sc = Sc("test")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
# Test that the standard spacecraft can be created
|
||||
craft = Sc("test")
|
||||
@test craft.mass == 1000.
|
||||
@test craft.mass == 10000.
|
||||
@test craft.mass_flow_rate == 0.01
|
||||
@test craft.max_thrust == 0.1
|
||||
@test craft.max_thrust == 0.05
|
||||
@test craft.num_thrusters == 2
|
||||
@test craft.duty_cycle == 1.
|
||||
|
||||
craft = Sc("no_thrust")
|
||||
@test craft.mass == 1000.
|
||||
@test craft.mass == 10000.
|
||||
@test craft.mass_flow_rate == 0.01
|
||||
@test craft.max_thrust == 0.
|
||||
@test craft.num_thrusters == 0
|
||||
|
||||
@@ -10,6 +10,8 @@ include("../main.jl")
|
||||
include("laguerre-conway.jl")
|
||||
include("propagator.jl")
|
||||
include("plotting.jl")
|
||||
include("result.jl")
|
||||
include("single_shoot.jl")
|
||||
end
|
||||
|
||||
print()
|
||||
|
||||
Reference in New Issue
Block a user