Currently working on refactor, much work to do

This commit is contained in:
Connor
2021-09-25 16:10:02 -06:00
parent 7d0037f38d
commit af545ba1a7
23 changed files with 286 additions and 353 deletions

View File

@@ -18,18 +18,15 @@ A convenience function for using spacecraft. Note that this function outputs a s
function prop_one(ΔV_unit::Vector{<:Real},
state::Vector{<:Real},
craft::Sc,
μ::Float64,
time::Float64)
time::Float64,
primary::Body=Sun)
for direction in ΔV_unit
if abs(direction) > 1.0
println(direction)
error("ΔV is impossibly high")
end
abs(direction) <= 1.0 || throw(PropOne_Error(ΔV_unit))
end
ΔV = max_ΔV(craft.duty_cycle, craft.num_thrusters, craft.max_thrust, time, 0., state[7]) * ΔV_unit
halfway = laguerre_conway(state, μ, time/2) + [zeros(3); ΔV]
final = laguerre_conway(halfway, μ, time/2)
halfway = laguerre_conway(state, time/2, primary) + [zeros(3); ΔV]
final = laguerre_conway(halfway, time/2, primary)
return [final; state[7] - craft.mass_flow_rate*norm(ΔV_unit)*time]
end
@@ -40,10 +37,10 @@ The propagator function
function prop(ΔVs::Matrix{T},
state::Vector{Float64},
craft::Sc,
μ::Float64,
time::Float64) where T <: Real
time::Float64,
primary::Body=Sun) where T <: Real
if size(ΔVs)[2] != 3 throw(ErrorException("ΔV input is wrong size")) end
size(ΔVs)[2] == 3 || throw(ΔVsize_Error())
n = size(ΔVs)[1]
x_states = Vector{T}()
@@ -63,7 +60,7 @@ function prop(ΔVs::Matrix{T},
push!(masses, state[7])
for i in 1:n
state = prop_one(ΔVs[i,:], state, craft, μ, time/n)
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])
@@ -71,12 +68,14 @@ function prop(ΔVs::Matrix{T},
push!(dy_states, state[5])
push!(dz_states, state[6])
push!(masses, state[7])
if state[7] < craft.dry_mass
println(state[7])
error("Mass is too low")
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
end
"""
Convenience function for propagating a state with no thrust
"""
prop(x::Vector{Float64}, t::Float64, p::Body=Sun) = prop(zeros(1000,3), x, no_thrust, t, p)[1]