-
Notifications
You must be signed in to change notification settings - Fork 0
/
rocketOptimization.py
90 lines (80 loc) · 3.69 KB
/
rocketOptimization.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#Project Name: Rocket Simulation
#Author: Conner Fransoo
#Date: January 30th, 2022
import math
idealDesign = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
oxidizerToFuelRatio = 2.5
#kg
engineMass = 15.0
payload = 10.0
dryMass = 0.0
wetMass = 0.0
#s
specificImpulse = 250.0
burnTime = 0.0
#N
thrust = 10000.0
#Pa
tankPressure = 2500000.0
#m
bodyTubeThickness = 0.002
fairingHeight = 1.0
tankThickness = 0.01
rocketRadius = 0.175
rocketHeight = 0.7
#m/s
deltaV = 0.0
#kg/m^30
keroseneDensity = 800.0
loxDensity = 1141.0
aluminumDensity = 2700.0
def finalMass(rocketRadius, rocketHeight):
#Assumes the body tube and fairing are made out of aluminum (density: 2700kg/m^3)
#LOX tank and fuel tank height proportions based on 2.5 Oxidizer to Fuel Mass Ratio and the differences in density
bodyTubeMass = math.pi*((rocketRadius**2.0)-((rocketRadius-bodyTubeThickness)**2))*rocketHeight*aluminumDensity
fairingMass = bodyTubeThickness * aluminumDensity * math.pi * rocketRadius * math.sqrt((rocketRadius**2)+(fairingHeight**2))
loxTankMass = (math.pi * ((rocketRadius-bodyTubeThickness) ** 2) * bodyTubeThickness * aluminumDensity * 2) + (math.pi * (((rocketRadius-bodyTubeThickness) ** 2)-((rocketRadius-bodyTubeThickness-tankThickness) ** 2)) * (0.6368*(rocketHeight-0.04)) * aluminumDensity)
fuelTankMass = (math.pi * ((rocketRadius-bodyTubeThickness) ** 2) * bodyTubeThickness * aluminumDensity * 2) + (math.pi * (((rocketRadius-bodyTubeThickness) ** 2)-((rocketRadius-bodyTubeThickness-tankThickness) ** 2)) * ((rocketHeight-0.04)/2.753) * aluminumDensity)
global dryMass
dryMass = bodyTubeMass + fairingMass + loxTankMass + fuelTankMass + engineMass + payload
return dryMass
def initialMass(dryMass, rocketRadius, rocketHeight):
loxMass = loxDensity * math.pi * ((rocketRadius-bodyTubeThickness-tankThickness)**2) * (0.6368*(rocketHeight-0.04))
fuelMass = keroseneDensity * math.pi * ((rocketRadius-bodyTubeThickness-tankThickness)**2) * ((rocketHeight-0.04)/2.753)
global wetMass
wetMass = dryMass + loxMass + fuelMass
return wetMass
def calculateBurnTime(wetMass, dryMass):
global burnTime
burnTime = (wetMass-dryMass)/(thrust/(9.81*specificImpulse))
return burnTime
def calculatedeltaV(initialMass, finalMass, burnTime):
global deltaV
deltaV = (specificImpulse * 9.81 * math.log(wetMass / dryMass))-(9.81*burnTime)
return deltaV
while rocketRadius < 0.31:
while wetMass < 340:
initialMass(dryMass, rocketRadius, rocketHeight)
finalMass(rocketRadius, rocketHeight)
calculateBurnTime(wetMass, dryMass)
calculatedeltaV(wetMass, dryMass, burnTime)
if deltaV > idealDesign[2]:
idealDesign[0] = rocketRadius
idealDesign[1] = rocketHeight
idealDesign[2] = deltaV
idealDesign[3] = burnTime
idealDesign[4] = wetMass
idealDesign[5] = dryMass
rocketHeight += 0.00001
rocketRadius += 0.00001
rocketHeight = rocketRadius * 4.001
print("Ideal rocket radius in meters is: " + str(idealDesign[0]))
print("Ideal rocket height in meters is: " + str(idealDesign[1]))
print("Maximum Delta V in m/s is: " + str(idealDesign[2]))
print("The initial mass of this rocket in kg is: " + str(idealDesign[4]))
print("The final mass of this rocket in kg is: " + str(idealDesign[5]))
#Equation from reference 1
maxHeight = (-9.81*idealDesign[3]/2)+(((9.81*specificImpulse*idealDesign[3]*dryMass)/(wetMass-dryMass))*math.log(dryMass/wetMass))+(9.81*specificImpulse*idealDesign[3])+((deltaV ** 2)/(9.81*2))
print("Maximum altitude reached in meters is: " + str(maxHeight))
flightTime = idealDesign[3]+(idealDesign[2]/9.81)
print("Flight time in seconds is: " + str(flightTime))