1
0
mirror of https://gitlab.com/lander-team/plots.git synced 2025-06-16 06:56:39 +00:00
This commit is contained in:
Anson 2021-09-26 15:40:30 -07:00
parent f755449b4a
commit 4242644cd2
2 changed files with 46 additions and 26 deletions

View File

@ -5,39 +5,59 @@ using NumericalIntegration
theme(:juno) theme(:juno)
rate = 180u"°/s" function impulse_calc(max_deflection = 15u"°")
if max_deflection == 0
max_deflection = 15u"°" return 0u"N*s"
end
servo_speed = 180u"°/s"
dt = 0.001u"s" dt = 0.001u"s"
time = 0u"s":dt:2u"s" time = 0u"s":dt:3.5u"s"
servo_rate = dt * servo_speed
angle = [(t * rate) % max_deflection for t in time] # angle = [(t * rate) % max_deflection for t in time]
angles = zeros(length(time)) .* u"°"
angle = 0u"°"
for i = 1:length(time)
if abs(angle) > max_deflection
servo_rate = servo_rate * -1
end
angle = angle + servo_rate
angles[i] = angle
end
v = angles .|> cos .|> abs
h = angles .|> sin .|> abs
v = cos.(angle) .* u"N"
h = sin.(angle) .* u"N"
horizontal_impulse = let horizontal_impulse = let
vimp = integrate(time, v) vimp = integrate(time, v)
himp = integrate(time, h) himp = integrate(time, h)
round(himp / (vimp + himp) * 100) |> Int himp / (vimp + himp) * 100
end end
return horizontal_impulse
end
deflections = (0.1:0.1:20)u"°"
impulse = impulse_calc.(deflections)
let let
plot(time, v, label = "Vertical") plot(deflections, impulse, label = "Horizontal Impulse", legend = :topleft, line = 3)
plot!(time, h, label = "Horizontal") yticks!(0:2:15, string.(0:2:15) .* "%")
yticks!(0:0.25:1, string.(0:25:100) .* "%") ylabel!("Percent of Impulse")
ylabel!("Percent of Thrust") xticks!(0:2:20, string.(0:2:20) .* "°")
xticks!(0:0.5:2, string.(0:0.5:2) .* "s") xlabel!("Maximum TVC Deflection")
xlabel!("Time") title!("Horizontal Impulse as a function \nof maximum TVC deflection")
title!( vline!([8], label = "Current Design", line = (3, :dash, :mediumpurple))
"Max Deflection: $(max_deflection)\n" *
"Vertical Impulse: $(100-horizontal_impulse)% | Horizontal Impulse: $(horizontal_impulse)%",
)
end end
savefig("ThrustDef.png") # savefig("ThrustDef.png")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 39 KiB