Created
July 4, 2018 07:28
-
-
Save fewlinesofcode/203f576d94fca841d797760aea5b55e1 to your computer and use it in GitHub Desktop.
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
import math | |
def to_deg(angle): | |
return angle * (180 / math.pi) | |
def to_rad(angle): | |
return angle * (math.pi / 180) | |
# Environment | |
airDensity = 1.2234 # kg/m^3 | |
frictionFactor = 0.004 # - | |
dragCoefficient = 0.7 # - | |
gravityFactor = 9.81 # m/s^2 | |
windDirection = 310.0 # - | |
windVelocity = 2.94 # m/s | |
rollingResistanceCoefficient = 0.0032 | |
# Bike and rider | |
bikeMass = 10 # kg | |
riderMass = 80 # kg | |
dragValues = [{ | |
"yawAngle": 5, | |
"dragArea": 0.258 | |
}, | |
{ | |
"yawAngle": 10, | |
"dragArea": 0.257 | |
} | |
] | |
wheelAerodynamicFactor = 0.0044 #- | |
distanceCovered = 471.8 # m | |
initialVelocity = 8.27 # m/s | |
finalVelocity = 8.45 # m/s | |
rideDirection = 340.0 # - | |
grade = 0.003 # - | |
timeToCoverDistance = 56.42 # s | |
momentOfInertiaOfWheels = 0.14 # kg/m^2 | |
outerTireRadius = 0.557 # m | |
chainEfficiencyFactor = 0.976 # - | |
groundVelocity = distanceCovered / timeToCoverDistance # m/s | |
# Air velocity (V_air) | |
tangentWindVelocity = windVelocity * math.cos(to_rad(rideDirection) - to_rad(windDirection)) # m/s | |
airVelocity = groundVelocity + tangentWindVelocity | |
print("V_air:", airVelocity) | |
# Yaw angle | |
normalWindVelocity = windVelocity * math.sin(to_rad(rideDirection) - to_rad(windDirection)) # m/s | |
yawAngle = to_deg(math.atan((normalWindVelocity / airVelocity))) | |
print("Yaw angle:", yawAngle) | |
# Aerodynamic power (P_ad) | |
cda = ((dragValues[1]["dragArea"] - dragValues[0]["dragArea"]) / (dragValues[1]["yawAngle"] - dragValues[0]["yawAngle"])) * (yawAngle - dragValues[0]["yawAngle"]) + dragValues[1]["dragArea"] | |
aerodynamicPower = math.pow(airVelocity, 2) * groundVelocity * airDensity * 0.5 * (cda + wheelAerodynamicFactor) | |
print("P_ad:", aerodynamicPower) | |
# Rolling resistance power (P_rr) | |
rollingResistancePower = groundVelocity * math.cos(math.atan(grade)) * rollingResistanceCoefficient * (bikeMass + riderMass) * gravityFactor | |
print("P_rr:", rollingResistancePower) | |
# Wheel bearing friction power (P_bfl) | |
wheelBearingFrictionPower = groundVelocity * (91.0 + 8.7 * groundVelocity) * math.pow(10, -3) | |
print("P_bfl", wheelBearingFrictionPower) | |
# Power related to changes in potential energy (P_pe) | |
potentialEnergyPower = groundVelocity * (bikeMass + riderMass) * gravityFactor * math.sin(math.atan(grade)) | |
print("P_pe", potentialEnergyPower) | |
# Power related tochanges in kineticenergy (P_ke) | |
kineticEnergyPower = 0.5 * (bikeMass + riderMass + momentOfInertiaOfWheels / math.pow(outerTireRadius, 2)) * (math.pow(finalVelocity, 2) - math.pow(initialVelocity, 2)) / timeToCoverDistance | |
print("P_ke", kineticEnergyPower) | |
# Total power (P_total) | |
totalPower = (aerodynamicPower + rollingResistancePower + wheelBearingFrictionPower + potentialEnergyPower + kineticEnergyPower) * chainEfficiencyFactor | |
print("P_total", totalPower) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment