Matlab/Simulink Based Energy Consumption Prediction of Electric Vehicles

— Transport electrification represents one of the key aspects of achieving carbon neutrality. Despite the decreasing price of electric vehicles, the transition to electric vehicles is progressing relatively slowly. The main reasons delaying transport electrification are associated with the long charging time of electric vehicles, limited charging infrastructure, along the so-called range anxiety manifesting itself in driver's uncertainty on whether the vehicle can reach the target destination successfully. Energy consumption prediction plays an important role in reducing range anxiety by providing the driver an accurate estimate of the remaining range. This paper presents a MATLAB/Simulink model for the energy consumption prediction of electric vehicles on a designated route. The developed model is a physical model relying on longitudinal vehicle dynamics which can be easily personalized according to different models of electric vehicles. The developed model is tested on a standard FTP75 driving cycle using the available data on Tesla Model S.


INTRODUCTION
The transportation sector contributes about 23% to the global greenhouse gas emissions, and its electrification represents one of the key aspects of achieving carbon neutrality. The Sustainable Development Scenario compatible with the targets of the EV30@30 Campaign aims at reaching 30% of the market share for electric vehicles by 2030 [1]. Although transport electrification is blooming in countries like China and Norway, following the slow transition in most countries, it becomes questionable whether the 2030 targets are realistic. The main reasons delaying transport electrification are associated with the relatively high price of electric vehicles, long charging time, limited charging infrastructure, along so-called range anxiety [2]. Range anxiety is related to the limited driving range of electric vehicles and sparse charging infrastructure, leading to the driver's uncertainty on whether the vehicle can reach the target destination successfully. Despite the constant improvement of battery technology, the capacity of electric vehicle batteries will remain limited by the battery's weight and cost. Therefore, accurate prediction of electric vehicle energy consumption represents an important solution alleviating range anxiety.
Extensive literature provides a wide variety of different strategies for the energy consumption prediction of electric vehicles. In [3], the authors divided the energy consumption prediction techniques into two categories, namely: methods based on longitudinal vehicle dynamics and statistical methods based on measurements of the electric vehicle consumption and real-world data. In [4], the authors employed a neural network to classify the environment in which the electric vehicle is operating and estimate the energy consumption using the average conditions. The proposed approach neglects the vehicle dynamics, and the authors claimed their method to have an accuracy within 20-30% for the 800 test scenarios. In [5], the authors analyzed the influence of road topography on electric vehicle energy consumption using a simplified dynamics model where the required power is expressed as a linear function of the road slope. It was concluded that road topography needs to be taken into account in routing applications aiming to minimize the energy consumption of electric vehicles. In [6], the authors developed an offline/online method employing open-source route information and considering a simplified model of longitudinal vehicle dynamics personalized for a Volkswagen Lupo. The proposed method was validated through driving tests on public roads, where the accuracy of 5 and 10% was found for the online and the offline method, respectively. In [7], the authors presented a computationally efficient energy consumption model personalized for Nissan Leaf which provides sufficient accuracy when compared with FASTSim, a high-level powertrain model developed by NREL [8]. Energy consumption models are also of interest in eco-driving and eco-routing applications with different models employed in [9]- [12].
The main disadvantage of statistical methods is that the quality of the obtained results depends on the quality of the underlying data. Furthermore, the statistical methods usually neglect the vehicle dynamics, which play an important role in energy consumption. Apart from that, physical models enable the identification of the critical vehicle and road parameters affecting the energy consumption of electric vehicles. Therefore, this paper presents a physical model of the electric vehicle developed in MATLAB's graphical programming environment Simulink. The developed model incorporates both, the electrical and the mechanical characteristics of the electric vehicle which can be personalized to suit different models of electric vehicles. The developed model is parametrized using the available data on Tesla Model S, and its performance is evaluated on a standard FTP75 urban driving cycle and a driving cycle obtained for a realistic route. The driving cycle is used as a referent signal of the speedtracking controller contained in the Longitudinal driver block. The speed-tracking controller is a proportional-integral (PI) controller which generates normalized acceleration and braking commands based on the difference between the referent and the measured velocity. The PI controller also enables the specification of the elevation profile on the observed route, whereby the acceleration and braking commands become dependent on the road topography, thus enabling the application of such controller on realistic routes. The normalized acceleration and braking commands generated by the Longitudinal driver block represent the inputs of the Motor drive block with the decoupled diagram shown in Fig. 2. Three types of motors are predominantly used in the electric vehicle industry, namely: three-phase induction motors, synchronous motors with permanent magnets, and brushless DC motors. For simplicity, electric vehicles with DC motors are considered in this paper. The DC motor is controlled by an H-bridge. The normalized acceleration command is converted to an appropriate voltage value at the input of the H-bridge using a PWM-controlled voltage source. The braking command results in a short circuit of the H-bridge output, thus interrupting the motor's supply. To prevent the occurrence of an overvoltage caused by a sudden supply loss, the H-bridge also contains a flyback diode. By simulating the operation of the DC motor following the acceleration and braking commands, the change of torque on the motor's shaft and the change of motor's current as a function of time are determined, these two being the main outputs of the Motor drive block.

II. METHODOLOGY
The torque on the motor shaft represents the main input of the Vehicle dynamics block, shown in Fig. 3. The vehicle wheels are not directly connected to the engine shaft, rather these two are connected through a transmission system. The transmission system aims to adjust the speed and torque on the engine shaft to their respective levels at the wheels, and it can be characterized by its transmission ratio and its efficiency. The interaction between the wheels and the road pavement is represented by the Magic formula model which allows determining the tractive force at the wheels. The tractive force represents the main input of the Vehicle body block modelling the longitudinal vehicle dynamics: where is the total mass of the vehicle including passengers, is the vehicle acceleration, is the external air density, is the frontal area of the vehicle, is the aerodynamic drag coefficient, is vehicle velocity, is the wind speed in the opposite direction of the vehicle movement, is the acceleration of the Earth's gravity, is the rolling resistance coefficient, and is the road slope. Knowing the parameters in the previous equation, the vehicle velocity resulting from the acceleration and braking commands is determined. The measured vehicle speed is used through a negative feedback loop to form the deviation signal of the PI speed-tracking controller contained in the Longitudinal driver block.
The change in motor current in time is used to determine the change in the state of charge of the battery (SoC) using the where is the battery idle voltage, is the maximum battery capacity, is the exponential voltage, is the exponential battery capacity, is the polarization constant, is the battery current, * is the low frequency dynamic current, and is the extracted battery capacity. The charge and discharge equations allow determining the change in the state of charge of the battery in time, and in addition, the Battery block also allows determining the change in the output voltage of the battery in time.
In the next sections, the details of the developed model are presented and the results of simulations on one of the test drive cycles are presented. In addition, the influence of wind speed and road slope on the energy consumption of the vehicle is analyzed.

III. TEST RESULTS
The parameters of the developed model are customized according to Tesla Model S. The maximum output power of the motor is set to 280 kW with a maximum torque of 420 Nm. The motor is powered by a 100 kWh lithium-ion battery pack with a nominal range of 360 kilometers. The wheels and the motor are connected through a transmission system with a fixed gear ratio of 9.734:1. The weight of the vehicle without passengers is equal to 2,200 kg. Fig. 4 demonstrates the operation of the implemented Simulink model following a standard FTP75 urban driving cycle. As can be seen, the simulation yields the change of battery's voltage, current, and state of charge over time. The trip starts with a fully charged battery and ends with a state of charge of 95% after traveling about 18 kilometers. The average consumption per kilometer is somewhat higher than the specified 18.1 kWh/100 km for the Tesla Model S, which is expected due to frequent starts  The results presented in Fig. 4 assume no wind and zero slopes along the route which is a bold assumption for realistic routes. As described in the previous section, the proposed model allows taking into account the change in the wind speed and the road slope along the route. Neglecting the effect of wind on energy consumption can lead to an underestimate of the energy consumption on the route. Increasing the wind speed in the driving direction increases the aerodynamic drag force which can substantially increase energy consumption. As can be seen from Fig. 5, the same driving cycle under different wind speeds leads to different energy consumptions along the route, proving that wind can severely affect the energy consumption of electric vehicles. The same applies to the road grade which can severely affect consumption.
In practice, both the wind speed and the road grade change along the route. One such example is demonstrated in Fig. 6. The change of wind speed and the road grade along the route is generated randomly, and in comparison with the simplified scenario which neglects the effects of wind speed and road grade, the energy consumption increases by almost 5%. Considering the analyzed route is only 18 kilometers long, neglecting the effect of wind speed and road grade could lead to an overestimation of the vehicle's range.
In the end, the proposed method needs to be tested using a OSM is a collaborative project to create a geographic map of the world freely editable by volunteers. The coverage of OSM is constantly increasing, and it is expected that soon OSM will become a quality open-source alternative to Google Maps. OSM can provide road characteristics including type of the road and the speed limit along the route specified by its origin and destination. On the other hand, SRTM represents an international project coordinated by the US National Geospatial-Intelligence Agency (NGA) and the US National Aeronautics and Space Administration (NASA). The objective of SRTM is to obtain elevation data on a near-global scale. Currently, the elevation data is available on a horizontal resolution of 30 meters which makes it ideal for routing applications. SRTM can be easily applied to determine the road grade along the whole route. OSM and SRTM are used as data sources for GraphHopper, a user-friendly open-source routing library [13]. Using GraphHopper, data has been obtained for a route with the origin at Nikšić (42.78, 18.95) and the destination at Podgorica (42.45, 19.25). The route itself and the elevation profile along the route are shown in Fig. 7. GraphHopper returns a segmented route with the characteristics of each segment. The driving cycle returned by GraphHopper is discontinuous, so some preprocessing needs to be done before using it as an input to the model. Furthermore, the driving cycle is based entirely on the speed limits along the route. Therefore, to simulate traffic and speed deviations from the speed limit, Gaussian noise is added to the driving cycle. The driving cycle and the energy consumption along the route are shown in Fig. 8. The travel time of about an hour is typical for the analyzed route and the energy consumption is proportional to the energy consumption obtained in the first analyzed scenario. The computation time of the model for the given route varies between 5 and 10 seconds over 50 runs, which makes it suitable to estimate the energy consumption before a trip.

IV. DISCUSSION
Following the results presented in the previous section, it can be seen that the developed model represents a simple and efficient solution for the energy consumption prediction of electric vehicles. Furthermore, the proposed model allows incorporating the effects of road characteristics and climate conditions on energy consumption. However, the proposed model relies on certain assumptions. The main disadvantage of the proposed model is that it neglects the efficiency of regenerative braking. In practice, energy recovered by regenerative braking depends on the vehicle velocity. At lower speeds, only mechanical brakes are used, and as the vehicle's speed increases, the efficiency of regenerative braking increases. At high speeds, the energy recovered by regenerative braking is constrained by the motor's rated power. In contrast, the proposed model assumes that 100% of the braking energy is being recovered. Apart from that, the proposed model neglects the auxiliary consumption in the vehicle, though this can be easily incorporated by superposition of the auxiliary load current to the motor current.
Regardless of the mentioned drawbacks, the proposed model represents a computationally efficient and reliable solution for a rough energy consumption estimate on a predefined driving cycle.

V. CONCLUSION
This paper presented a MATLAB/Simulink model for the energy consumption prediction of electric vehicles. The developed model is a physical model incorporating the mechanical and electrical components of the vehicle. The input of the model represents the driving cycle describing the change in the vehicle's velocity over time. The driving cycle is used as a referent signal for the speed-tracking controller which generates acceleration and braking commands, thus controlling the motor of the vehicle. Simulating the model yields the change of battery's voltage, current, and state of charge, as well as the vehicle speed and distance over time. Apart from the driving cycle, the developed model allows the specification of the road grade and the wind speed for the analyzed trip, thus enabling its use for realistic routes. The parameters of the model were personalized according to the available data on Tesla Model S. The performance of the model was evaluated on a standard FTP75 urban driving cycle and on a test driving cycle obtained for a realistic route. Furthermore, the effects of wind speed and the road grade on the energy consumption of electric vehicles were analyzed. It was concluded that neglecting the effects of wind and road grade can lead to serious underestimation of the energy consumption of electric vehicles on a particular route.
Further work will include the extension of the developed model to account for vehicle and route-related constraints. Furthermore, the proposed method will be compared with the existing methods for energy consumption prediction in order to evaluate its accuracy and computation efficiency.