Python - Calculate Delta V Budget for Space Mission
by matt392 in Design > Software
28 Views, 0 Favorites, 0 Comments
Python - Calculate Delta V Budget for Space Mission
Python program that calculates the Delta V Budget for a space mission. Code is attached and below.
Downloads
Supplies
- Python
- Python IDE like IDLE
# Formula to calculate the Delta V Budget for a space mission
# Delta V Budget = (Square Root(Gravitational Parameter/Initial Radius)) * ((Square Root(2 * Final Radius)/(Initial Radius + Final Radius))-1) )
import math
print ("Formula to calculate the Delta V Budget for a space mission")
print ("The formula for Delta V Budget is: Delta V Budget = (Square Root(Gravitational Parameter/Initial Radius)) * ((Square Root(2 * Final Radius)/(Initial Radius")
# Define functions that will calculate the formula
# Calculate the left side of the formula
def leftsideofformula():
EnteredGravitationalParameter = input ("Enter the gravitational parameter in meters cubed/second squared: ")
EnteredInitialRadius = input ("Enter the initial radius in meters: ")
# Convert to float and integers
GravitationalParameter = float(EnteredGravitationalParameter)
InitialRadius = int(EnteredInitialRadius)
LeftSideOfFormula = math.sqrt(GravitationalParameter/InitialRadius)
print("The left side of the formula is: ", LeftSideOfFormula)
return InitialRadius, LeftSideOfFormula
# Calculate the bottom of the formula
def rightsideofformula(InitialRadius):
EnteredFinalRadius = input ("Enter the final radius in meters: ")
# Convert to integer
FinalRadius = float(EnteredFinalRadius)
RightSideOfFormula = ((math.sqrt((2 * FinalRadius)/(InitialRadius + FinalRadius))) - 1)
print("The right side of the formula is: ", RightSideOfFormula)
return RightSideOfFormula
# Place results of leftsideofformula() into a tuple
InitialRadius, LeftSideOfFormula = leftsideofformula()
RightSideOfFormula = rightsideofformula(InitialRadius)
# Use the left and right numbers to make final Delta V Budget in calculation
# Place result from function into variable to print
DeltaVBudget = LeftSideOfFormula * RightSideOfFormula
print ("The Delta V Budget is:", DeltaVBudget, "meters per second.")