Ejemplo n.º 1
0
def dist4(V_BIKE, V_WIND, GRADE, G_FRAC, debug, C_SF):
    total_s = 0
    DELTA_V = 0.05              # m/sec
    v_i = common.meter_per_second(V_BIKE)  # convert from kmph to m/sec.
    delta_e = get_delta_ke(v_i, v_i - DELTA_V)
    drag_forces = get_total_res(common.kmph(v_i), V_WIND, GRADE, G_FRAC, debug, get_rear_frac(G_FRAC), C_SF)
    delta_s = delta_e / drag_forces
    while (v_i > 1.0):      # repeat till velocity is 1 m/s
        v_f = v_i - DELTA_V
        v_a = (v_f + v_i) / 2.0     # average velocity
        delta_t = delta_s / (v_a)   # time interval
        drag_forces = get_total_res(common.kmph(v_f), V_WIND, GRADE, G_FRAC, debug, get_rear_frac(G_FRAC), C_SF)
        if (drag_forces < 0):
            return -1
        delta_ke = get_delta_ke(v_i, v_f) 
        # calculate delta pe using delta s, positive when gradient is uphill and negative for downhill
        delta_pe = TOTAL_MASS * G_ACCEL * (GRADE / 100.0) * v_a * delta_t
        #delta_pe = TOTAL_MASS * G_ACCEL * (GRADE / 100.0) * delta_s

        # calculate the drag forces as F * d_s = d_e, delta_ke will be negative when slowing down
        # d_e is the total energy lost 
        delta_e = delta_ke - delta_pe        
        delta_s = delta_e / drag_forces
        total_s = total_s + delta_s
        v_i = v_f
        if (debug):
            print ("TE: " + common.nice_s(delta_e)  + " KE: "          + common.nice_s(delta_ke) + \
                   " PE: " + common.nice_s(delta_pe) + " Drag Forces: " + common.nice_s(drag_forces) + \
                   " DS: " + common.nice_s(delta_s) + " DT: " + common.nice_s(delta_t))
       
    return total_s
Ejemplo n.º 2
0
def calc_dist(V_BIKE, V_WIND, GRADE, G_FRAC, debug, return_dist, rear_frac, C_SF):
    if (rear_frac == INVALID_REAR_FRAC):
        rear_frac = get_rear_frac(G_FRAC)
    TOTAL_RES = get_total_res(V_BIKE, V_WIND, GRADE, G_FRAC, debug, rear_frac, C_SF)
    DELTA_TIME = 0.05 # seconds
    total_time = 0
    velocity = V_BIKE
    iter = 0
    stopping_dist = 0
    while (velocity > 1):
        # calculate the drag force, new acceleration, new velocity, and cumulative stopping distance
        TOTAL_RES = get_total_res(velocity, V_WIND, GRADE, G_FRAC, debug, rear_frac, C_SF)
        if (TOTAL_RES < 0):
            return -1
        accel = TOTAL_RES / TOTAL_MASS
        new_velocity = velocity - common.kmph(accel) * DELTA_TIME  # convert accel from m/s to kmph
        stopping_dist = stopping_dist + common.meter_per_second(DELTA_TIME * new_velocity)
        velocity = new_velocity
        iter = iter + 1
        total_time += DELTA_TIME
        if (iter > 10000):
           return -1
    if (return_dist):
        return stopping_dist
    return total_time
Ejemplo n.º 3
0
def calc_power(total_res, v_bike):
    EFFICIENCY = 0.95
    return common.meter_per_second(v_bike) * total_res / EFFICIENCY
Ejemplo n.º 4
0
def calc_air_res(K_A, v_bike, v_wind, alpha_d):
    v_bike = common.meter_per_second(v_bike)
    v_wind = common.meter_per_second(v_wind)
    return calc_wind.get_head_wind2(v_bike, v_wind, alpha_d) * K_A
Ejemplo n.º 5
0
def dist2(velocity, c_a, c_r):
    numer = common.meter_per_second(velocity) * common.meter_per_second(velocity)
    denom = 20 * (c_a + c_r)
    return numer / denom