mirror of
https://gitlab.com/lander-team/air-prop-simulation.git
synced 2025-07-25 23:51:37 +00:00
init
This commit is contained in:
59
thrust.jl
Normal file
59
thrust.jl
Normal file
@@ -0,0 +1,59 @@
|
||||
using Unitful
|
||||
using DataFrames
|
||||
using Plots
|
||||
using UnitfulRecipes
|
||||
using Roots
|
||||
using CSV
|
||||
|
||||
|
||||
# Tank https://www.amazon.com/Empire-Paintball-BASICS-Pressure-Compressed/dp/B07B6M48SR/
|
||||
V = 90u"inch^3"
|
||||
P0 = 4500.0u"psi"
|
||||
Wtank = 2.3u"lb"
|
||||
Pmax = 100u"psi"
|
||||
|
||||
Wsolenoid = 1.5u"kg"
|
||||
|
||||
# Params
|
||||
d_nozzle = (1 // 16) * u"inch"
|
||||
a_nozzle = (pi / 4) * d_nozzle^2
|
||||
Poutmax = 800u"psi"
|
||||
|
||||
# Universal Stuff
|
||||
P_amb = 1u"atm"
|
||||
γ = 1.4
|
||||
R = 287.05u"J/(kg * K)"
|
||||
T = 300u"K"
|
||||
|
||||
# Setting up while loop
|
||||
t = 1.0u"s"
|
||||
P = P0 |> u"Pa"
|
||||
M = V * (P / (R * T)) |> u"kg"
|
||||
df = DataFrame(Thrust = 0.0u"N", Pressure = P, Time = t, Mass = M)
|
||||
ts = 0.001u"s"
|
||||
while M > 0.01u"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"
|
||||
ρ = P / (R * T) |> u"kg/m^3"
|
||||
ṁ = ρ * a_nozzle * ve |> u"kg/s"
|
||||
|
||||
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)
|
||||
append!(df, df_step)
|
||||
end
|
||||
println("---------------------------\n\n\n\n")
|
||||
println("Total Impulse: ", sum(df.Thrust) * ts)
|
||||
println("Burn Time: ", t)
|
||||
println("Mass Total: ", Wtank + Wsolenoid + maximum(df.Mass))
|
||||
|
||||
print(describe(df))
|
||||
plot(df.Time, df.Thrust, title = "Thrust Over Time")
|
||||
CSV.write("thrustdata.csv", df .|> ustrip)
|
Reference in New Issue
Block a user