Files
thesis/julia/test/propagator.jl
2021-08-25 15:33:44 -06:00

40 lines
1.3 KiB
Julia

@testset "Propagator" begin
using Thesis: prop_one
# 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")
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 == start_mass
# Test that mass is reduced properly
craft = Sc("test")
start_mass = craft.mass
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.5, 0., 0.], start, craft, μs["Earth"], stepsize)
# Test that a full propagation doesn't take too long
end