Skip to content

Instantly share code, notes, and snippets.

@ecounysis
Created October 18, 2013 14:21
Show Gist options
  • Save ecounysis/7042278 to your computer and use it in GitHub Desktop.
Save ecounysis/7042278 to your computer and use it in GitHub Desktop.
How much power in watts do you need on a stationary bicycle in order to replicate outdoor riding conditions given your weight, speed, wind resistance, and grade?
#http://en.wikipedia.org/wiki/Bicycle_performance#Aerodynamics_vs_power
G = 9.8 #earth's gravitational constant
K1 = 0.0053 #lumped constant for all frictional losses (tires, bearings, chain), and is generally reported with a value of 0.0053
K2 = 0.185 #lumped constant for aerodynamic drag and is generally reported with a value of 0.185 kg/m
def power(velocity_ground, velocity_air, grade, mass):
"""
mass is in kg
velocity_ground and velocity_air are in meters per second
grade is percent eg 0.05, 0.12
"""
return G*mass*velocity_ground*(K1+grade)+K2*velocity_air**2*velocity_ground
def kg(pounds):
return pounds*0.453592
def meters_per_second(miles_per_hour):
return miles_per_hour*0.44704
def epower(velocity_ground, velocity_air, grade, weight):
"""
mass is in lbs
velocity_ground and velocity_air are in miles per hour
grade is percent eg 0.05, 0.12
"""
velocity_ground=meters_per_second(velocity_ground)
velocity_air=meters_per_second(velocity_air)
mass=kg(weight)
return power(velocity_ground, velocity_air, grade, mass)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment