A lot of progress on the propagator
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
@testset "Laguerre-Conway" begin
|
||||
|
||||
# Test that the propagator produces good periodic orbits (forwards and backwards)
|
||||
for T in rand(3600*1.5:3600*4, (5))
|
||||
start = oe_to_xyz([ (μs["Earth"]*(T/(2π))^2)^(1/3), 0.1, 0.1, 0., 0., 1. ], μs["Earth"])
|
||||
start = oe_to_xyz([ (μs["Earth"]*(T/(2π))^2)^(1/3), rand(0.01:0.01:0.5), rand(0.01:0.01:0.45π), 0., 0., 1. ], μs["Earth"])
|
||||
orbit = start
|
||||
for _ in 1:5
|
||||
i = 0.
|
||||
@@ -11,5 +13,15 @@
|
||||
@test i ≈ T
|
||||
@test orbit ≈ start
|
||||
end
|
||||
for _ in 1:5
|
||||
i = 0.
|
||||
while i > -T
|
||||
orbit = laguerre_conway(orbit, μs["Earth"], -1.)
|
||||
i -= 1
|
||||
end
|
||||
@test i ≈ -T
|
||||
@test orbit ≈ start
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
33
julia/test/propagator.jl
Normal file
33
julia/test/propagator.jl
Normal file
@@ -0,0 +1,33 @@
|
||||
@testset "Propagator" begin
|
||||
|
||||
# Set up
|
||||
start = oe_to_xyz([ (μs["Earth"]*(rand(3600*1.5:0.01:3600*4)/(2π))^2)^(1/3),
|
||||
rand(0.01:0.01:0.5),
|
||||
rand(0.01:0.01:0.45π),
|
||||
0.,
|
||||
0.,
|
||||
1. ], μs["Earth"])
|
||||
stepsize = rand(100.0:0.01:500.0)
|
||||
|
||||
# Test that Laguerre-Conway is the default propagator
|
||||
propped = prop_one([0., 0., 0.], start, 0., 0, 0., 1000., 0.1, μs["Earth"], stepsize)
|
||||
@test laguerre_conway(start, μs["Earth"], stepsize) ≈ propped[1]
|
||||
|
||||
# Test that Laguerre-Conway is the default propagator for spacecrafts
|
||||
craft = sc("no_thrust")
|
||||
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 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)
|
||||
@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)
|
||||
|
||||
end
|
||||
19
julia/test/spacecraft.jl
Normal file
19
julia/test/spacecraft.jl
Normal file
@@ -0,0 +1,19 @@
|
||||
@testset "Spacecraft Construction" begin
|
||||
|
||||
# Test that the standard spacecrafts can be created
|
||||
craft = sc("test")
|
||||
@test craft.mass == 1000.
|
||||
@test craft.mass_flow_rate == 0.01
|
||||
@test craft.max_thrust == 0.1
|
||||
@test craft.num_thrusters == 2
|
||||
@test craft.duty_cycle == 1.
|
||||
|
||||
craft = sc("no_thrust")
|
||||
@test craft.mass == 1000.
|
||||
@test craft.mass_flow_rate == 0.01
|
||||
@test craft.max_thrust == 0.
|
||||
@test craft.num_thrusters == 0
|
||||
@test craft.duty_cycle == 0.
|
||||
|
||||
|
||||
end
|
||||
@@ -5,12 +5,16 @@ using LinearAlgebra
|
||||
# Includes
|
||||
include("../constants.jl")
|
||||
include("../conversions.jl")
|
||||
include("../spacecraft.jl")
|
||||
include("../sft.jl")
|
||||
include("../laguerre-conway.jl")
|
||||
include("../propagator.jl")
|
||||
|
||||
# Tests
|
||||
@testset verbose=true "All Tests" begin
|
||||
@testset "All Tests" begin
|
||||
include("spacecraft.jl")
|
||||
include("laguerre-conway.jl")
|
||||
include("propagator.jl")
|
||||
end
|
||||
|
||||
print()
|
||||
|
||||
Reference in New Issue
Block a user