mirror of
https://gitlab.com/lander-team/air-prop-simulation.git
synced 2025-07-22 22:21:36 +00:00
code cleanup
This commit is contained in:
BIN
Presentation.png
BIN
Presentation.png
Binary file not shown.
Before Width: | Height: | Size: 26 KiB |
6
Project.toml
Normal file
6
Project.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
[deps]
|
||||
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
|
||||
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
|
||||
Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
|
||||
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
||||
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
|
BIN
ThrustCurve.png
BIN
ThrustCurve.png
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@@ -1,14 +1,12 @@
|
||||
using Unitful
|
||||
using DataFrames
|
||||
using Plots
|
||||
theme(:ggplot2);
|
||||
using UnitfulRecipes
|
||||
theme(:ggplot2);
|
||||
using CSV
|
||||
using Measurements
|
||||
using Measurements: value, uncertainty
|
||||
using Printf
|
||||
|
||||
|
||||
# Tank https://www.amazon.com/Empire-Paintball-BASICS-Pressure-Compressed/dp/B07B6M48SR/
|
||||
V = (85 ± 5)u"inch^3"
|
||||
P0 = (4200.0 ± 300)u"psi"
|
||||
@@ -27,15 +25,13 @@ P_amb = (1 ± 0.2)u"atm"
|
||||
R = 287.05u"J/(kg * K)"
|
||||
T = (300 ± 20)u"K"
|
||||
|
||||
# Setting up while loop
|
||||
t = 0.0u"s"
|
||||
P = P0 |> u"Pa"
|
||||
M = V * (P / (R * T)) |> u"kg"
|
||||
ts = 1u"ms"
|
||||
df = DataFrame(Thrust=(0 ± 0)u"N", Pressure=P, Time=t, Mass=M)
|
||||
df = DataFrame(Thrust = (0 ± 0)u"N", Pressure = P, Time = t, Mass = M)
|
||||
|
||||
while M > 0.005u"kg"
|
||||
# while t < 30u"s"
|
||||
# Calculate what is leaving tank
|
||||
P = minimum([P, Pmax])
|
||||
ve = sqrt((2 * γ / (γ - 1)) * R * T * (1 - P_amb / P)^((γ - 1) / γ)) |> u"m/s"
|
||||
@@ -44,65 +40,80 @@ while M > 0.005u"kg"
|
||||
|
||||
Thrust = ṁ * ve + a_nozzle * (P - P_amb) |> u"N"
|
||||
|
||||
# Calculate what is still in the tank
|
||||
M = M - ṁ * ts |> u"kg"
|
||||
P = (M * R * T) / V |> u"Pa"
|
||||
t = t + ts
|
||||
|
||||
df_step = DataFrame(Thrust=Thrust, Pressure=P, Time=t, Mass=M)
|
||||
df_step = DataFrame(Thrust = Thrust, Pressure = P, Time = t, Mass = M)
|
||||
append!(df, df_step)
|
||||
end
|
||||
final_time = t |> u"s"
|
||||
impulse = sum(df.Thrust) * ts |> u"N*s"
|
||||
println("---------------------------\n\n\n\n")
|
||||
println("Total Impulse: ", impulse)
|
||||
println("Burn Time: ", t)
|
||||
|
||||
println("Mass Total: ", Wtank + Wsolenoid + maximum(df.Mass))
|
||||
|
||||
|
||||
print(describe(df))
|
||||
|
||||
thrust_values = df.Thrust .|> ustrip .|> value
|
||||
thrust_uncertainties = df.Thrust .|> ustrip .|> uncertainty
|
||||
thrust_uncertainties = df.Thrust .|> ustrip .|> uncertainty
|
||||
|
||||
plot(df.Time .|> ustrip, thrust_values,
|
||||
title="Thrust Over Time",
|
||||
ribbon=(thrust_uncertainties, thrust_uncertainties),
|
||||
fillalpha=.2,label="Thrust",
|
||||
xlabel="Time (s)",
|
||||
ylabel="Thrust (N)",
|
||||
palette=:leonardo,
|
||||
)
|
||||
plot(
|
||||
df.Time .|> ustrip,
|
||||
thrust_values,
|
||||
title = "Thrust Over Time",
|
||||
ribbon = (thrust_uncertainties, thrust_uncertainties),
|
||||
fillalpha = 0.2,
|
||||
label = "Thrust",
|
||||
xlabel = "Time (s)",
|
||||
ylabel = "Thrust (N)",
|
||||
palette = :leonardo,
|
||||
)
|
||||
|
||||
out = DataFrame(Thrust=thrust_values, Uncertainty=thrust_uncertainties, Time=df.Time .|> u"s" .|> ustrip)
|
||||
CSV.write("AirProp.csv",out)
|
||||
out = DataFrame(
|
||||
Thrust = thrust_values,
|
||||
Uncertainty = thrust_uncertainties,
|
||||
Time = df.Time .|> u"s" .|> ustrip,
|
||||
)
|
||||
CSV.write("AirProp.csv", out)
|
||||
|
||||
### Save data to readme.md
|
||||
|
||||
savefig("ThrustCurve.png")
|
||||
|
||||
include("prop_compare.jl")
|
||||
|
||||
b = IOBuffer();
|
||||
t = TextDisplay(b);
|
||||
display(t, "text/html", describe(df));
|
||||
table = String(take!(b)); # https://stackoverflow.com/a/60443621/8774114
|
||||
|
||||
t = TextDisplay(b);
|
||||
display(t, "text/html", describe(df));
|
||||
table = String(take!(b)); # https://stackoverflow.com/a/60443621/8774114
|
||||
|
||||
readme = Printf.@sprintf """
|
||||
# Air Prop Thrust
|
||||
|
||||
`readme auto generated, run air_prop_sim.jl to recreate.`
|
||||
|
||||

|
||||
|
||||
Total Impulse: %s
|
||||
|
||||
Burn TIme: %s
|
||||
|
||||

|
||||
|
||||
More Data:
|
||||
|
||||
%s
|
||||
|
||||
`readme auto generated`
|
||||
## Comparison to Rocket Motors
|
||||
|
||||

|
||||
|
||||
https://www.thrustcurve.org/
|
||||
|
||||
""" impulse final_time table
|
||||
|
||||
|
||||
write("readme.md", readme);
|
||||
write("readme.md", readme);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using CSV
|
||||
using DataFrames
|
||||
using Plots
|
||||
theme(:juno)
|
||||
theme(:ggplot2)
|
||||
|
||||
air = CSV.read("AirProp.csv", DataFrame)
|
||||
|
||||
@@ -9,15 +9,21 @@ f10 = CSV.read("AeroTech_F10.csv", DataFrame)
|
||||
f15 = CSV.read("Estes_F15.csv", DataFrame)
|
||||
g8 = CSV.read("AeroTech_G8ST.csv", DataFrame)
|
||||
|
||||
|
||||
plot(air.Time, air.Thrust, label="Air Propulsion", ribbon=(zeros(length(df.Time)), min.(15, air.Uncertainty)), fillalpha=.1, legend=:topleft)
|
||||
plot(
|
||||
air.Time,
|
||||
air.Thrust,
|
||||
label = "Air Propulsion",
|
||||
ribbon = (zeros(length(df.Time)), min.(15, air.Uncertainty)),
|
||||
fillalpha = 0.1,
|
||||
legend = :topleft,
|
||||
)
|
||||
|
||||
for (d, l) in [(f10, "F10"), (f15, "F15"), (g8, "G8ST")]
|
||||
plot!(d[!,"Time (s)"], d[!, "Thrust (N)"], label=l)
|
||||
plot!(d[!, "Time (s)"], d[!, "Thrust (N)"], label = l)
|
||||
end
|
||||
|
||||
title!("Propulsion Comparison")
|
||||
xlabel!("Time (s)")
|
||||
ylabel!("Thrust (N)")
|
||||
|
||||
savefig("Presentation.png")
|
||||
savefig("prop_compare.png")
|
BIN
prop_compare.png
Normal file
BIN
prop_compare.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
15
readme.md
15
readme.md
@@ -1,13 +1,20 @@
|
||||
# Air Prop Thrust
|
||||
|
||||
`readme auto generated`
|
||||
|
||||

|
||||
|
||||
Total Impulse: 405.0 ± 40.0 N s
|
||||
|
||||
Burn TIme: 20.30300000000183 s
|
||||
|
||||

|
||||
|
||||
More Data:
|
||||
|
||||
<table class="data-frame"><thead><tr><th></th><th>variable</th><th>mean</th><th>min</th><th>median</th><th>max</th><th>nmissing</th><th>eltype</th></tr><tr><th></th><th>Symbol</th><th>Quantity</th><th>Quantity</th><th>Quantity</th><th>Quantity</th><th>Int64</th><th>DataType</th></tr></thead><tbody><p>4 rows × 7 columns</p><tr><th>1</th><td>Thrust</td><td>20.0±2.0 N</td><td>0.0±0.0 N</td><td>21.1±4.7 N</td><td>21.1±4.7 N</td><td>0</td><td>Quantity{Measurement{Float64}, 𝐋 𝐌 𝐓^-2, FreeUnits{(N,), 𝐋 𝐌 𝐓^-2, nothing}}</td></tr><tr><th>2</th><td>Pressure</td><td>1.39e7±3.6e6 Pa</td><td>300000.0±1.1e6 Pa</td><td>1.38e7±3.9e6 Pa</td><td>2.9e7±2.1e6 Pa</td><td>0</td><td>Quantity{Measurement{Float64}, 𝐌 𝐋^-1 𝐓^-2, FreeUnits{(Pa,), 𝐌 𝐋^-1 𝐓^-2, nothing}}</td></tr><tr><th>3</th><td>Time</td><td>10.1515 s</td><td>0.0 s</td><td>10.1515 s</td><td>20.303 s</td><td>0</td><td>Quantity{Float64, 𝐓, FreeUnits{(s,), 𝐓, nothing}}</td></tr><tr><th>4</th><td>Mass</td><td>0.225±0.066 kg</td><td>0.005±0.018 kg</td><td>0.224±0.071 kg</td><td>0.468±0.053 kg</td><td>0</td><td>Quantity{Measurement{Float64}, 𝐌, FreeUnits{(kg,), 𝐌, nothing}}</td></tr></tbody></table>
|
||||
<table class="data-frame"><thead><tr><th></th><th>variable</th><th>mean</th><th>min</th><th>median</th><th>max</th><th>nmissing</th><th>eltype</th></tr><tr><th></th><th>Symbol</th><th>Quantity</th><th>Quantity</th><th>Quantity</th><th>Quantity</th><th>Int64</th><th>DataType</th></tr></thead><tbody><p>4 rows × 7 columns</p><tr><th>1</th><td>Thrust</td><td>20.0±2.0 N</td><td>0.0±0.0 N</td><td>21.1±4.7 N</td><td>21.1±4.7 N</td><td>0</td><td>Quantity{Measurement{Float64}, 𝐋 𝐌 𝐓^-2, FreeUnits{(N,), 𝐋 𝐌 𝐓^-2, nothing}}</td></tr><tr><th>2</th><td>Pressure</td><td>1.39e7±3.6e6 Pa</td><td>310000.0±1.1e6 Pa</td><td>1.38e7±3.9e6 Pa</td><td>2.9e7±2.1e6 Pa</td><td>0</td><td>Quantity{Measurement{Float64}, 𝐌 𝐋^-1 𝐓^-2, FreeUnits{(Pa,), 𝐌 𝐋^-1 𝐓^-2, nothing}}</td></tr><tr><th>3</th><td>Time</td><td>10.1515 s</td><td>0.0 s</td><td>10.1515 s</td><td>20.303 s</td><td>0</td><td>Quantity{Float64, 𝐓, FreeUnits{(s,), 𝐓, nothing}}</td></tr><tr><th>4</th><td>Mass</td><td>0.225±0.066 kg</td><td>0.005±0.018 kg</td><td>0.224±0.071 kg</td><td>0.468±0.053 kg</td><td>0</td><td>Quantity{Measurement{Float64}, 𝐌, FreeUnits{(kg,), 𝐌, nothing}}</td></tr></tbody></table>
|
||||
|
||||
## Comparison to Rocket Motors
|
||||
|
||||

|
||||
|
||||
https://www.thrustcurve.org/
|
||||
|
||||
`readme auto generated`
|
||||
|
Reference in New Issue
Block a user