1
0
mirror of https://gitlab.com/lander-team/air-prop-simulation.git synced 2025-07-23 14:41:38 +00:00

switched to measurements.jl

This commit is contained in:
2021-03-22 06:06:00 -07:00
parent 6c5f6b8459
commit b9237f9a43
2 changed files with 18 additions and 147 deletions

124
calcs.jl
View File

@@ -1,124 +0,0 @@
### A Pluto.jl notebook ###
# v0.12.20
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local el = $(esc(element))
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : missing
el
end
end
# ╔═╡ 7d1e8730-81f7-11eb-0b4d-d7c878032280
begin
using Unitful
using Roots
using PlutoUI
end
# ╔═╡ d8461f50-833d-11eb-04f2-f9e262a97ba5
md"## Air Compressor Thrust Calcs"
# ╔═╡ 2a976cf0-833e-11eb-3892-03869a9b0acc
html"<button onclick='present()'>present</button>"
# ╔═╡ b0efd6c2-81f9-11eb-2aad-efc9bdd8c220
@bind diam Slider(0.1:.1:6.5, default=.5)
# ╔═╡ bc06c722-81fa-11eb-05ac-e38ac21ce27e
@bind p Slider(15:6000, default=126)
# ╔═╡ 99835750-81fe-11eb-3a7e-1132eb3cdd90
@bind w Slider(.5:.25:20, default=5)
# ╔═╡ a9f59000-81f7-11eb-15c0-4520acb6543f
begin
M = w*u"kg"
P_amb = 1u"atm"
P_c = p*u"psi"
d_nozzle = diam*u"mm"
a_nozzle = (pi/4)*d_nozzle^2
γ = 1.4
R = 287.05u"J/(kg * K)"
T = 300u"K"
burn_time = 5u"s"
V = 68u"inch^3"
end;
# ╔═╡ 764dcf30-81fa-11eb-3155-559823202b8f
md"Area of Nozzle: $(a_nozzle) | $(round(u\"inch^2\",a_nozzle, digits = 4))"
# ╔═╡ b4a957a0-833e-11eb-1ca9-0d87d162790f
md"Diameter of Nozzle: $(d_nozzle) | $(round(u\"inch\",d_nozzle, digits = 4))"
# ╔═╡ a7bef990-81fa-11eb-3976-817c3e383e64
md"Pressure of system: $(P_c)"
# ╔═╡ b113c030-81fe-11eb-2042-776472e720ac
md"Mass of Lander: $(M) | $(round(u\"lb\",M, digits = 2))"
# ╔═╡ a9317cb0-81f7-11eb-26e5-95719252409b
begin
ve = sqrt((2 * γ / (γ - 1)) * R * T * (1 - P_amb / P_c)^((γ - 1) / γ)) |> u"m/s"
ρ = P_c / (R * T) |> u"kg/m^3"
= ρ * a_nozzle * ve |> u"kg/s"
end;
# ╔═╡ cf5b7030-846d-11eb-2f23-290624c7d684
M_air = ρ*V |> u"kg"
# ╔═╡ 2149b640-846e-11eb-262b-299ded0c61c5
M_air /
# ╔═╡ c57fe2d0-81f7-11eb-27d7-4b5c0520998d
Thrust = * ve + a_nozzle * (P_c - P_amb) |> u"N"
# ╔═╡ 213ef2c0-81fb-11eb-1425-15bfcf1dc14c
volume_air = * burn_time / ρ |> u"inch^3";
# ╔═╡ 9388c570-833d-11eb-3baa-758b5cb19065
md"Air Needed: $(round(ustrip(volume_air/burn_time)*.004329,digits=3)) Gallon/s"
# ╔═╡ e85b0e90-81fe-11eb-0dd5-0b3df376a4f7
begin
W_earth = 9.81u"m/s^2" * M |> u"N"
W_moon = 1.623u"m/s^2" * M |> u"N"
end;
# ╔═╡ 57844480-833a-11eb-3a57-bf00cecde849
md"Thrust to Weight Ratio Earth: $(Thrust/W_earth)"
# ╔═╡ a5c735d0-833a-11eb-2bae-71ba4af6b3a1
md"Thrust to Weight Ratio Moon: $(Thrust/W_moon)"
# ╔═╡ Cell order:
# ╟─d8461f50-833d-11eb-04f2-f9e262a97ba5
# ╟─2a976cf0-833e-11eb-3892-03869a9b0acc
# ╟─7d1e8730-81f7-11eb-0b4d-d7c878032280
# ╟─764dcf30-81fa-11eb-3155-559823202b8f
# ╟─b4a957a0-833e-11eb-1ca9-0d87d162790f
# ╟─b0efd6c2-81f9-11eb-2aad-efc9bdd8c220
# ╟─a7bef990-81fa-11eb-3976-817c3e383e64
# ╠═bc06c722-81fa-11eb-05ac-e38ac21ce27e
# ╟─b113c030-81fe-11eb-2042-776472e720ac
# ╠═99835750-81fe-11eb-3a7e-1132eb3cdd90
# ╠═a9f59000-81f7-11eb-15c0-4520acb6543f
# ╠═a9317cb0-81f7-11eb-26e5-95719252409b
# ╠═2149b640-846e-11eb-262b-299ded0c61c5
# ╠═cf5b7030-846d-11eb-2f23-290624c7d684
# ╠═c57fe2d0-81f7-11eb-27d7-4b5c0520998d
# ╟─213ef2c0-81fb-11eb-1425-15bfcf1dc14c
# ╠═9388c570-833d-11eb-3baa-758b5cb19065
# ╟─e85b0e90-81fe-11eb-0dd5-0b3df376a4f7
# ╟─57844480-833a-11eb-3a57-bf00cecde849
# ╟─a5c735d0-833a-11eb-2bae-71ba4af6b3a1

View File

@@ -1,20 +1,17 @@
using Unitful
using DataFrames
using Plots
# using Gadfly
using UnitfulRecipes
using Roots
using CSV
using MonteCarloMeasurements
using Measurements
unsafe_comparisons(true)
# Tank https://www.amazon.com/Empire-Paintball-BASICS-Pressure-Compressed/dp/B07B6M48SR/
V = (85 ± 5)u"inch^3"
P0 = (4200.0 ± 300)u"psi"
Wtank = (2.3 ± 0.2)u"lb"
Pmax = (100 ± 5)u"psi"
Pmax = (800 ± 50)u"psi"
Wsolenoid = 1.5u"kg"
@@ -33,10 +30,10 @@ T = (300 ± 20)u"K"
t = 0.0u"s"
P = P0 |> u"Pa"
M = V * (P / (R * T)) |> u"kg"
# df = DataFrame(Thrust = (0 ± 0)u"N", Pressure = P, Time = t, Mass = M)
df = DataFrame()
ts = 10u"ms"
while M > 0.1u"kg"
ts = 1u"ms"
df = DataFrame(Thrust = (0 ± 0)u"N", Pressure = P, Time = t, Mass = M)
while M > 0.01u"kg"
# while t < 30u"s"
# Calculate what is leaving tank
P = minimum([P, Pmax])
@@ -49,25 +46,23 @@ while M > 0.1u"kg"
# Calculate what is still in the tank
M = M - * ts |> u"kg"
P = (M * R * T) / V |> u"Pa"
# df_step = DataFrame(Thrust = Thrust, Pressure = P, Time = t, Mass = M)
if df == DataFrame()
df = DataFrame(Thrust = Thrust, Pressure = P, Time = t, Mass = M)
else
append!(df, DataFrame(Thrust = Thrust, Pressure = P, Time = t, Mass = M))
end
t = t + ts
df_step = DataFrame(Thrust = Thrust, Pressure = P, Time = t, Mass = M)
append!(df, df_step)
end
impulse = sum(df.Thrust) * ts |> u"N*s"
println("---------------------------\n\n\n\n")
println("Total Impulse: ", impulse)
println("Burn Time: ", t)
plot(impulse)
println("Mass Total: ", Wtank + Wsolenoid + maximum(df.Mass))
# plot(sum(df.Thrust) * ts |> u"N*s")
# print(describe(df))
# df.Time = round(u"s", df.Time)
# plot(df.Time, df.Thrust, title = "Thrust Over Time")
# CSV.write("thrustdata.csv", df .|> ustrip)
# plot(df.Time .|> u"s" .|> ustrip, df.Thrust .|> u"N" .|> ustrip)> ustrip, df.Thrust .|> u"N" .|> ustrip)
print(describe(df))
plot(df.Time[1:150:end], df.Thrust[1:150:end], title = "Thrust Over Time")
savefig("ThrustCurve.png")