Simulating the performace of an air propulsion system as an alternative to solid rocket motors.
Boilerplate intro about why all of this was done
using Plots
plotly():ggplot2); # In true R spirit
theme(
using Unitful
using DataFrames
using Measurements
using Measurements: value, uncertainty
This code is just the setup, using values scraped from various parts of the world wide web.
# Tank https://www.amazon.com/Empire-Paintball-BASICS-Pressure-Compressed/dp/B07B6M48SR/
= (85 ± 5)u"inch^3"
V = (4200.0 ± 300)u"psi"
P0 = (2.3 ± 0.2)u"lb"
Wtank = (250 ± 50)u"psi" # Max Pressure that can come out the nozzle
Pmax
= 1.5u"kg"
Wsolenoid
# Params
= ((1 // 18) ± 0.001)u"inch"
d_nozzle = (pi / 4) * d_nozzle^2
a_nozzle
# Universal Stuff
= (1 ± 0.2)u"atm"
P_amb = 1.4 ± 0.05
γ = 287.05u"J/(kg * K)"
R = (300 ± 20)u"K" T
This is the actual simulation. Maybe throw some references in and explain some equations.
The rocket equation is pretty sick:
\[T = \dot{m} \cdot v_\text{Exit} + A_\text{Nozzle} \cdot (P - P_\text{Ambient}) \] And thats about all you need to get to the moon(Curtis 2020).
let
= 0.0u"s"
t = P0 |> u"Pa"
P = V * (P / (R * T)) |> u"kg"
M = 1u"ms"
ts global df = DataFrame(Thrust=(0 ± 0)u"N", Pressure=P0, Time=0.0u"s", Mass=M)
while M > 0.005u"kg"
# while t < 30u"s"
# Calculate what is leaving tank
= minimum([P, Pmax])
P = sqrt((2 * γ / (γ - 1)) * R * T * (1 - P_amb / P)^((γ - 1) / γ)) |> u"m/s"
ve = P / (R * T) |> u"kg/m^3"
ρ = ρ * a_nozzle * ve |> u"kg/s"
ṁ
= ṁ * ve + a_nozzle * (P - P_amb) |> u"N"
Thrust
# Calculate what is still in the tank
= M - ṁ * ts |> u"kg"
M = (M * R * T) / V |> u"Pa"
P = t + ts
t
= DataFrame(Thrust=Thrust, Pressure=P, Time=t, Mass=M)
df_step append!(df, df_step)
end
end
Heres the results plotted. Notice the massive error once the tank starts running low.
Big conclusion about things.
If you see mistakes or want to suggest changes, please create an issue on the source repository.