"""THIS IS A BICYCLE AND MOTORCYCLE DESIGN AID
HIS PROGRAM IS MEANT TO ACCOMPANY THE TEXT
" THE CHRONICLES OF THE LORDS OF THE CHAINRING"
THIS IS SPECIFICALLY BUILT TO INCLUDE
THE ANGULAR MOMENTUM OF THE WHEELS AND THE EFFECT OF TILLER."""
from math import *
from numpy import zeros
def graph (vel, n, count, konst):
KX = 630 / count
for k in range(1, count - 2):
YY = -konst * vel[n, k] + 390
YYY = -konst * vel[n, k + 1] + 390
XX = KX * k + 10
XXX = KX * (k + 1) + 10
print YY, XX, XXX, YYY
#LINE (XX, YY)-(XXX, YYY)
#LINE (10, 390)-(630, 390)
vel = zeros((6, 200)) ## 2D list
## INPUT ALL DISTANCE VALUES IN METERS, MASS IS KG
## INPUT ALL ANGLES IN DEGREES
##we are metric
deg = pi / 180
## .O254 CONVERTS INCHES TO METERS
## ENTER YOUR GEOMETRY DATA HERE (CHANGE THE VALUE OF A, B ETC TO MATCH YOUR DESIGN)
## A =wheelbase
A = 1.18
## B = dist from rear axle to cg "riders belly button"
B = .55
##beta1 = head tube angle ,
beta1 = 60
## H =distance from the gnd to cg "riders belly button"
h = .67
## mass 1 KG IS 2.2 LBS ,
M = 215 / 2.2
## s= fork offset normal to headtube PLUS MEANS THE AXLE IS FORWARD OF THE STEERING AXIS
s = .02
## Rh IS HANDLEBAR RADIUS
Rh = .3
## Til is the TILLER the position of the hands aft of the steering axis
Til = 1 * .0254
## Fha is the constant force of each hand hanging from the handlebars
## this is only an estimate. It is possible to pull harder to aid high
## speed riding.
Fha = 1
## Rt is the tire caseing radius
Rt = .5 * .0254
## KX = radius of gyration of the bike and rider about cg X axis
## estimate .26 for supine rider to .44 for vertical seat back
## more for a fully faired vehicle
KX = .35
## beta = complement of beta1
BETA = (90.01 - beta1) * pi / 180
##the program divideds by zero for a beta1 of zero
##r= radius of front wheel
r = .245
##rr = radius of the rear wheel
rr = 12.8 * .0254
##++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## INCLUDING ANGULAR MOMENTUM OF THE WHEELS.
## RHO IS A REASONABLE ESTIMATE FOR THE MASS PER METER OF A LIGHT BIKE WHEEL/TIRE
RHO = .5
RF = r
rr = rr
## MASS MOMENTS OF INERTIA OF THE FRONT AND REAR WHEEL
IIF = 2 * pi * RHO * RF * RF * RF
IIR = 2 * pi * RHO * rr * rr * rr
## FOR MOTORCYCLE WHEELS, MEASURE MASS MOMENTS
CB = cos(BETA)
SB = sin(BETA)
IFUN = (IIF / RF + IIR / rr) * CB / A
DELF = IFUN * (B / (A * h)) * KX * KX / (KX * KX + h * h)
OM = (IIF * CB / (RF * A)) * (SB + B * CB / h)
## ADD ESTIMATES OF TILLER ON THE CONTROL SPRING K1
K1Til = -2 * Fha * Til
#-------------------------------------------------------------------------------
# ====================== WARNING ============
# CHANGE NO DATA PAST THIS POINT
#-------------------------------------------------------------------------------
## del is trail
DEL = r * tan(BETA) - s / cos(BETA)
DELK2 = DELF * (DEL * (CB) + Rt) + OM
G = 9.81
##v = velocity at start of plot ,
v = .1
## INPUTTING HANDLING QUALITY CONSTANTS
kc = (B * cos(BETA)) / (A * h)
kkkc = kc / Rh
kc1 = M * G * B * DEL * cos(BETA) * sin(BETA) / A
KC2 = (DEL * cos(BETA) + Rt * sin(BETA)) * M * B * cos(BETA) * (KX * KX / (KX * KX + h * h)) / (A * A)
KA = 1 / 1500
## ADD THE EFFECT OF WHEEL MOMENTUM
KC2 = KC2 + DELK2
## ADD THE EFFECT OF TILLER
kc1 = kc1 + K1Til
## FIND FORK FLOP
FLOP = M * 9.81 * (B / A) * DEL * cos(BETA) / Rh
## NOW FIND THE MINIMUM SPEED WHERE THE BIKE STOPS WOBBLING
mmmin = (kc1 / KC2)
if (kc1 / KC2) <= 0: mmmin = .01
VVMIN = 3.6 * mmmin**.5
##FIND THE MAXIMUM SENSITIVITY
velmaxis = 0
maxes = 0
count = 1
nn = -1
while True:
vel[1, count] = 18
##1 is control MAX RECOMMENDED SENSTIVITY LINE
vel[2, count] = (kc1 - KC2 * v * v) / Rh
##2 is control spring rate
vel[5, count] = kc * v / (Rh + (KA / Rh) * (-kc1 + KC2 * v * v))
##5 is sensitivity
if (maxes < vel[5, count]): velmaxis = v
if (maxes < vel[5, count]): maxes = vel[5, count]
v = v + .2
if v >= 15: break
count = count + 1
velmaxis = velmaxis * 3.6
konst = 18
print " LOW SPEED HANDLING VALUES "
print "for a headtube angle of ", beta1
print "for a fork offset of ", s
print "trail = ", DEL
print "or = ", DEL / .0254, "INCHES"
print
print "FORK FLOP IS ", FLOP, "newtons/radian"
print
print
print "Fork flop is an indicator of the bike to turn towards a lean"
print " it aids us as a sort of auto pilot and should be between "
print " 50 and 150 newtons per radian. If it is too much, the handlebars"
print " will jerk too hard. If it is too little, the bike will require too"
print "much attention."
print
print " WOBBLE SPEED IS ", VVMIN, "Km/Hr"
print
print "below this speed, your handlebars tend to deviate. "
print "this is why new riders wobble at low speed when"
print "the control spring is backward which makes the bike hard to control"
print
print
print " hit enter to see a plot of the control spring, hit enter again to contiue. "
konstd = 10
print
print " CONTROL SPRING VS VELOCITY"
print "stable values up"
konstd = -.1
graph(vel, 2, count, konstd)
print "VELOCITY -->"
print
print " HIGH SPEED HANDLING VALUES "
print " At high speed, the bike reacts more to control inputs "
print " this is termed sensitivity. the model used here is highly simplified"
print " but, has been validated up to 40 miles per hour. Higher speeds might need "
print " analysis that include angular accelerations and control damping "
print " that have been ignored in this model."
print
print
print " MAX SENSITIVITY IS ", maxes, " radians/meter"
print
print " at a speed of ", velmaxis, "km/hour"
print
print
print " High speed plots may be in error above 40 mph. Control sensitivity "
print " may be higher than predicted. "
print " Maximum senstivity has been found to be 18 radians/meter for normal folks"
print " higher values may be used by experienced riders."
print
print
print
print " hit enter to see the sensitivy plot"
print
print " Roll Sensitivity "
konstd = 18
graph(vel, 5, count, konstd)
graph(vel, 1, count, konstd)
print "overcontrol line"
print "VELOCITY -->"
print
print
print " This computer modesl is incomplete, other derivatives change bike handling. "
print " For more information and hints as to how to change handling "
print " qualities, get the Lords of the chainring. "
print
print " email at wpatters@calpoly.edu"