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

@@ -1,3 +1,15 @@
"""
Maximum ΔV that a spacecraft can impulse for a given single time step
"""
function max_ΔV(duty_cycle::Float64,
num_thrusters::Int,
max_thrust::Float64,
tf::Float64,
t0::Float64,
mass::Float64)
return duty_cycle*num_thrusters*max_thrust*(tf-t0)/mass
end
"""
This function propagates the spacecraft forward in time 1 Sim-Flanagan step (of variable length of time),
applying a thrust in the center.
@@ -26,11 +38,64 @@ A convenience function for using spacecraft. Note that this function outputs a s
"""
function prop_one(ΔV_unit::Vector{Float64},
state::Vector{Float64},
craft::sc,
craft::Sc,
μ::Float64,
time::Float64)
state, mass = prop_one(ΔV_unit, state, craft.duty_cycle, craft.num_thrusters, craft.max_thrust,
craft.mass, craft.mass_flow_rate, μ, time)
return state, sc(mass, craft.mass_flow_rate, craft.max_thrust, craft.num_thrusters, craft.duty_cycle)
return state, Sc(mass, craft.mass_flow_rate, craft.max_thrust, craft.num_thrusters, craft.duty_cycle)
end
"""
This propagates over a given time period, with a certain number of intermediate steps
"""
function prop(ΔV_units::Vector{Vector{Float64}},
state::Vector{Float64},
duty_cycle::Float64,
num_thrusters::Int,
max_thrust::Float64,
mass::Float64,
mass_flow_rate::Float64,
μ::Float64,
time::Float64,
n::Int)
if length(ΔV_units) != n
throw(ExceptionError("Bad number of ΔV vectors"))
end
for i in 1:n
state, mass = prop_one(ΔV_units[i], state, duty_cycle, num_thrusters, max_thrust, mass,
mass_flow_rate, μ, time/n)
end
return state, mass
end
"""
The same function, using Scs
"""
function prop(ΔV_units::Vector{Vector{Float64}},
state::Vector{Float64},
craft::Sc,
μ::Float64,
time::Float64,
n::Int)
if length(ΔV_units) != n
throw(ExceptionError("Bad number of ΔV vectors"))
end
states = state'
masses = craft.mass
for i in 1:n
state, craft = prop_one(ΔV_units[i], state, craft, μ, time/n)
states = [states; state']
masses = [masses, craft.mass]
end
return states, masses
end