- Joined
- Dec 1, 2023

- Messages
- 1

- Reaction score
- 0

import math

earth_mass = 5.972e24 # kg

earth_radius = 6371000 # meters

time_step = 0.01

# user values

print(f"Program only works up to 85000 meters")

initial_height = float(input("Enter the initial altitude (meters): "))

print(f"Drag Coefficient values for known shapes are: sphere = 0.47, cube = 1.05, cylinder = 0.82, cone = 0.5, human_spread_eagle = 1.0")

drag_coefficient = float(input("Enter the Drag Coefficient of the object:"

))

mass = float(input("Enter the mass of the object (kg): "))

diameter = float(input("Enter the diameter of the object (meters): "))

initial_velocity = float(input("Enter the initial velocity (m/s): "))

initial_acceleration = float(input("Enter the initial acceleration (m/s^2): "))

# No atmosphere calculation

altitude = initial_height

velocity = initial_velocity

acceleration = initial_acceleration

time = 0.0

while altitude > 0:

gravity = 6.67e-11 * (earth_mass / (earth_radius + altitude)**2)

area = math.pi * (diameter / 2)**2

if 71000 <= altitude <= 85000:

density = 1.225 / (1 + 0.00694 * altitude) ** 0.0171

elif 51000 <= altitude < 71000:

density = 1.225 / (1 + 0.00971 * altitude) ** 0.01222

elif 47000 <= altitude < 51000:

density = 1.225

elif 32000 <= altitude < 47000:

density = 1.225 * (1 - 0.00971 * altitude) ** 0.0122

elif 20000 <= altitude < 32000:

density = 1.225 * (1 - 0.00347 * altitude) ** 0.0171

elif 11000 <= altitude < 20000:

density = 1.225

else:

density = 1.225 * (1 - 0.00002 * altitude) ** 5.26

drag_force = 0.5 * density * velocity**2 * area * drag_coefficient

acceleration = (gravity - drag_force / mass)

velocity += acceleration * time_step

altitude -= velocity * time_step

time += time_step

print(f"Freefall time with atmosphere: {time:.2f} seconds")

# No atmosphere calculation

altitude = initial_height

velocity = initial_velocity

acceleration = initial_acceleration

time = 0.0

while altitude > 0:

gravity = 6.67e-11 * (earth_mass / ((earth_radius + altitude)**2))

acceleration = initial_acceleration + gravity

velocity += acceleration * time_step

altitude -= velocity * time_step

time += time_step

print(f"Freefall time without atmosphere: {time:.2f} seconds")