Got plotting working

This commit is contained in:
rconnorjohnstone
2021-05-19 22:23:54 -06:00
parent 376f18556c
commit 2c39c34f01
11 changed files with 162 additions and 35 deletions

View File

@@ -11,7 +11,7 @@
i += 1
end
@test i T
@test orbit start
@test norm(orbit - start) < 1e-2
end
for _ in 1:5
i = 0.
@@ -20,7 +20,7 @@
i -= 1
end
@test i -T
@test orbit start
@test norm(orbit - start) < 1e-2
end
end

18
julia/test/plotting.jl Normal file
View File

@@ -0,0 +1,18 @@
@testset "Plotting" begin
# First some setup
sc = Sc("test")
T = rand(3600*1.5:0.01:3600*4)
start = oe_to_xyz([ (μs["Earth"]*(T/(2π))^2)^(1/3),
0.3,
π/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]
p = plot_orbits([path])
savefig(p,"plot_test.html")
@test typeof(p) == PlotlyJS.SyncPlot
end

View File

@@ -14,19 +14,19 @@
@test laguerre_conway(start, μs["Earth"], stepsize) propped[1]
# Test that Laguerre-Conway is the default propagator for spacecrafts
craft = sc("no_thrust")
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")
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")
craft = Sc("test")
start_mass = craft.mass
@test_throws ErrorException prop_one([1., 1., -1.], start, craft, μs["Earth"], stepsize)

View File

@@ -1,19 +1,18 @@
@testset "Spacecraft Construction" begin
# Test that the standard spacecrafts can be created
craft = sc("test")
# Test that the standard spacecraft 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")
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

View File

@@ -2,19 +2,14 @@ using Test
using Random
using LinearAlgebra
# Includes
include("../constants.jl")
include("../conversions.jl")
include("../spacecraft.jl")
include("../sft.jl")
include("../laguerre-conway.jl")
include("../propagator.jl")
include("../main.jl")
# Tests
@testset "All Tests" begin
include("spacecraft.jl")
include("laguerre-conway.jl")
include("propagator.jl")
include("plotting.jl")
end
print()