You are on page 1of 26

Dear​ ​reader,

As​ ​a​ ​citizen​ ​and​ ​taxpayer​ ​of​ ​Tompkins​ ​County,​ ​you​ ​might​ ​be​ ​concerned​ ​about​ ​the​ ​economic
viability​ ​of​ ​your​ ​county’s​ ​decision​ ​to​ ​purchase​ ​eight​ ​hybrid​ ​busses.​ ​ ​Given​ ​the​ ​magnitude​ ​of​ ​this
investment​ ​(according​ ​to​ ​the​ ​Environmental​ ​and​ ​Energy​ ​Study​ ​Institute,​ ​your​ ​average​ ​hybrid​ ​bus
runs​ ​at​ ​about​ ​210,000$​ ​more​ ​than​ ​a​ ​normal​ ​diesel-powered​ ​bus1)​ ​you​ ​would​ ​be​ ​well​ ​within​ ​your
rights​ ​to​ ​scrutinize​ ​the​ ​efficacy​ ​of​ ​this​ ​plan,​ ​and​ ​so​ ​we​ ​are​ ​writing​ ​The​ ​Ithaca​ ​Journal​ ​to​ ​put​ ​your
mind​ ​at​ ​ease.

By​ ​considering​ ​Ithaca’s​ ​hilly,​ ​hilly​ ​terrain​ ​we​ ​calculated​ ​the​ ​amount​ ​of​ ​energy​ ​that​ ​a​ ​hybrid​ ​bus
would​ ​spend​ ​going​ ​around​ ​six​ ​different​ ​TCAT​ ​routes​ ​around​ ​downtown,​ ​and​ ​CU​ ​and​ ​IC’s
campuses.​ ​ ​Given​ ​how​ ​much​ ​power​ ​the​ ​battery​ ​in​ ​the​ ​hybrid​ ​bus​ ​can​ ​output​ ​we​ ​were​ ​then​ ​able​ ​to
say​ ​how​ ​much​ ​of​ ​the​ ​energy​ ​that​ ​this​ ​hybrid​ ​bus​ ​spent​ ​would​ ​be​ ​energy​ ​that​ ​was​ ​harvested​ ​by​ ​the
battery​ ​when​ ​it​ ​would’ve​ ​otherwise​ ​been​ ​wasted​ ​in​ ​a​ ​normal​ ​diesel-powered​ ​bus.​ ​ ​The​ ​power
salvaged​ ​by​ ​the​ ​bus​ ​going​ ​around​ ​the​ ​different​ ​routes​ ​was​ ​highly​ ​dependent​ ​on​ ​the​ ​exact​ ​terrain
of​ ​the​ ​route,​ ​and​ ​so​ ​we​ ​were​ ​able​ ​to​ ​pick​ ​the​ ​best,​ ​most​ ​efficient​ ​routes​ ​so​ ​that​ ​the​ ​shrewd
taxpayer​ ​could​ ​reap​ ​maximum​ ​profit​ ​from​ ​this​ ​investment.

It​ ​should​ ​come​ ​as​ ​a​ ​pleasant​ ​surprise​ ​to​ ​hear​ ​that,​ ​on​ ​the​ ​most​ ​efficient​ ​of​ ​the​ ​routes​ ​that​ ​we
examined,​ ​route​ ​10,​ ​a​ ​hybrid​ ​bus​ ​will​ ​save​ ​more​ ​than​ ​43000​ ​Joules​ ​a​ ​second!​ ​In​ ​plain​ ​English,​ ​a
hybrid​ ​bus​ ​would​ ​save​ ​almost​ ​a​ ​gallon​ ​of​ ​diesel​ ​every​ ​forty​ ​minutes2!​ ​ ​Barring​ ​a​ ​major​ ​drop​ ​in
the​ ​price​ ​of​ ​diesel,​ ​since​ ​the​ ​10​ ​bus​ ​operates​ ​twelve​ ​hours​ ​a​ ​day,​ ​after​ ​20​ ​years​ ​a​ ​hybrid​ ​bus
running​ ​on​ ​route​ ​10​ ​will​ ​recoup​ ​the​ ​investment​ ​that​ ​you,​ ​the​ ​taxpayer,​ ​put​ ​into​ ​it.

We​ ​hope​ ​that​ ​this​ ​letter​ ​has​ ​put​ ​your​ ​mind​ ​at​ ​ease,​ ​and​ ​that​ ​you,​ ​like​ ​us​ ​and​ ​Tompkins​ ​County’s
government,​ ​feel​ ​that​ ​the​ ​initial​ ​investment​ ​is​ ​worth​ ​both​ ​the​ ​cost​ ​we’ll​ ​recoup​ ​in​ ​the​ ​long​ ​run,
and​ ​the​ ​environmental​ ​advantages​ ​of​ ​hybrid​ ​busses​ ​over​ ​traditional​ ​busses.

​ ​ ​ ​ ​ ​ ​Sincerely,

Aditi​ ​Kabra,​ ​Mac​ ​Carden,

&​ ​John​ ​Mastroberti

1
​ ​Environmental​ ​and​ ​Energy​ ​Study​ ​Institute;​ ​Hybrid​ ​Busses:​ ​Costs​ ​and​ ​Benefits​.
http://www.eesi.org/files/eesi_hybrid_bus_032007.pdf
2
​ ​Don​ ​Hofstrand​ ​of​ ​Iowa​ ​State​ ​University;​ ​Liquid​ ​Fuel​ ​Measurements​ ​and​ ​Conversions​.
https://www.extension.iastate.edu/agdm/wholefarm/pdf/c6-87.pdf
Hybrid Buses for TCAT
Mac Carden, Aditi Kabra and John Mastroberti
Cornell Mathematical Contest in Modeling 2017
November 12, 2017

Abstract
In this paper we examine the efficiency of putting hybrid buses on six di↵erent TCAT routes
to determine which ones yielded the greatest benefit. Using data from the manufacturer
of TCAT’s buses, and Google Earth, we determine that the best routes to put the hybrid
buses on are 10, 81, and 82, based on the inclines the bus would need to traverse along the
di↵erent routes. We also examine the robustness of our results by playing with assumptions
that we used to assure ourselves that these three paths remain the best routes, even if
our assumptions carry a reasonable error. Additionally, further work on how to optimize
the energy saved by the hybrid buses based on how and when we switch the hybrids onto
di↵erent routes is discussed.

1
Contents
1 Introduction 3

2 Parameters 3
2.1 Assumptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Notation Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3 Method 5

4 Results 7

5 Robustness 7

6 Future Work 8
6.1 Dynamic Programming Algorithm . . . . . . . . . . . . . . . . . . . . . . . . 8

7 Conclusions 9

8 References 10

9 Appendix 11
9.1 Python Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
9.2 Route Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
9.2.1 Route 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
9.2.2 Route 11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
9.2.3 Route 15 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
9.2.4 Route 17 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
9.2.5 Route 81 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
9.2.6 Route 82 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

2
1 Introduction
We are interested in improving the overall fuel efficiency of the Tompkins County Area
Transit (TCAT) bus system by replacing existing diesel buses with diesel-electric hybrids.
To maximize fuel efficiency, we must determine which of TCAT’s routes would best leverage
the benefits of a hybrid bus.
The hybrid buses save energy over the diesel buses by running the bus o↵ of battery
power and a electric motor when possible. However, the buses must use the stronger diesel
engine to go up sufficiently steep hills and whenever the battery needs to recharge. The buses
have a mechanism to charge the batteries directly from the diesel engine and a mechanism
to harness energy from the brakes.
TCAT would like to replace some of the buses on routes 10, 11, 15, 17, 81, or 82 with
hybrid buses, so our task is to determine which of these routes would yield the greatest
energy savings. This reduces to determining the average power output by the motor on each
of the routes, since this is all power that the engines are saved from outputting.

2 Parameters
As we determined by directly inspecting a TCAT bus, TCAT uses Gillig Standard Low Floor
Buses. According to a report by Gillig,9 these buses have a mass of about M = 16, 000 kg.
The diesel-only model of this bus uses a Cummins ISL9 engine, while the hybrid model also
has a BAE Hybridrive E system.1 This Hybridrive system consists of a direct drive traction
motor and a lithium-ion battery.3
The technical documentation of the diesel engine indicates that it can run at a power
level of PD = 209 kW.4 In contrast, the electric motor is only designed to run at a power
level of PE = 120 kW.11 The battery employed by the Hybridrive system has a maximum
capacity of Bm = 114 MJ and a maximum power output of 200 kW,10 so the battery should
not limit the power output from the electric motor.
We obtained measurements of the distances the buses need to travel along each of the
routes, as well as how the elevation changes along each route, from Google Earth.5 In
addition to this geographical data, we also obtained speed limits from the City of Ithaca
legal code,2 as well as from Ithaca College7 and Cornell University8 regulations.

2.1 Assumptions
Several simplifying assumptions were necessary in our analysis of the TCAT bus system.
First and foremost, we assume all of the bus routes have the same approximate frequency
of stops (both from traffic and designated bus stops) so that we may ignore this aspect
of the buses’ motion. This assumption greatly simplifies calculations and serves as a first
approximation to the buses’ motion.
This assumption is most inaccurate on route 11, which includes a two mile section re-
quiring very few stops. This assumption makes the other routes look less favorable than
they actually are in comparison to route 11. However, we shall see that route 11 already

3
yields relatively poor improvements when running with hybrid buses, so this assumption is
safe since we wouldn’t be assigning the hybrid buses to route 11 anyway.
Additionally, we make some simplifying assumptions about the buses’ technical details.
We take the battery’s advertised capacity of 31.8 kWh as the total usable capacity; that
is, the di↵erence in energy stored in the battery at full charge and at minimum charge is
31.8 kWh. Due to a lack of available documentation about how exactly the buses’ brake
generators might work, we will take the maximum output rate advertised for the generator,
PG = 145 kW,11 as the maximum rate at which the brakes can generate power for the battery.
Lastly, we don’t know how exactly the battery recharges o↵ of the diesel engine, so we assume
that the amount of energy D provided to the battery by the engine is linear in the amount
of work done WD by the diesel engine:

D = aWD

We call this constant of proportionality the diesel recharge constant and assume it has a
value of 0.8. Additionally, we assume that the diesel engine does not do any more work than
it usually would when it is charging the battery.
Of course, the buses must expend some power just to travel at a constant speed. A report
by Cummins Inc6 presents some data on how much power it takes to keep a truck traveling
at a constant speed. Specifically, the graphs on pages 6-7 of the report indicate that at low
speeds (30 miles per hour or slower), the power Pf needed to maintain a constant speed on
a flat road is approximately linearly related to the speed v:
119 hp
Pf = v = (3050 N)v
65 mph
We assume that this describes the amount of power it takes for the buses to travel along a
flat surface at a constant speed. Moreover, we assume that when the buses are going up or
down an incline, the total power the buses consume is just the sum of the power used to
travel along a flat surface of equal length and the power consumed or released to increase or
decrease the buses’ height by the height of the hill:

Ptot = Pf + Ph

Note that when the buses are going down a hill, Ph < 0.
We are also ignoring the energy spent or saved when the buses speed up or slow down
when changing speed. We make this simplification because although more energy is required
to speed the buses up, the buses can then coast and spend no energy when slowing back
down. We know that the speeding up and slowing down occurs cyclically because the buses
drive in loops, so this assumption should minimally a↵ect our conclusions.

2.2 Notation Summary


In summary, the following table lists the parameters that have been defined (with a few new
ones too), along with their values.

4
Symbol Meaning Value
M Mass of a bus 16000 kg
PD Power of the diesel engine 209 kW
PE Power of the electric motor 120 kW
Bm Maximum battery capacity 114 MJ
PG Maximum power the battery can receive at any time 145 kW
a Diesel recharge constant 0.8
g Acceleration due to gravity 9.81 m/s2

Additionally, the following variable names will be used:

Symbol Meaning Units


x Horizontal distance covered by a route section m
y Signed vertical distance covered by a route section m
d Total distance traveled along a route section m
t Time taken to traverse a route section s
tD Time spent running the diesel engine on this section s
v Speed of the bus m/s
Pf (v) Power required sustain speed v on a flat road W
Ph Extra power consumed/released when ascending/descending an incline W
U Signed change in potential energy between the start and end of a route section J
Ptot Total power consumed/released to move the bus along a section of the route W
E Energy released or consumed after traversing a section J
B Amount of energy stored in the battery J
D Amount of energy sent to the battery by the diesel engine J
WD Amount of work done by the diesel engine on this section J
WE Running total work done by the electric motor J
P Average power delivered by the motor over the whole route W

3 Method
We have broken up each of the routes into short sections which we consider linear. We then
iterate over each section of the route, calculating how much work the generator saves the
diesel engine from doing. Our running total of how much work the electric motor has done
is WE .
First, we calculate the power that is consumed to maintain the bus’s speed along that
section if the section was flat using the formula introduced in section 2.1:

Pf (v) = (3040 N)v (1)

Then, we investigate the power Ph that is expended to ascend/descend the section. We do


this by calculating the potential energy di↵erence between the start and end of the section:

U = M gy (2)

5
With this, we just need the time taken to traverse the section to find Ph . We start by
computing the distance traveled, p
d = x2 + y 2 (3)
from which we find that
d
t= (4)
v
Thus, Eqs. 2-4 let us write
U M gyv
Ph = =p (5)
t x2 + y 2
Which, when combined with Eq. 1, tells us that
" #
M gy
Ptot = Pf + Ph = (3040 N) + p v (6)
x2 + y 2

Now, if the battery is currently recharging, we must run the diesel engine for this section.
Otherwise, we check if the electric motor is strong enough to cover this section of the route.
If Ptot  PE , we run the electric motor for at least part of this section. We find that the
total energy used (or released) along the section is

E = Ptot t (7)

Now, we must consider the following three cases:

1. If 0 < E < B, we update WE to WE + E and B to B E.

2. If E > B, we update WE to WE + B and then update B to 0, switching the battery


over to charging.

3. If E < 0, the motor doesn’t actually get to do any work. However, the brakes will
get to recharge the battery to some degree. If Ptot < PG , we update B to B + E.
Otherwise, we update B to B + PG t.

If the motor is not strong enough to run on this section, or if the battery is currently charging,
we simply run the diesel engine on this section.
After all of this, if the diesel engine ran for any amount of time, we recharge the battery
by an amount
D = aPtot tD (8)
Note that D is always positive, because the diesel engine doesn’t run when Ptot < 0. We
then update B to min {B + D, Btot }, and if that gives us B = Btot , we no longer consider
the battery to be charging if it was.
We run these steps on each step of the bus route, obtaining a total amount of work WE
done by the electric motor. To fairly compare the routes, we compute the time averaged
power output by the electric motor over the route by
WE ⇣X ⌘ 1
P = = WE t (9)
T

6
where we sum all the times spanned by all of the sections of the route.
So far, we have not taken into account that the bus’s charge level might change from
the start to the finish of the route. To account for this, we run the algorithm many times,
feeding the final battery status into being the initial status on the next run of the algorithm.
We then average the powers output by the motor on each cycle of the route to get a measure
of the motor’s typical average power output on the route.

4 Results
After running our algorithm on all of the routes, we find that the average power output by
the motor has the following values for each of the routes:
Route number Average Power Output
10 43.3 kW
11 27.3 kW
15 17.2 kW
17 36.2 kW
81 62.9 kW
82 36.2 kW

As we can see from the table, route 81 benefits the most from hybrid buses. After this, route
10 provides the next most benefit, followed by route 82. It seems fitting then that we should
always assign a hybrid bus to route 81. After transitioning all of the buses on route 81 to
being hybrids, we should transition as many of the buses on route 10 to being hybrids as
possible. Finally, the rest of the hybrid buses should be assigned to route 82.

5 Robustness
Since we only care about which routes yield the greatest benefit from a hybrid bus and not
exactly how much benefit is yielded, we tested the robustness of our model by varying some
of the parameters we were uncertain of and checking if the ranking of which route had the
biggest benefit changes. The first parameter we investigated was a, which describes how fast
the battery charges o↵ of the diesel engine. For a & 0.5, the ranking we presented in section
4 is una↵ected. However, as a is pushed lower than about 0.5, route 10 yields larger benefits
from the hybrid buses than route 81. When a is pushed down even further to around 0.1,
route 11 yields greater benefits than route 17.
These changes make logical sense; as we turn down a, the buses are relying on braking
for a greater portion of their recharging than on the engine. Route 10 contains steeper hilly
sections than route 81, so it makes sense that route 10 starts to yield greater benefits than
route 81 as a decreases. Similarly, route 11 is hillier than route 17, so for sufficiently small
a route 11 benefits more from a hybrid bus than route 17.
However, these changes do not a↵ect our conclusion: we still find that route 81 and route
10 provide the first and second best benefits from the hybrid buses (not necessarily in that
order), followed by route 82. Since TCAT has 8 hybrid buses and only at most 4 buses run

7
on routes 81 and 82 combined, we still want to use only hybrid buses on routes 10 and 81,
and then assign the rest of the hybrid buses to route 82.
Apart from a, the only other parameter that substantially influenced which routes yield
the best benefits was the mass of the bus, M . Reducing M by about 15% or increasing M by
about 10% causes route 10 to yield better benefits than route 81 while leaving the ranking
of the other routes the same. Again, this doesn’t change which routes should get hybrid
buses; route 81 and 10 are still the two most optimal routes, followed by route 82, so 81 and
82 should still be fully transitioned to hybrid buses and the rest of the hybrid buses should
be assigned to route 82. Changing any of the other parameters, including the maximum
rate at which the battery can recharge from the brakes and the minimum charge level of the
battery, does not a↵ect which routes yield the best benefits from the hybrid buses.
Of particular note is the fact that changing the dependence of Pf on v (even so that Pf is
up to 3 times more or less sensitive to changes in v) does not a↵ect which routes provide the
best benefits from hybrid buses. This indicates that our solution should work even in winter
conditions because the e↵ect of the icy roads is to make Pf larger. This is because the bus
must do more work to go the same speed when the roads are slippery, since the wheels don’t
get to do as much work on the road as when the road is not icy.

6 Future Work
One thing we would like to add to our model is some treatment of how often the buses need
to stop, both for traffic and for designated bus stops. This is the biggest assumption that we
have made with our model, and it may a↵ect how routes 11 ranks as well as how our results
vary with the time of day. Additionally, a better model of how the diesel engine recharges
the battery would help increase the accuracy of our results. We might also want to have a
more detailed consideration of how slippery roads a↵ect the performance of the hybrid buses
than our variation of Pf . Additionally, only routes 11, 15 and 17 run on weekends, and there
are other bus routes that only run on the weekends, so we may want to look at a di↵erent
set of potential routes to assign the hybrid buses to on the weekends.

6.1 Dynamic Programming Algorithm


Given the data we have acquired above, we can determine the optimal bus assignment
computationally using a dynamic programming algorithm, as is standard for scheduling
problems. Such an algorithm would allow for rapidly computing new assignments when
conditions and constants change, and would give us the absolute optimum, taking into
account reassigning routes and the penalty for doing so, and starting charge capacities, since
the energy saved on a route is dependent also on initial charge of the battery.
We are given 6 routes. Some of these routes have more than one bus running on them at
any given time. Let us consider these multiple timings to be di↵erent tasks. For example,
if at any given time, two buses are running route 82, let us say that there are two tasks —
82.1 and 82.2. Let R(t) be the set of all tasks to be done at time t. Divide the day into a
finite number of time intervals N .

8
Let maxN t=1 (R(t)) = M . Also, let Combinations(R(t)) be the set of all subsets of R(t)
consisting of at most 8 tasks, and c be such a combination. For doing c, we have a “reward”
equal to the energy expended by the battery in doing all the routes in c. For shifting from a
set of tasks c0 to c, let there be a “penalty”, consisting of the minimum possible amount of
extra energy expended in shifting between routes of c and c0 .
Define OPT(t, c) to be the maximum possible reward one can get from doing tasks before
time interval t, assuming you do all the tasks in c at t, and OPT(t) to be the maximum
possible reward one can get by doing tasks until time t. Finally have non clashing(t, c) to
be the set of all possible combinations that lie n later than t 1 and do not clash with c.
We have the following recursive relation:
✓ ✓ ◆◆
OPT(t) = max OPT(t 1), max max (OPT(t 1, h) + reward(c) penalty(h, c))
c2R(t) h2non clashing(t,c)

To solve this problem efficiently, we can build a table of OPT values, starting o↵ from t = 0
and building up to t = N . To solve for any t = n, we need only to refer to the values of
OPT with t < n, which we will already have computed.
Our table might look something like this:
t=0 t=1 ··· t=N
Task 10.1 OPT(1, {10.1}) ··· OPT(N, {10.1})
Task 10.2 OPT(1, {10.2}) ··· OPT(N, {10.2})
··· ··· ··· ···
Tasks 10.1,10.2 OPT(1, {10.1, 10.2}) ··· OPT(N, {10.1, 10.2})
Optimal Combination OPT(1) ··· OPT(N )
Start with the leftmost column and fill downwards. There are at most M C 8 rows. There
are N columns.
The innermost max is O(nM ), and the next max is O(M nM ), the outermost max is a
single comparison, hence the overall complexity is just O(M nM ). Keep in mind that M is
a constant, small number (the total number of “tasks”). This makes the algorithm fairly
computable.
If we want to account for the di↵ering “rewards” for a route depending on initial battery
charge, we could add a dimension to our table for di↵erent possible starting charge levels.
This would not optimize over the continuous charge levels, but we could make our approxi-
mation better and better by making our discrete intervals smaller. The penalty in runtime
for this, however, is significant: if we account for f possible starting fuel states, runtime
becomes O(f M nf M ).

7 Conclusions
Now that we’ve determined that 81, 10, & 82 are the most efficient placements of the buses,
the question remains as to how we should actually arrange the buses. Note that the route 81
always runs at most four buses, and route 10 runs at most three buses, so we can always fill
up 81 and 10 with hybrid buses, and we can put any buses which are leftover at the moment
on 82. (Note that 82 and 81 are very close so it is efficient to switch buses between them.)

9
When building our model we were unsure about some of the variables such as bus weight,
and the diesel recharge constant, but our examination of their robustness yielded that the
exact values of these constants (within reason) do not a↵ect which routes are the top three
most efficient, and thus we are fairly confident in our results. There is certainly work that
can be done to improve our model, but this serves as a good first approximation.

8 References
1
Gillig Low Floor. https://cptdb.ca/wiki/index.php/Gillig_Low_Floor. Accessed on
11 November 2017.
2
Ithaca, New York, Municipal Code §346-52.
3
Series-E: Electric Power and Propulsion. http://www.hybridrive.com/series-e.php.
Accessed on 11 November 2017.
4
Cummins Inc. ISL9 for Urban Bus and Shuttle (2013) — Specifications. https:
//cumminsengines.com/isl9-urban-bus-shuttle-2013?Filters=0&SearchText=
ISL9#specifications. Accessed on 11 November 2017.
5
Google Inc. Google Earth Elevation Data. Accessed on 11 November 2017.
6
Cummins Inc. Secrets of Better Fuel Economy — The Physics of MPG. Technical report,
Cummins Inc, n.y. The Physics of MPG.
7
Dave Maley. Ithaca College Parking Policy Committee and Office of Public Safety An-
nounce Acquisition of Radar Unit to Address Speeding On Campus, 2005. Ithaca College.
8
Office of Transportation Services. Rules and Regulations for the Control of Traffic and
Parking on the Grounds of Cornell University. Technical report, Cornell University, 2006.
9
Ron Quebbeman. Gillig Corporation VIN System. Technical report, Gillig Corporation,
2000.
10
BAE Systems. ESS-3G-32K — Energy Storage System. Technical report, BAE Systems
plc, 2016.
11
BAE Systems. DDTM-100 — Direct Drive Traction Motor. Technical report, BAE Systems
plc, 2017.

10
9 Appendix
Here, we present present the python code we used to implement our method, as well as the
data we obtained from Google Earth, Ithaca’s municipal code, Ithaca College and Cornell
University about the routes themselves.

9.1 Python Code


import math
import csv

#CONSTANTS
_DISTANCE_COLUMN = 0
_ELEVATION_COLUMN = 2
_SPEED_COLUMN = 3
_ROUTE_COLUMN = 4

_MAX_POWER = 120000 #W
_BUS_MASS = 16000 #pounds
_POWER = 88738/29 #multiply with speed
_INIT_CHARGE = 114000000 #J
_MIN_CHARGE = 0
_MAX_CHARGE = 114000000 #J
_MAX_RECHARGE = 145000 #W
_A = 0.8 #recharge/energy spent -need better estimate

_AVERAGE_ENERGY = 0
_END_CHARGE = 1
_IS_CHARGING = 2

def main():
elevation_data_file = "./Elevation.csv"
route_data = read_routes(elevation_data_file)
print loop(40, route_data)
vary_initial_values(route_data)

def loop(no_times, route_data):


answer_dict = dict()
old_dict = dict()
for i in range(no_times):
approximation_dict = {route : first_approx_power(
data, _POWER, init_charge =
(old_dict.get(route, (0,0,False))[_END_CHARGE]),
charging = (old_dict.get(route, (0,0,False))[_IS_CHARGING]))
for (route, data) in route_data.iteritems()}

11
old_dict = approximation_dict
answer_dict = {route : (energy[_AVERAGE_ENERGY] +
answer_dict.get(route, 0))
for (route, energy) in approximation_dict.iteritems()}
return {route : (energy/no_times)
for (route, energy) in answer_dict.iteritems()}

def vary_initial_values(route_data):
"""Print the results where initial battery charge is varied as
0*max, 0.1*max ... 1*max"""
approximation_list = []
for i in range(11):
approximation_list += [{route : first_approx_power(
data, _POWER, init_charge = (
i * 0.1 * _MAX_CHARGE))[_AVERAGE_ENERGY]
for (route, data) in route_data.iteritems()}]
print_list = []
for i in range(11):
appr_dict = approximation_list[i]
row = [i, appr_dict[’10’], appr_dict[’11’], appr_dict[’15’],
appr_dict[’17’], appr_dict[’81’], appr_dict[’82’]]
print row

def read_routes(file_path):
"""Reads csv file containing path data in form:
distance from origin | Beginning elevation | ending elevation | speed |
route.
Return dictionary of form:
{
route_number : sorted list of (distance from origin,
elevation at point, speed)
}
"""
route_dict = dict()
with open(file_path) as csvfile:
reader = csv.reader(csvfile, delimiter=’,’)
next(reader)
for row in reader:
route_dict.update({row[_ROUTE_COLUMN] :
((route_dict.get(row[_ROUTE_COLUMN], []))
+ [(float(row[_DISTANCE_COLUMN]), float(row[_ELEVATION_COLUMN]),
float(row[_SPEED_COLUMN]))])})
#Sort data points by distance from origin
sorted_route_dict = {route : sorted(data,

12
key=lambda data_tuple : data_tuple[0])
for (route, data) in route_dict.iteritems()}
#special case: programmatically get loop for route 17 and 82
sorted_route_dict.update({’17’:loop_route(sorted_route_dict.get(’17’,[]))})
sorted_route_dict.update({’82’:loop_route(sorted_route_dict.get(’82’,[]))})
return {route : map(
lambda (dist, el, speed) : (dist*1609.34, el*0.3048, speed*0.44704),
data) for (route, data) in sorted_route_dict.iteritems()}

def first_approx_power(route, P, max_power = _MAX_POWER, bus_mass = _BUS_MASS,


init_charge = _INIT_CHARGE, min_charge = _MIN_CHARGE,
max_charge = _MAX_CHARGE, max_recharge = _MAX_RECHARGE,
A = _A, charging = False):
"""
Returns average energy consumed by battery over route (ignoring recharge),
and charge that the batery is left with.
route : list of tuplets, each one of which represents a point, of form:
(miles gone since its starting point, elevation, speed of the bus until
the next point).
max_power : the maximum power after which the battery switches to diesel.
bus_mass : the mass of the bus.
P : P * velocity = the power it takes for the bus to run on flat land at a
constant speed (ie the power it takes for the bus to counteract frictive
forces).
init_charge : the initial charge of the battery.
min_charge : the minimum charge of the battery before it switches to
diesel power.
max_charge : the maximum energy the battery can hold before it stops
recharging.
A : "diesel recharge constant". Assuming that the recharge rate of
the battery when the bus is on diesel is
proportional to the energy that the engine is generating, let A be the
constant such that (recharge = A*(power*t)).
charging: true if the bus starts off chrging
returns : (average energy consumed by battery, current charge, isCharging)
"""
#tuple position constants
_X_DISTANCE = 0
_ELEVATION = 1
_SPEED = 2
_G = 9.8

#set initial conditions


total_time = 0

13
battery_energy_used = 0
current_charge = init_charge
old_x_distance = 0
old_elevation = route[0][_ELEVATION]
#threshold till which battery recharges before being switched back to use:
charging_threshold = max_charge * 0.9

#simulate run over route


for data_point in route:
#setup variables
x_distance = data_point[_X_DISTANCE]
elevation = data_point[_ELEVATION]
delta_x_distance = x_distance - old_x_distance
if delta_x_distance == 0:
continue #in case this is the same point
delta_elevation = elevation - old_elevation
distance = math.sqrt(delta_x_distance**2 + delta_elevation**2)
speed = data_point[_SPEED]
time = distance/speed
angle = math.atan(delta_elevation/delta_x_distance)
total_time += time

#compute energy required = work against gravity + work against friction


required_energy = delta_elevation*bus_mass*_G + P*speed
required_power = required_energy/time
engine_power = required_power - max_power
charging = charging or (engine_power<0)

if not charging:

#if going upwards:


if (required_energy > 0):
if ((current_charge - min_charge) > required_energy):
current_charge -= required_energy
battery_energy_used += required_energy
else:
#assumption: required_energy <= battery cpacity
battery_energy_used += (current_charge - min_charge)
current_charge = min_charge + (
(required_energy - (current_charge - min_charge))
/required_energy)*A
charging = True
#if going downwards
if (required_energy<0):

14
required_energy = -required_energy
#to work with a poitive value.
charge_rate = min(required_energy/time, max_recharge)
energy_change = charge_rate * time
if current_charge + energy_change <= max_charge:
current_charge += energy_change
else:
current_charge = max_charge

#if charging
else:

#if going upwards:


if (required_energy > 0):
recharge = required_energy * A
if ((current_charge + recharge) > charging_threshold):
battery_energy_used += (
current_charge+recharge-charging_threshold)
current_charge = charging_threshold - (
current_charge+recharge-charging_threshold)
charging = False
else:
current_charge += recharge
#if going downwards
if (required_energy<0):
required_energy = -required_energy
#To work with a poitive value.
charge_rate = min(required_energy/time, max_recharge)
energy_change = charge_rate*time
if current_charge + energy_change <= charging_threshold:
current_charge += energy_change
else:
current_charge = max_charge
charging = current_charge < charging_threshold

#update for next iteration


old_x_distance = x_distance
old_elevation = elevation
return (battery_energy_used/total_time, current_charge, charging)

def loop_route(route):
"""Given a tuple list representing route, return list + reversed list
as representing the way there and back.
route: list of tuples. Each tuple is of form (distance, elevation, speed).
returns: looped route for traveling forwards and then returning backwards

15
along route."""
_DISTANCE_COL = 0

max_dist = route[len(route)-1][_DISTANCE_COL]
points_reversed = map(lambda (dist, el, speed) : (
(2*max_dist) - dist, el, speed), route)
reversed_sorted = sorted(
points_reversed, key=lambda (dist, el, speed) : dist)
return route + reversed_sorted

if __name__ == ’__main__’:
main()

9.2 Route Data


9.2.1 Route 10

Cumulative horizontal distance (m) Elevation (m) Speed Limit (m/s)


0.0 125.5776 13.4112
128.7472 124.6632 13.4112
354.0548 122.8344 13.4112
579.3624 127.7112 13.4112
659.8294 138.9888 13.4112
885.137 161.8488 13.4112
949.5106 157.5816 13.4112
1319.6588 175.5648 13.4112
1673.7136 213.36 13.4112
1899.0212 239.268 13.4112
2092.142 246.5832 13.4112
2253.076 248.1072 13.4112
2365.7298 252.6792 13.4112
2687.5978 252.6792 13.4112
2751.9714 248.1072 13.4112
2961.1856 245.364 13.4112
3218.68 232.5624 13.4112
3299.147 231.9528 13.4112
3379.614 223.7232 13.4112
3443.9876 224.6376 13.4112
3508.3612 230.7336 13.4112
4538.3388 153.0096 13.4112
4667.086 133.1976 13.4112
5053.3276 126.7968 13.4112

16
9.2.2 Route 11

Cumulative horizontal distance (m) Elevation (m) Speed Limit (m/s)


0.0 125.2728 13.4112
1319.6588 126.7968 13.4112
1448.406 140.5128 13.4112
2687.5978 240.1824 13.4112
2993.3724 246.2784 13.4112
3283.0536 266.0904 11.176
4280.8444 270.6624 11.176
4860.2068 311.8104 11.176
5455.6626 319.7352 11.176
5793.624 331.3176 11.176
6147.6788 317.6016 11.176
8320.2878 223.4184 13.4112
9334.172 143.8656 13.4112
9430.7324 126.1872 13.4112
9591.6664 126.492 13.4112

9.2.3 Route 15

Cumulative horizontal distance (m) Elevation (m) Speed Limit (m/s)


0.0 125.5776 13.4112
80.467 124.968 13.4112
209.2142 123.1392 13.4112
321.868 123.444 13.4112
386.2416 121.6152 13.4112
498.8954 124.3584 13.4112
563.269 121.6152 13.4112
595.4558 122.5296 13.4112
659.8294 121.6152 13.4112
756.3898 121.6152 13.4112
804.67 120.396 13.4112
836.8568 121.6152 13.4112
901.2304 120.0912 13.4112
933.4172 121.6152 13.4112
1013.8842 118.872 11.176
1062.1644 120.0912 11.176
1094.3512 120.0912 11.176
1126.538 119.1768 11.176
1207.005 119.7864 11.176
1271.3786 118.2624 11.176
1303.5654 119.4816 11.176

17
1351.8456 118.5672 11.176
1384.0324 119.4816 11.176
1448.406 116.7384 11.176
1512.7796 119.7864 11.176
1561.0598 118.2624 11.176
1593.2466 117.0432 11.176
1673.7136 117.0432 11.176
1705.9004 118.2624 11.176
1850.741 118.2624 13.4112
1915.1146 116.7384 13.4112
2124.3288 115.2144 13.4112
2220.8892 115.2144 13.4112
2301.3562 117.348 13.4112
2381.8232 116.7384 13.4112
2430.1034 117.348 13.4112
2671.5044 116.1288 13.4112
2751.9714 118.2624 13.4112
2800.2516 116.7384 13.4112
2896.812 116.7384 13.4112
3154.3064 118.5672 13.4112
3266.9602 117.6528 6.7056
3299.147 116.7384 6.7056
3411.8008 117.9576 6.7056
3492.2678 117.6528 6.7056
3540.548 117.0432 6.7056
3862.416 116.4336 6.7056
3975.0698 117.6528 6.7056
4039.4434 115.824 6.7056
4457.8718 118.5672 6.7056
4586.619 117.0432 6.7056
4667.086 117.9576 6.7056
4779.7398 120.7008 6.7056
4828.02 119.7864 6.7056
4924.5804 118.2624 6.7056
4988.954 118.872 6.7056
5149.888 116.4336 13.4112
5182.0748 117.9576 13.4112
5278.6352 117.0432 13.4112
5310.822 116.4336 13.4112
5520.0362 115.824 13.4112
5616.5966 117.6528 13.4112
5680.9702 116.4336 13.4112

18
5922.3712 116.7384 13.4112
5970.6514 118.2624 13.4112
6051.1184 116.1288 13.4112
6163.7722 117.348 13.4112
6228.1458 117.9576 13.4112
6308.6128 117.6528 13.4112
6356.893 116.7384 11.176
6405.1732 119.4816 11.176
6469.5468 118.5672 11.176
6517.827 121.6152 11.176
6550.0138 118.5672 11.176
6598.294 120.396 11.176
6759.228 120.0912 11.176
6807.5082 119.7864 13.4112
6871.8818 121.3104 13.4112
6920.162 120.396 13.4112
6952.3488 121.6152 13.4112
6984.5356 120.7008 13.4112
7129.3762 124.6632 13.4112
7161.563 123.1392 13.4112
7258.1234 123.1392 13.4112
7306.4036 123.7488 13.4112
7370.7772 123.444 13.4112
7515.6178 125.5776 13.4112

9.2.4 Route 17

Cumulative horizontal distance (m) Elevation (m) Speed Limit (m/s)


0.0 117.6528 13.4112
48.2802 117.9576 13.4112
64.3736 117.6528 13.4112
112.6538 117.348 13.4112
144.8406 117.0432 13.4112
177.0274 117.0432 13.4112
257.4944 117.9576 13.4112
273.5878 117.348 13.4112
321.868 117.9576 13.4112
386.2416 117.6528 13.4112
418.4284 117.348 13.4112
466.7086 118.2624 13.4112
498.8954 117.6528 13.4112
514.9888 117.348 13.4112
595.4558 119.1768 13.4112

19
643.736 117.348 13.4112
692.0162 120.0912 13.4112
740.2964 117.9576 13.4112
772.4832 118.2624 13.4112
804.67 117.6528 13.4112
852.9502 118.5672 13.4112
901.2304 117.9576 13.4112
933.4172 119.4816 13.4112
997.7908 117.9576 13.4112
1029.9776 119.4816 13.4112
1046.071 118.872 13.4112
1094.3512 119.1768 13.4112
1110.4446 118.5672 13.4112
1126.538 119.4816 13.4112
1174.8182 119.1768 13.4112
1207.005 119.7864 13.4112
1255.2852 119.1768 13.4112
1287.472 120.7008 13.4112
1335.7522 120.7008 13.4112
1400.1258 122.2248 13.4112
1496.6862 121.3104 13.4112
1528.873 122.8344 13.4112
1561.0598 122.8344 13.4112
1625.4334 121.92 13.4112
1673.7136 124.6632 13.4112
1721.9938 122.8344 13.4112
1850.741 125.8824 13.4112
1882.9278 124.6632 13.4112
1915.1146 124.968 13.4112
1963.3948 123.1392 13.4112
2011.675 124.0536 13.4112
2092.142 122.8344 13.4112
2140.4222 124.6632 13.4112
2172.609 121.92 13.4112
2236.9826 122.8344 13.4112
2253.076 121.92 13.4112
2317.4496 121.3104 13.4112
2349.6364 124.3584 13.4112
2381.8232 124.0536 13.4112
2397.9166 122.8344 13.4112
2446.1968 124.968 13.4112
2478.3836 123.7488 13.4112

20
2510.5704 124.3584 13.4112
2558.8506 124.0536 13.4112
2607.1308 124.3584 13.4112
2639.3176 123.7488 13.4112
2671.5044 124.968 13.4112
2719.7846 122.8344 13.4112
2735.878 124.0536 13.4112
2768.0648 124.3584 13.4112
2800.2516 121.3104 13.4112
2864.6252 121.92 13.4112
2880.7186 122.8344 13.4112
2945.0922 121.92 13.4112
2977.279 124.6632 13.4112
3025.5592 122.8344 13.4112
3106.0262 124.0536 13.4112
3154.3064 123.1392 13.4112
3202.5866 124.968 13.4112
3234.7734 124.6632 13.4112
3266.9602 125.8824 13.4112
3395.7074 122.8344 13.4112
3443.9876 124.6632 13.4112
3492.2678 121.92 13.4112
3556.6414 122.8344 13.4112
3588.8282 122.8344 13.4112
3621.015 121.3104 13.4112
3717.5754 122.2248 13.4112
3781.949 120.7008 13.4112
3830.2292 120.7008 13.4112
3862.416 119.1768 13.4112
3910.6962 119.7864 13.4112
3942.883 119.1768 13.4112
3991.1632 119.4816 13.4112
4007.2566 118.5672 13.4112
4023.35 119.1768 13.4112
4071.6302 118.872 13.4112
4087.7236 119.4816 13.4112
4119.9104 117.9576 13.4112
4184.284 119.4816 13.4112
4216.4708 117.9576 13.4112
4264.751 118.5672 13.4112
4313.0312 117.6528 13.4112
4345.218 118.2624 13.4112

21
4377.4048 117.9576 13.4112
4425.685 120.0912 13.4112
4473.9652 117.348 13.4112
4522.2454 119.1768 13.4112
4602.7124 117.348 13.4112
4618.8058 117.6528 13.4112
4650.9926 118.2624 13.4112
4699.2728 117.348 13.4112
4731.4596 117.6528 13.4112
4795.8332 117.9576 13.4112
4844.1134 117.348 13.4112
4860.2068 117.9576 13.4112
4940.6738 117.0432 13.4112
4972.8606 117.0432 13.4112
5005.0474 117.348 13.4112
5053.3276 117.6528 13.4112
5069.421 117.9576 13.4112
5117.7012 117.6528 13.4112

9.2.5 Route 81

Cumulative horizontal distance (m) Elevation (m) Speed Limit (m/s)


0.0 277.6728 13.4112
193.1208 265.4808 13.4112
273.5878 262.128 13.4112
354.0548 269.748 13.4112
370.1482 262.4328 13.4112
514.9888 259.08 13.4112
611.5492 256.032 13.4112
708.1096 267.3096 13.4112
724.203 252.3744 13.4112
772.4832 252.0696 13.4112
836.8568 247.8024 13.4112
901.2304 249.0216 13.4112
1013.8842 242.9256 13.4112
1094.3512 243.84 13.4112
1126.538 245.364 13.4112
1174.8182 243.5352 13.4112
1190.9116 252.6792 13.4112
1287.472 252.3744 13.4112
1512.7796 252.0696 13.4112
1657.6202 253.5936 13.4112
1689.807 251.7648 13.4112

22
1705.9004 243.5352 13.4112
1786.3674 247.8024 13.4112
1899.0212 242.316 13.4112
1995.5816 249.6312 13.4112
2076.0486 248.1072 13.4112
2124.3288 266.3952 13.4112
2253.076 256.6416 13.4112
2285.2628 268.5288 13.4112
2333.543 254.8128 13.4112
2381.8232 268.5288 13.4112
2414.01 269.1384 13.4112
2542.7572 269.1384 4.4704
2574.944 261.5184 4.4704
2719.7846 272.4912 4.4704
3186.4932 277.6728 11.176
3315.2404 277.9776 11.176
3637.1084 271.272 11.176
4184.284 243.2304 13.4112
4264.751 247.4976 13.4112
4345.218 242.316 13.4112
4473.9652 252.3744 13.4112
4844.1134 252.6792 13.4112
5343.0088 267.9192 13.4112
5664.8768 269.4432 13.4112
6018.9316 277.0632 13.4112

9.2.6 Route 82

Cumulative horizontal distance (m) Elevation (m) Speed Limit (m/s)


0.0 270.0528 6.7056
225.3076 262.128 6.7056
321.868 262.128 13.4112
643.736 277.6728 13.4112
836.8568 280.416 13.4112
949.5106 280.1112 13.4112
1126.538 277.6728 11.176
1223.0984 276.4536 11.176
1432.3126 272.1864 11.176
1577.1532 261.5184 11.176
1673.7136 259.9944 11.176
1963.3948 243.5352 13.4112
2027.7684 245.6688 13.4112
2059.9552 243.84 13.4112

23
2204.7958 252.984 13.4112
2526.6638 253.5936 13.4112
2558.8506 251.7648 13.4112
3138.213 268.224 13.4112
3363.5206 268.5288 13.4112
4071.6302 282.2448 13.4112
4168.1906 279.1968 13.4112
4280.8444 279.1968 13.4112
4634.8992 248.1072 13.4112
4747.553 258.7752 13.4112
4828.02 264.8712 13.4112
4908.487 259.9944 13.4112
4972.8606 252.984 13.4112
5117.7012 250.2408 13.4112
5198.1682 252.984 13.4112
5246.4484 250.8504 13.4112
5343.0088 256.032 13.4112
5503.9428 259.9944 13.4112
5568.3164 265.4808 13.4112
5777.5306 278.892 13.4112
5986.7448 281.94 13.4112
6051.1184 281.0256 13.4112
6228.1458 283.464 13.4112
6308.6128 279.8064 13.4112
6405.1732 285.2928 13.4112
6469.5468 282.5496 13.4112
6582.2006 284.3784 6.7056
6614.3874 283.464 6.7056
6759.228 286.2072 6.7056
6855.7884 284.988 6.7056
6984.5356 286.2072 6.7056
7097.1894 284.3784 6.7056
7193.7498 285.5976 6.7056
7290.3102 284.6832 6.7056
7386.8706 285.5976 6.7056
7483.431 284.3784 6.7056
7596.0848 286.2072 6.7056
7724.832 284.988 6.7056
7821.3924 286.2072 6.7056
7966.233 283.464 6.7056
7998.4198 284.3784 6.7056
8111.0736 282.5496 13.4112

24
8175.4472 285.2928 13.4112
8272.0076 279.8064 13.4112
8352.4746 283.464 13.4112
8529.502 281.0256 13.4112
8593.8756 281.94 13.4112
8803.0898 278.892 13.4112
9012.304 265.4808 13.4112
9076.6776 259.9944 13.4112
9237.6116 256.032 13.4112
9334.172 250.8504 13.4112
9382.4522 252.984 13.4112
9462.9192 250.2408 13.4112
9607.7598 252.984 13.4112
9672.1334 259.9944 13.4112
9752.6004 264.8712 13.4112
9833.0674 258.7752 13.4112
9945.7212 248.1072 13.4112
10299.776 279.1968 13.4112
10412.4298 279.1968 13.4112
10508.9902 282.2448 13.4112
11217.0998 268.5288 13.4112
11442.4074 268.224 13.4112
12021.7698 251.7648 13.4112
12053.9566 253.5936 13.4112
12375.8246 252.984 13.4112
12520.6652 243.84 13.4112
12552.852 245.6688 13.4112
12617.2256 243.5352 13.4112
12906.9068 259.9944 11.176
13003.4672 261.5184 11.176
13148.3078 272.1864 11.176
13357.522 276.4536 11.176
13454.0824 277.6728 11.176
13631.1098 280.1112 13.4112
13743.7636 280.416 13.4112
13936.8844 277.6728 13.4112
14258.7524 262.128 13.4112
14355.3128 262.128 6.7056
14580.6204 270.0528 6.7056

25

You might also like