Last active
August 29, 2015 14:17
-
-
Save saxbophone/f5e0531bde0244af2e33 to your computer and use it in GitHub Desktop.
Hacky sim of acceleration over time, taking air resistance into effect until acceleration effectively becomes nil
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from time import sleep | |
mass = 303209.382 # Kg of a tube train roughly | |
force = 0.0 # Newtons, initially set to 0 | |
accel = 0.0 # m/s^2, initially set to 0 | |
power = 0.0 # Newtons, force being applied | |
drag = 0.0 # Newtons, air resistance | |
roll = 0.0 # Netwons, rolling resistance | |
velocity = 0.0 # m/s, speed | |
# start count at 0 seconds | |
count = 0 | |
# set force to something | |
power = 16000.0 | |
while True: | |
force = power-drag-roll | |
# f = m*a | |
accel = force/mass | |
# air resistance rule | |
# ??? air density cube coefficient cross-sectional area | |
drag = 0.5 * 1.29 * (velocity * velocity) * 1.05 * 20.0 | |
# rolling resistance rule | |
# weight * gravity * rolling resistance coefficient of steel rail | |
roll = mass * 9.81 * 0.001 | |
sleep(1) | |
velocity += accel | |
print('{0} s\t{1}N \t{2}m/s/s \t{3}m/s \t{4}KpH'.format(count, round(force, 2), round(accel, 2), round(velocity, 2), round((velocity * 60 * 60) / 1000, 2))) | |
count += 1 | |
#if round(accel, 2) == 0.0: | |
# break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment