diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dba8cba..e263b3e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,4 +7,5 @@ unit-test-job: - apt-get update - apt-get -y upgrade - apt-get install -y unzip + - mkdir julia/plots - julia --project=julia/Project.toml -E 'using Pkg; Pkg.test()' diff --git a/julia/src/find_closest.jl b/julia/src/find_closest.jl index 2061726..5152e01 100644 --- a/julia/src/find_closest.jl +++ b/julia/src/find_closest.jl @@ -12,8 +12,9 @@ function single_shoot(start::Vector{Float64}, t0::Float64, tf::Float64, x0::AbstractVector, - tol=1e-2) + tol=1e-8) + n::Int = length(x0)/3 function f!(F,x) F[1:6] .= prop(treat_inputs(x), start, craft, μ, tf-t0)[1][end,:] - final F[7:3n] .= 0. diff --git a/julia/test/find_closest.jl b/julia/test/find_closest.jl index 0f06bc4..79512ff 100644 --- a/julia/test/find_closest.jl +++ b/julia/test/find_closest.jl @@ -1,5 +1,8 @@ @testset "Find Closest" begin + using NLsolve + using Thesis: treat_inputs + # Initial Setup sc = Sc("test") a = rand(15000:1.:40000) @@ -20,16 +23,16 @@ result = Thesis.single_shoot(start, final, sc, μs["Earth"], 0.0, prop_time, x0) # Test and plot - @test result[3] == :XTOL_REACHED + @test converged(result) path1 = prop(zeros((100,3)), start, sc, μs["Earth"], T)[1] - path2, mass = prop(treat_inputs(result[2]), start, sc, μs["Earth"], prop_time) + path2, mass = prop(treat_inputs(result.zero), start, sc, μs["Earth"], prop_time) path3 = prop(zeros((100,3)), path2[end,:], sc, μs["Earth"], new_T)[1] path4 = prop(zeros((100,3)), final, sc, μs["Earth"], new_T)[1] savefig(plot_orbits([path1, path2, path3, path4], labels=["inital", "transit", "after transit", "final"], colors=["#FFFFFF","#FF4444","#44FF44","#4444FF"]), - "plots/find_closest_test.html") - if result[3] == :XTOL_REACHED + "../plots/find_closest_test.html") + if converged(result) @test norm(path2[end,:] - final) < 1e-6 end