Added a sun test case and interpolation
This commit is contained in:
@@ -22,7 +22,7 @@ function solve_phase( start::Vector{Float64},
|
||||
F[1:6, 1] .= prop(tanh.(x), start, craft, tof, primary)[2][1:6] .- final[1:6]
|
||||
catch e
|
||||
# If the error is due to something natural, just imply a penalty
|
||||
if isa(Mass_Error, e) || isa(PropOne_Error, e)
|
||||
if isa(e, Mass_Error) || isa(e, PropOne_Error)
|
||||
F .= 10000000.0
|
||||
else
|
||||
rethrow()
|
||||
@@ -31,6 +31,7 @@ function solve_phase( start::Vector{Float64},
|
||||
end
|
||||
|
||||
result = nlsolve(f!, atanh.(x0), ftol=tol, autodiff=:forward, iterations=num_iters)
|
||||
converged(result) || throw(Convergence_Error())
|
||||
result.zero = tanh.(result.zero)
|
||||
|
||||
return result
|
||||
|
||||
@@ -38,40 +38,30 @@ function prop(ΔVs::Matrix{T},
|
||||
state::Vector{Float64},
|
||||
craft::Sc,
|
||||
time::Float64,
|
||||
primary::Body=Sun) where T <: Real
|
||||
primary::Body=Sun;
|
||||
interpolate::Bool=false) where T <: Real
|
||||
|
||||
size(ΔVs)[2] == 3 || throw(ΔVsize_Error())
|
||||
n = size(ΔVs)[1]
|
||||
|
||||
x_states = Vector{T}()
|
||||
y_states = Vector{T}()
|
||||
z_states = Vector{T}()
|
||||
dx_states = Vector{T}()
|
||||
dy_states = Vector{T}()
|
||||
dz_states = Vector{T}()
|
||||
masses = Vector{T}()
|
||||
states = [ Vector{T}(),Vector{T}(),Vector{T}(),Vector{T}(),Vector{T}(),Vector{T}(),Vector{T}() ]
|
||||
|
||||
push!(x_states, state[1])
|
||||
push!(y_states, state[2])
|
||||
push!(z_states, state[3])
|
||||
push!(dx_states, state[4])
|
||||
push!(dy_states, state[5])
|
||||
push!(dz_states, state[6])
|
||||
push!(masses, state[7])
|
||||
for i in 1:7 push!(states[i], state[i]) end
|
||||
|
||||
for i in 1:n
|
||||
if interpolate
|
||||
interpolated_state = copy(state)
|
||||
for j in 1:49
|
||||
interpolated_state = [laguerre_conway(interpolated_state, time/50n, primary); 0.0]
|
||||
for k in 1:7 push!(states[k], interpolated_state[k]) end
|
||||
end
|
||||
end
|
||||
state = prop_one(ΔVs[i,:], state, craft, time/n, primary)
|
||||
push!(x_states, state[1])
|
||||
push!(y_states, state[2])
|
||||
push!(z_states, state[3])
|
||||
push!(dx_states, state[4])
|
||||
push!(dy_states, state[5])
|
||||
push!(dz_states, state[6])
|
||||
push!(masses, state[7])
|
||||
for j in 1:7 push!(states[j], state[j]) end
|
||||
state[7] >= craft.dry_mass || throw(Mass_Error(state[7]))
|
||||
end
|
||||
|
||||
return [x_states, y_states, z_states, dx_states, dy_states, dz_states, masses], state
|
||||
return states, state
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user