# Consumption

The consumption features of the API extend the routing service to enable calculation of energy and fuel consumption for electric vehicles and fuel-based vehicles, respectively. The consumption calculation is based on a consumption model that, along with map data, also depends on user-provided consumption parameters. Consumption model for electric vehicles and fuel-based vehicles share certain common concepts but also differ in some aspects. This guide deals with:

## Common consumption concepts

The consumption models for both electric and fuel-based vehicles depend on the user provided consumption speed tables freeFlowSpeedTable and trafficSpeedTable.

### Consumption speed table

Consumption speed tables define the rate of energy or fuel consumption, in vehicle-dependent-units per meter driven, when the vehicle travels on a straight road with no change in elevation, at a given speed (in km/h).

A table represents a piecewise linear function. The following is a function with the corresponding request option:

fuel[freeFlowSpeedTable]=0,0.239,27,0.239,45,0.259,60,0.196,
75,0.207,90,0.238,100,0.26,110,0.296,120,0.337,130,0.351


#### Vehicle-dependent-units:

• Unit for EV:
Vehicle Type Unit
Electric Wh/m i.e., Watt-hours per meter
• Units for Fuel-based vehicles:
Vehicle Type Unit
Diesel, Petrol & LPG ml/m i.e., milliliters per meter
CNG gm/m i.e., grams per meter

#### Consumption speed function

The API allows two different consumption speed tables to be provided: freeFlowSpeedTable and trafficSpeedTable.

• freeFlowSpeedTable describes energy or fuel consumption when travelling at constant speed.
• trafficSpeedTable describes energy or fuel consumption when travelling under heavy traffic conditions, that is when the vehicle is expected to often change the travel speed, at a given average speed.

If the request does not specify trafficSpeedTable, then only freeFlowSpeedTable is used to calculate speed-related energy or fuel consumption. Otherwise, the following formula is applied:

$P_{speed} = S_T(v_t) + \frac{v_t}{v_f} \times (S_F(v_t) - S_T(v_t)),$

where

• $$v_f$$ is the free flow speed of a given road, defined as the estimated speed of travel without considering any traffic-related constraints,
• $$v_t$$ is the average traffic speed of a given road, that uses available traffic information to estimate the speed of travel,
• $$S_T$$ and $$S_F$$ are the traffic and free flow speed tables, respectively.

For example, if the traffic speed is equal to the free flow speed, then the calculation will use only the freeFlowSpeedTable in order to determine the energy or fuel consumption. The lower the traffic speed is compared to the free flow speed, the bigger an effect the trafficSpeedTable will have.

## Consumption model for electric vehicles

The consumption model for electric vehicles depends on additional user provided parameters and provides additional controls for energy consumption calculations like charging time, levels, stations, etc. For details refer to Consumption model for EV

## Consumption model for fuel-based vehicles

Note: This feature is currently a Beta version.

The consumption model for fuel-based vehicles allows you to specify vehicle specific parameters, which are then used to calculate fuel consumption for the vehicle on a given route.

The fuel consumption is in Liters (L) for diesel, petrol and LPG, and in Kilograms (Kgs) for CNG.

### Consumption calculation formula for fuel-based vehicles

In this model, consumption ($$C$$) along the segment depends on the length, speed and elevation difference.

$C = P_{asc} \cdot \Delta h_+ + P_{speed} \cdot L + P_{addl} \cdot t$

#### Request and Model Parameters for fuel-based vehicles

The following request parameters define the consumption model for consumption calculation:

Request Parameter Model Parameter Mandatory Description
freeFlowSpeedTable $$P_{speed}$$ Yes Function curve specifying consumption rate at a given free-flow speed on a flat stretch of road. For details, see Consumption speed table.
trafficSpeedTable $$P_{speed}$$ Function curve specifying consumption rate at a given speed under traffic conditions on a flat stretch of road. For details, see Consumption speed table.
additionalConsumption $$P_{addl}$$ Fuel consumption in grams (gms) or milliliters (mls) by the vehicle's auxiliary systems (for example, air-conditioning, lights, etc.) per second of travel.
ascent $$P_{asc}$$ Fuel consumption in grams (gms) or milliliters (mls) per meter rise in elevation.

#### Map Parameters for fuel-based vehicles

The following parameters are taken from the map data to support the consumption calculation:

Parameter Description
$$L$$ Length of the segment in meters.
$$t$$ Travel time along the segment in seconds.

To obtain fuel consumption of a fuel-based vehicle, add details of a consumption model to the request. All request parameters related to fuel-based vehicles start with the prefix fuel.

For code samples, see the tutorial: