Longitudinal Dynamics Simulation Tool for Hybrid APU and Full Electric Vehicle

Due to problems related to environmental pollution and fossil fuels consumption that have not infinite availability, the automotive sector is increasingly moving towards electric powertrains. The most limiting aspect of this category of vehicles is certainly the battery pack, regarding the difficulty in obtaining high range with good performance and low weights. The aim of this work is to provide a simulation tool, which allows for the analysis of the performance of different types of electric and hybrid powertrains, concerning both mechanical and electrical aspects. Through this model it is possible to test different vehicle configurations before prototype realization or to investigate the impact that subsystems’ modifications may have on a vehicle under development. This will allow to speed-up the model-based design process typical for fully electric and hybrid vehicles. The model aims to be at the same time complete but simple enough to lower the simulation time and computational burden so that it can be used in real-time applications, such as driving simulators. All this reduces the time and costs of vehicle design. Validation is also provided, based on a real vehicle and comparison with another consolidated simulation tool. Maximum error on mechanical quantities is proved to be within 5% while on electrical quantities it is always lower than 10%.


Introduction
Nowadays, the automotive sector is facing the challenge of improving its environmental sustainability. Because of that, car manufacturers are trying to increase the market share of electric and hybrid vehicles [1]. As a matter of fact, due to the stringent emission laws from governments from all over the world, diesel vehicles are being replaced by hybrid vehicles [1]. In this regard, it is interesting to mention the law of 16 January 2019 (formal adoption on 3 April 2019) [2,3], as the European Parliament voted for the further reduction of carbon dioxide (CO 2 ) emissions for the newly registered vehicles. In particular, cars and light commercial vehicles (vans) registered from 2025 will have to emit 15% less CO 2 and by 2030 cars will have to emit 37.5% less CO 2 , while light commercial vehicles will have to emit 31% less.
Furthermore, the problem of traditional vehicles is not only linked to environmental problems (global warming associated with the emission of large quantities of CO 2 and pollution linked to the emission of pollutants such as unburnt substances and nitrogen oxides (NOx) contained in the exhaust gases of thermal engines), but it is also associated with the noninfinite availability of fossil fuels [4]. For all the above reasons, the automotive market is pushing more and more electrified, hybrid or fully electric vehicles.
However, the spread of these alternative powertrains (especially full electric) is being slowed down by their range as it is still not comparable to a traditional liquid fuel-powered vehicle. In fact, despite the considerable step forward in battery technology, energy density

•
In Section 2 the general layout of this tool will be presented as well as the mathematical background. In particular, details of each submodel will be given.

•
In Section 3 a graphical user interface will be presented. This interface is useful for using the program and for setting all the necessary inputs.

•
In Section 4 the validation process will be described. The validation was carried out both through the comparison with the results of another consolidated simulation tool, and through the comparison with real-world experimental data. • In Section 5 conclusion remarks are given. The utility and the featured application of this simulation tool will be highlighted as well. • Finally, Appendix A includes the nomenclature with all symbols and abbreviations used in this paper.

Simulation Tool
The model allows for the simulation of both the mechanical part (forces, torques, speeds, accelerations, etc.) and the electric part (electric powers, electric resistances, battery parameters) of a full electric vehicle or APU hybrid vehicle.
To lighten the model, it was chosen not to use the Simulink library blocks relating to the powertrain, apart from possibly the battery block ("Datasheet Battery"). The program works in fixed steps and the operating logic ensures that the model lends itself to discrete operation, obviously with the appropriate precautions, for example, by replacing the Simulink blocks of the derivatives and integrals with similar calculations obtained using only blocks that allow for discreet operation.
In this regard, following the same logic, the "Datasheet Battery" block has been reworked, to obtain one that works discreetly but following the same logic. The following paragraphs explain the operating logic of the entire program. Furthermore, Figure 1 shows a schematic illustration of the operation of the program.

Power Longitudinal Dynamics Modelling: From Target Speed to Request
Different speed profiles (different Laps) can be supplied as inputs to the model, once the profile to be followed is chosen, it is possible to filter it by defining a constant k. The model considers as the input speed profile the moving average of k values of the chosen speed profile. If you do not want to filter the profile, then simply set k equal to 1.
The reference acceleration a re f is obtained from the filtered speed profile using the following equation: where v re f is the target speed of the filtered speed profile, corresponding to the instant of calculation considered, v prev is the actual vehicle speed of the instant of calculation preceding that considered and t s is the sample time of the simulation.
Simulink blocks of the derivatives and integrals with similar calculations obtained using only blocks that allow for discreet operation. In this regard, following the same logic, the "Datasheet Battery" block has been reworked, to obtain one that works discreetly but following the same logic. The following paragraphs explain the operating logic of the entire program. Furthermore, Figure 1 shows a schematic illustration of the operation of the program.

Power Longitudinal Dynamics Modelling: from Target Speed to Request
Different speed profiles (different Laps) can be supplied as inputs to the model, once the profile to be followed is chosen, it is possible to filter it by defining a constant . The model considers as the input speed profile the moving average of values of the chosen speed profile. If you do not want to filter the profile, then simply set equal to 1.
The reference acceleration is obtained from the filtered speed profile using the following equation: where is the target speed of the filtered speed profile, corresponding to the instant of calculation considered, is the actual vehicle speed of the instant of calculation preceding that considered and is the sample time of the simulation.  Considering the wheel radius and the reduction ratios, the model calculates the angular speeds of the wheels and the rotation speed of the electric motors, not taking into account any slippages, as in Equations (2)- (5).
Energies 2021, 14, 1207 5 of 35 ω motor_re f _R = ω wheel_re f _R ·τ di f f _R ·τ Gb_R (5) where ω wheel_re f _F and ω wheel_re f _R are the angular speeds of the wheels, front and rear respectively, if the vehicle faithfully follows the imposed speed profile (and without slippages), while R wheel_F is the rolling radius of the front wheels and R wheel_R that of the rear wheels. ω motor_re f _F is the rotation speed of the motor that acts on the front axle and is calculated only in the presence of this motor, otherwise it is set equal to zero, the same is true for ω motor_re f _R which is the rotation speed of the motor that acts on the rear axle. τ di f f _F and τ di f f _R are respectively the overall reduction ratios of the differential and transmission on the wheel side (with respect to the gearbox) of the front and rear drive chain, while τ Gb_F and τ Gb_R are the reduction ratios of the reduction/gearbox front and rear. In addition to the speed target, it is also possible to impose, for each Lap, a temperature profile of the battery pack, linked to the speed profile, obtained for example experimentally, by detecting the temperature of the pack on a real vehicle that travels the imposed speed profile. The space travelled by the vehicle is obtained by integrating the speed of the profile, if the vehicle faithfully follows the imposed cycle. The model, through the space travelled and using a one-dimensional Lookup Table, detects the altitude of the road at the point considered on the track. The slope of the road surface is obtained from the distance on the track and from the elevation profile, the slope is expressed as an angle in degrees (θ), as follows: where dz is the difference between the altitude of the road at the point considered and the altitude of the point of the instant of calculation preceding that considered, while dx is the difference in distance traveled, between the current instant and the previous calculation instant, with the imposed speed profile. In addition, if the vehicle is stationary, θ is imposed equal to that of the previous calculation instant. The calculation of the resistant forces (additional resistant or traction force due to the slope, rolling resistance force and aerodynamic resistance) is essential for the functioning of the model. The additional force given by the presence of the slope of the ground F θ , positive if it acts as a resistant force, negative if it is in favour of acceleration, agrees with the speed vector and acts as a traction force) is considered through the following relationship: m vehicle is the unladen mass of the vehicle, m driver is the driver's mass (plus the mass of any passengers), m f uel is the mass of the fuel (considered constant during the simulation, in this first version of the model), necessary for powering the any generators. The rolling resistance F r is considered constant with respect to the speed and calculated using Equation (8) as reported in [19] for nonzero speeds (and set zero for zero speed).
where f r is the static rolling resistance coefficient. The equation used to calculate the aerodynamic resistance F aero is: where ρ is the air density, A f is the frontal area of the vehicle and C x is the longitudinal aerodynamic coefficient, considered constant. Therefore, in this first version of this model, no aerodynamic map has been considered yet, which would still be easy to implement. In the "Reference Motor Torque" block, the motor torques required to follow the target speed profile are calculated. There is in output from this block also the traction force required by the wheels (including the contribution given by the inertia of the wheels themselves), necessary in different blocks to distinguish the cases in which a positive traction force is required (to accelerate or to partially overcome the resisting forces and decelerate less intensely compared to the absence of traction force) from cases in which a negative one is required (to have greater deceleration than that given only by the resisting forces).
Moreover, a balance of forces acting on the vehicle (in the centre of gravity) is carried out in order to identify the traction force F tr necessary for the vehicle to travel with acceleration equal to that of reference, as in the following equation: Adding the inertia contributions to the traction force, the total traction force at wheels F re f _wheels must be recalculated. The inertia contributions, respectively of the front (11) and rear (12) wheels, are obtained through the following equations: where the "2" coefficient is used to consider both wheels of the axle. I wheel_F and I wheel_R are the front and rear wheel inertia, respectively. The total traction force, including contributions due to the inertia of the wheels, is multiplied by TractRatio acc if the electric motors are used for traction or by TractRatio brak if the motors are used as generators to recharge the batteries during braking, to obtain the portion of traction force F tr_F which must be guaranteed by the front motor. TractRatio acc is the distribution of torque between the two electric motors (towards the front) in the case of the accelerator pedal pressed, TractRatio brak is the distribution in the event that the brake pedal is pressed. Using these distribution values to divide the traction force between the two axles, an approximation is therefore being made. Obviously, if only the front electric motor is present on the vehicle, both distributions will have to be set equal to 1, vice versa, if the vehicle has only rear motor, both distributions will be null. Finally, the motor torques required at the front T re f _F and at the rear T re f _R are calculated, using relationships (13) and (14), only if the motor is present, considering the contributions of input and output inertia to the gearbox, the motors inertia and a general transmission efficiency for transmission on each of the two axles.
where X is equal to 1 in the case of motors that produce traction force and −1 in the case of motors that act as generators; J out_F and J out_R are the inertia coefficients of the moving mechanical parts in output respectively to the reducer/gearbox of the front and rear motor; J in_F and J in_R are the inertia coefficients of the moving mechanical parts in input respectively to the reducer/gearbox of the front and rear motor; J motor_F is the inertia coefficient of the front electric motor, while J motor_R of the rear one; η trans_F and η trans_R are the general efficiencies of the entire transmission, front and rear respectively. Once the torques that the electric motors must supply or absorb in the case of braking (and in the absence of traditional brakes) have been obtained, it is necessary to compare them with the maximum available torques of the two motors to check whether the target Energies 2021, 14, 1207 7 of 35 mission can be met or not. The calculation of the maximum torque available for each motor (front or rear) is obviously carried out only if the motor in question is present on the vehicle, otherwise the maximum torque value is set at zero. To obtain the maximum torque of the motors, the angular speeds (in RPM) of the previous instant are considered. This is done as an approximation since the rotation speed of the motors at the instant considered is not yet known, the vehicle may in fact, due to limitations of the motors or batteries, fail to follow the target speed profile.
In the Simulink model the maximum motor torques are obtained thanks to the Lookup Tables containing information regarding the torque curves of the motors in the condition of maximum admission. The reference torque T re f _F and the maximum available torque at the front are compared and the torque T req_F which will in turn be compared with the limits imposed by the battery pack is the lowest in modulus between the first two. The same approach can be adopted for the rear motor, for the calculation of T req_R . Alternatively, for one or both motors, it is possible to define a maximum torque for regenerative braking, which has a trend that grows linearly as a function of the time elapsed since the start of the braking and which then reaches a predefined maximum value (in module). This is what was done in the model, in the "Motor Torque Required" block.
Starting from the latter regenerative braking configuration, it is possible to return to the first described, simply by setting an absolute maximum braking torque equal to or greater than the maximum motor torque and an infinite angular coefficient for the equation of the straight line that binds time elapsed since start of braking and maximum regeneration torque at the instant considered. For the instant considered, it can now be considered that the rotation speed of the front and rear motor respectively, ω motor_req_F and ω motor_req_R , is equal to the reference rotation speed of the relative motor (closely related to the target speed profile) if there is no limitation given by the maximum performance of the motor in question. While, if the motor is unable to guarantee the torque required by the target, its rotation speed is approximated to that of the previous instant.
In the "Motor Torque Required" block, binary values (1 or 0) are also obtained as output depending on whether or not there are torque limitations due to the maximum performance of the motors, in the pressed accelerator condition (Limit mot_acc ) and in the braking condition (Limit mot_brak ). The question is whether this limitation, respectively in the accelerator or brake pedal pressed phase, that is present on only one motor, is enough to trigger the variable Limit mot_acc or Limit mot_brak the unit value.

Power Electronics and BMS Modelling
Once the requests of the mechanical part have been defined, it is necessary to consider the electrical part to take into account any limitations given by the batteries and for the calculation of the power, current, voltage and SOC (State of Charge) parameters of the battery pack.

Battery Limitations
To know the power that the electric motors must request from the batteries (or the power that thanks to the motors recharge the batteries) it is necessary to know the powers lost due to the Joule effect due to the resistances of the electric cables that connect the motors and batteries themselves. Obviously, the connection cables are present only in the presence of the relative motor; therefore, in the absence of the latter the related resistance is considered null. The connection cables' resistances between batteries and front R cable_F and rear R cable_R motor are calculated as follows: where ρ Cu is the resistivity of copper (or any other material the electrical cables under consideration can be made), L cable_F and L cable_R are the total lengths of the connection cables of the front and rear motor respectively, π 4 (Φ cable_F ) 2 and π 4 (Φ cable_R ) 2 are the crosssectional areas of the front and rear cables while Φ cable_F is the diameter of the front cables and Φ cable_R is the diameter of the rear cables.
Within the "Power Required" block, the total power required of the batteries by the electric motors (or that the motors could guarantee as input to the batteries) is calculated, instant by instant. This power is the result of an approximation as no voltage drop is considered as regards the resistance of cables and electric motors. In particular, the total power required P tot_req is equal to the sum of the power required by the front motor P req_F and that required by the rear motor P req_R . The calculation of the latter two quantities is represented in Equations (17) and (18).
where Y and Z are worth 1 if the motors require energy from the batteries, -1 if the motors act as generators by sending energy to the battery pack. V is the voltage of the battery pack and is calculated in the Simulink "Battery Pack" block of the model, η mot_re f _F and η mot_re f _R are the electrical efficiencies of the front and rear motor and they are obtained through a special block, which is present inside the "Power Required" block. The electrical efficiencies of the motors are calculated by the model only if the considered motor is present, otherwise the relative efficiency is set to zero. In particular, the efficiency of each motor is obtained thanks to a two-dimensional Lookup Table that receives in input the motor torque and motor speed and returns the efficiency.
To calculate the overall power input or output from the battery pack, it is also necessary to know the power supplied by the generators (if they are present). In this first version of the model, the possibility of integrating the vehicle with a number of generators N gen that is zero or greater than zero was considered, where all the generators installed on the vehicle are identical and all have the same operation instant by instant.
Furthermore, no resistance of the connection cables between generators and batteries was considered, considered negligible. In particular, the generators have a constant rotation speed and a constant rated power output over time, unless the need to cut power due to the limitations imposed by the maximum performance of the battery pack.
In the "Generators" subassembly, the electrical efficiency of the single generator is obtained starting from the nominal power (P gen_nom , positive) of the single generator and its rotation speed ω gen , through a two-dimensional Lookup Table. Multiplying the efficiency by the rated power and by the number of generators gives the total maximum power value (P gen_th , positive) that the generators can supply as input to the battery pack.
For the comparison of the balance of the power required, entering or leaving the battery pack, with the limitations of the pack itself, it is also necessary to consider the contribution of the power lost inside the cells due to their electrical resistance. First of all, the model, starting from the total power entering or leaving the battery pack and the voltage of the pack, calculates the theoretically required current I req if there are no limitations given by the batteries, as in Equation (19).
where P acc is the total power consumed by the vehicle accessories, considered constant. A Lookup Table, which receives the temperature of the battery pack and the SOC at the input, returns the resistance R of the single cell to the output. Finally, the calculation of the total power P battI2R of all cells, dissipated by Joule effect in the entire battery pack is: (20) where N s corresponds to the number of cells arranged in series inside the battery pack, while N p the number of those arranged in parallel. The power dissipated by the Joule effect thus obtained is relative to the case in the absence of limitations given by the maximum performance of the battery pack, but will be used, as an approximation, even in the cases in the presence of such limitations. In this way, in limited condition, an approximation of the power lost due to the internal resistance of the cells is made for excess. In the "Battery Limitations" block, the discharging and charging limitations of the batteries are considered. These limitations can be expressed as powers or as currents.
In particular, these limits are defined in function of the SOC of the pack and they are obtained in a dedicated subassembly which will be described later. The power balance shown below, in Equations (21) and (22), allows one to distinguish the case of discharge from that of recharging the batteries.
Discharge of the battery pack: Charge of the battery pack: Depending on whether the power balance mentioned above is positive (or null) or negative, one passes to considering an "if" subassembly or another in the Simulink model. In the case that the previous power balance is positive or null, the desired variables are the output from the "if" subassembly "Battery Discharge". In this case, the generators can work by supplying the entire rated power as output, without the need for limitations.
In this block there are in turn two further "if" checks that divide the case in which there is no limitation imposed by the battery pack from that in which the power absorbed by the electric motors must be limited. The available power P available , which can be taken from the battery pack, is calculated as: P available = V·I dischrg_limit − P bu f f er − P battI2R + P gen (23) which is valid in the event that the discharge limit of the battery pack is supplied as a limit current (positive, I dischrg_limit ), if it is expressed as a power (positive, P dischrg_limit ) the previous relationship must be reconstructed as follows: where P bu f f er is simply a constant power that is used to keep within the discharge and charge limits with a defined tolerance, equal to the value of this constant and P gen is the "real" power supplied to the batteries by the generators, which in case of discharge is equal to the maximum power P gen_th , without the need for any limitation. The power to be taken from the battery pack consists of the sum of the power absorbed by the vehicle accessories (P acc , considered constant) and the total power required by the electric motors P tot_req . By subtracting the contribution of these two powers from the maximum available, it is therefore possible to ascertain whether this is actually available and therefore no limitation is necessary or vice versa (i.e., if the result of this subtraction is positive or negative). In the event that there are no limitations given by the battery pack being discharged, the required quantities will actually be the "real" ones of the vehicle, at the instant considered (remembering that the limitations of maximum drive torque have already been considered), and they will be taken as output from the first "if" block.
A binary control variable is also defined, Limit batt_acc , defined in this case equal to 0, defined instead equal to 1 in the condition of limitation of the motors during traction due to the maximum performance of the batteries. The calculations are carried out in the second "if" block if it is necessary to impose limitations during the discharge phase. In the case with limitation in the discharge phase, if the available power is not enough even to power the accessories, obviously the electric motors will be turned off and it is necessary to define the P acc variable to keep track of the amount of power missing for the power supply of the accessories. P acc is defined equal to the difference between available power and power that should be absorbed by the accessories. On the other hand, if after the part of available power supplied to the accessories is considered, a part of power remains available; the latter will be used to power the electric motors.
In the presence of both motors, this power will be divided between front P batt_F and rear P batt_R through the distribution constant TractRatio acc . Below are the calculations of the front drive torque T mot_F , in Equation (25), and rear T mot_R , in Equation (27).
For the calculation of both motors torques, it is taken into account the resistance of the cables (but the relative voltage drop is neglected), the electrical efficiency of the motors (η mot_F and η mot_R , obtained by means of the Lookup Table, starting from the efficiency map of the motors) and the equality of the instantaneous rotation speed of the motor (ω motor_F and ω motor_R ) is set as an approximation to the rotation speed relative to the previous instant of calculation (ω motor_prev_F and ω motor_prev_R ) as show in the Equations (26) and (28).
The foregoing is valid in the event that the electric motors must absorb power from the battery pack, but it could fall into the limit case in which the motors act as generators (P tot_req < 0), but the power absorbed by the accessories is still sufficient to ensure that the batteries are being discharged. In this case, no limitation is required for the motors torque and the ∆P acc will be calculated as follows (29).
The Limit batt_acc control variable is defined for both motors and the output variable to the "if" block will be equal to 1 if that relating to at least one motor is unitary (i.e., if at least one of the motors is limited by the maximum performance of the battery pack), equal to zero vice versa. If a motor (front or rear) is not present on the vehicle in question, all the relevant quantities are defined as null, including the Limit batt_acc variable. In case that the battery pack is in a recharging condition, the desired variables are output from the "Battery Charge" "if" subassembly, contained in the "Battery Limitations" block. In the "Battery Charge" block there are in turn two further "if" blocks that divide the case in which there is no limitation imposed by the battery pack from that in which it is necessary to implement limitations. The maximum power that the battery pack can absorb P absorbable is calculated using the following equation: Equation (30) is valid if the discharge limit of the battery pack is supplied as a limit current (negative, I chrg_limit ), if it is expressed as a power (always negative, P chrg_limit ) the previous relationship must be reconstructed as follows: It is therefore possible to understand if it is necessary to make limitations or not, considering the power contributions of generators and electric motors. The outputs are obtained from the "if" subassembly relating to the absence of limitations if the inequality (32) is valid, from the "if" subassembly relating to the presence of limitations vice versa.
When no limitation is required during the battery discharge, the system variables are considered equal to those resulting from the comparison with the maximum performance of the electric motors. Limit batt_brak binary control variable is also defined, null in the absence of limitations of the electric motors when braking (and also even if the motors participate in traction), set equal to 1 in the case of motor limitation during regenerative braking, due to battery limitations. Limit gen is instead a binary quantity useful for checking that the generators have been limited (when it is equal to 1) or less (equal to zero).
The "if" subassembly relating to the presence of current limitations is in turn divided into two "if" subassembly, "Without Motor Power Restrictions" and "With Regenerative Braking Restriction". The model recovers the variables of interest from the first "if" block if the maximum P absorbable that the battery can absorb (negative) is less than or equal to the required power P tot_req (input or output to the battery pack) from the motors, vice versa from the second "if" subassembly. The logic adopted is to limit the generators first, so as to be able to guarantee the regenerative braking of the motors within the limits (so as to be able to exploit the traditional brakes of the vehicle to a minimum) and only in case of need for further limitation also limit the electric motors. If it is sufficient to implement the limitation to the generators only, the only new quantity to be calculated is precisely the "real" power that the generators supply to the battery input P gen , equal to the difference between the total power of the motors P tot_req and the maximum absorbable power battery P absorbable . The difference has been structured in this way to ensure that the power of the generators is positive. If it is also necessary to limit the power of the electric motors, the generators will be turned off and all the power supplied as input to the battery will be guaranteed by the electric motors P mot_tot = P absorbable . In this case, the control variables will assume the following binary values, represented in Equations (33) and (34).
The total power supplied by the motors P mot_tot is divided between the front P batt_F and the rear P batt_R by means of the distribution constant TractRatio brak . The new quantities of the system are obtained by means of the Equations from (35) to (38).
Again, the motors' efficiencies are obtained by means of Lookup Tables and the voltage drops caused by the resistances of the electric cables are neglected. Furthermore, the rotation speed of the motors is approximated to that of the previous calculation instant. This part of the Simulink model, which includes the limitations of the battery pack, represents part modelling of the BMS. The logic of the BMS is strongly linked to the type of battery and the strategies adopted by the vehicle manufacturer. For this reason, these logics can vary greatly depending on the type of vehicle and its mission.

Battery Parameters
Once the requests for electric motors and generators have been defined, after applying the necessary limitations, it is necessary to know the input or output current to the battery pack. The calculation of the current is very simple, and it is represented by the equation number (39).
where the total battery power deriving from the electric motors P mot_tot is the sum of the front contribution P batt_F and rear contribution P batt_R . Considering the current passing through the battery pack, relative to the previous calculation instant with respect to the one considered, it is possible to obtain all the battery values of interest, including the voltage of the pack, used for the calculations inside the blocks previously exposed.
In the model, the thermal balances are not taken into account, the temperature can therefore be assumed constant or supplied as input starting from experimental values measured according to the target speed profile.
Furthermore, by multiplying the current and voltage between them, it is possible to obtain the incoming (negative) or outgoing (positive) power from the battery pack, starting from the current of the previous calculation instant (I prev = BattCrnt_prev) and the instantaneous temperature of the battery pack, it is possible, through the "Datasheet Battery" (Figure 2) block of the Simulink library, to obtain battery state of charge BattSoc and voltage (V = BattVolt) of the pack. The battery block of the Simulink library is an internal resistance battery model [10] and it is easily replicable for its discreet use if there is the need to perform this type of simulation. Finally, to conclude the discussion concerning the electrical part of the model, the origin of the discharge and charge limits of the battery pack, obtained starting from the state of charge of the battery pack, is described. Both limits are obtained using Lookup Tables which contain information about the link between SOC and limit in discharge and the link between SOC and limit in charge. Tables which contain information about the link between SOC and limit in discharge and the link between SOC and limit in charge.

Power Longitudinal Dynamics Modelling: From Motor Torque to Vehicle Speed
Once the limitations given by the electrical part have also been considered, it is necessary to define how the vehicle responds to the set speed target, faithfully following it or departing from it due to the limitations.
In the "Vehicle Acceleration" block, a balance of forces (see Equation (40)) is carried out again, as in the case of the "Reference Motor Torque" block, but this time to find the "real" acceleration (a) of the vehicle, starting from the limited motors torques (if necessary).
Thanks to the motor torque and the rotation speed of each of the electric motors, it is possible to obtain the front F tr_F and rear F tr_R traction force provided by the motors (positive if it is really a traction force, negative in the case of regenerative braking).
If there is an electric motor that acts on the front axle, the related traction force is calculated as in (41), while it is imposed null in the absence of this motor. It is the same with regards to the electric motor that acts on the rear axle (42).
The contributions given by the inertia of the front F wheels_inertia_F and rear F wheels_inertia_R wheels are calculated as follows using Equations from (43) to (46).
If the front electric motor is present: If the front electric motor is absent: If the rear electric motor is present: If a rear electric motor is not included: The F brake braking force of traditional brakes must be that necessary to integrate regenerative braking, if necessary, to allow the vehicle to follow the speed target when braking, unless there is any limitation given by the maximum permissible braking of the braking system. In the "Traditional Brakes" block, located inside the "Vehicle Acceleration" assembly, the balance of forces reported in (47) is carried out to obtain the braking force required (F brake_req , defined positive) from the brake system.
This force must be compared with the maximum force that can be generated by the braking system (F brake_max , defined positive). The effective F brake will be equal to the smaller of the two. The following equation shows the calculation of F brake_max : where p brake_max is the maximum pressure that can be generated inside the master cylinder of the brake system; Bias brake_F represents the pressure portion, compared to that of the master cylinder, which acts on the front brakes; A piston_F and A piston_R are the total action areas of the brake pistons of the front and rear callipers respectively; µ pad_F and µ pad_R are the dynamic coefficients of friction between brake pads and brake callipers, front and rear; R m_disc_F and R m_disc_R are respectively the average radii of application of the braking force on the front and rear discs. In the "Traditional Brakes" block a further control parameter called Limit trad_brak is defined, which is set to 1 if there is a limitation of traditional braking or equal to 0 instead. The aerodynamic drag force F d is equal to F aero calculated previously on the basis of the target speed if in the instant considered there are no limitations to the motors caused by the maximum performance of the motors themselves or by the maximum performance of the battery pack and if there is no limitation of the traditional brakes. Otherwise, F d is calculated using, as an approximation, the vehicle speed of the instant of calculation preceding the one considered. To avoid incurring approximation errors during the calculations, the "real" vehicle acceleration output from block "Vehicle Acceleration" is that calculated using Equation (40) if there are limitations that lead to the failure to follow the target speed, otherwise a is defined equal to a re f . A further block relating to the mechanical part with limitations is the one called "Vehicle Speed", which outputs the "real" vehicle speed. The logical scheme adopted to obtain the "real" speed followed instant by instant by the vehicle is shown in Figure 3. As can be seen, appropriate measures have been taken to prevent the propagation of the approximation errors, inevitable during the calculations and due to different approximations adopted in the model. The sign of the F re f _wheels variable is used to distinguish the case of the accelerator pedal pressed from the case of the brake pedal pressed.
For the calculation of the speed (v), where necessary, a uniformly accelerated motion between one instant of calculation of the simulation and the next was considered, see Equation (49).
Finally, from the speed it is also possible to obtain the space travelled by the vehicle (x) during the execution of the actual driving cycle, once again considering motion uniformly accelerated between two successive calculation step, as in the following equation: where x prev is the space covered by the vehicle from the start of the simulation until the calculation step preceding the one considered.
"Vehicle Speed", which outputs the "real" vehicle speed. The logical scheme adopted to obtain the "real" speed followed instant by instant by the vehicle is shown in Figure 3. As can be seen, appropriate measures have been taken to prevent the propagation of the approximation errors, inevitable during the calculations and due to different approximations adopted in the model. The sign of the _ variable is used to distinguish the case of the accelerator pedal pressed from the case of the brake pedal pressed.
Finally, from the speed it is also possible to obtain the space travelled by the vehicle ( ) during the execution of the actual driving cycle, once again considering motion uniformly accelerated between two successive calculation step, as in the following equation: where is the space covered by the vehicle from the start of the simulation until the calculation step preceding the one considered.

Outputs
Once the simulation is completed, all variables will be saved in MATLAB workspace. Therefore, the outputs are completely "customizable by the user" based on the variables Figure 3. Simulink logical scheme adopted to obtain the instantaneous vehicle speed.

Outputs
Once the simulation is completed, all variables will be saved in MATLAB workspace. Therefore, the outputs are completely "customizable by the user" based on the variables he wants to analyse. In Section 4, an example layout will be shown for the outputs with the most relevant quantities.

Graphic User Interface
For easier and simpler management of the Simulink model, a graphic user interface has been created, using the "App Designer" tool of MATLAB, which allows for the control and modification of all the inputs of the model and starts the simulation. In particular, it is possible to save, for a specific vehicle, six different simulations (from Lap 0 to Lap 5), relating to six different speed profiles, each filtered through the average of k elements (with k that can differ between a Lap and the other), with relative altimetric profiles, with fixed sample time of simulation and initial state of charge of the battery pack ( Figure 4a).
Furthermore, it is possible to define all the environmental parameters and other parameters such as the driver's weight and the weight of fuel on board, necessary to power any generators (Figure 4b). It is then possible to define as input all the parameters relating to the vehicle in general, the wheels and the braking system (Figure 4c,d). The APP also allows you to set all the parameters relating to the batteries, with the option of choosing to enter information regarding the charging and discharging limitations in Ampere or Watt, and the two electric motors, front and rear (Figure 4e,f). For each motor it is possible to define both the continuous and peak torque curve and choose which one to use during the simulation, as can be seen from Figure 4f. Therefore, there is still no implementation in the model of an automatic management of the peak torque for the maximum allowed time and then an automatic transition to the maximum continuous torque. Finally, it is possible to modify all the input parameters concerning any generators in parallel installed on the vehicle (Figure 4g). Using the "START Simulation" button, simulation is started, and the graphic results are shown. The information regarding the simulation and some variables of the simulation itself are also automatically saved in the workspace, such as the electric motors torques, the voltage and current of the battery pack, etc. It is however possible to save any other quantity and display any other graph as long as they represent variables calculated in some branch of the Simulink model described in Section 2, entitled "Simulation Tool".

Model Validation
The validation of the model was carried out by comparing two borderline cases: a low-performance vehicle in terms of traction performance and a very high-performance hypercar. In the first case the validation was carried out through the comparison between model results and experimental data acquired through the VCU (Vehicle Control Unit) installed on a vehicle in the prototyping phase. In the second case the validation was carried out through the comparison between TEST and PROPS [8] results.
Furthermore, the driving missions of the two vehicles are also very different, in the first case an urban driving context is considered, in the second case the driving mission is of the Motorsport type, on the track.

Validation with Low Performance Vehicle
For the validation of the model under conditions of common driving cycles used in the public roads, the results of the model (obtained by setting the appropriate data concerning the specific vehicle) were compared with the data obtained experimentally from the VCU (Vehicle Control Unit) of a waste collection vehicle in the prototyping phase.

Powertrain
The prototype being simulated has a purely electric powertrain and it is a rear-wheel drive, with a single electric motor powered by a lithium battery pack. The configuration of this vehicle does not include any type of generator that recharges the battery pack, the only charging function in the simulation is the use of the electric motor as a generator during regenerative braking.
In particular, when the accelerator is released there is a regenerative torque which increases linearly with the time from the beginning of the release up to a maximum value, later this value remain constant until the accelerator pedal is pressed. In the same way, regenerative braking also intervenes with the brake pedal pressed.

Traction Motor
The electric motor is three-phase with an assembly mass of 57.2 kg and a rotational inertia of 0.086 kg·m 2 . It is characterized by the peak and continuous torque curves shown in Figure 5. In particular, the maximum peak torque is 380 Nm, while the maximum continuous torque is 304.3 Nm.

Battery Pack
The battery pack consists of 108 lithium cells arranged in series which give it a maximum nominal capacity of 120 Ah. Regarding the outgoing current (positive) and incoming current (negative), the battery pack has the limits shown in Figure 6, depending on the state of charge.

Battery Pack
The battery pack consists of 108 lithium cells arranged in series which give it a maximum nominal capacity of 120 Ah. Regarding the outgoing current (positive) and incoming current (negative), the battery pack has the limits shown in Figure 6, depending on the state of charge.

Battery Pack
The battery pack consists of 108 lithium cells arranged in series which give it a maximum nominal capacity of 120 Ah. Regarding the outgoing current (positive) and incoming current (negative), the battery pack has the limits shown in Figure 6, depending on the state of charge.  The open circuit voltage (OCV) and the internal resistance (RES) of the battery pack were considered constant, in fact the average temperature of the cells detected by the BMS is constant during the test and the SOC does not vary significantly. OCV and RES were derived from the experimental data and their values are represented in the Table 1, together with the other main data of the vehicle. EV2274A. A speed profile followed by the vehicle was used for the simulation and the corresponding motor torque and battery SOC, current, voltage and power were used for the comparison with the model results.

Target Speed Profile
The mission of the waste collection vehicle object of this model validation is a public road driving cycle. The target speed profile for validation was obtained thanks to road tests carried out with a vehicle prototype, acquiring all the data of interest from the VCU. Table 2 shows the main data of the target speed profile considered.   The mechanical part of the model works well, as can be seen in Figure 8, which shows the comparison between the motor torque obtained from the model and the experimental motor torque. The mechanical part of the model works well, as can be seen in Figure 8, which shows the comparison between the motor torque obtained from the model and the experimental motor torque.
The motor torque values obtained in output from the model are much noisier than the real torque values (acquired through the VCU). This is because the model does not consider transients; it calculates the quantities considering only the calculation instant in  The mechanical part of the model works well, as can be seen in Figure 8, which shows the comparison between the motor torque obtained from the model and the experimental motor torque. The motor torque values obtained in output from the model are much noisier than the real torque values (acquired through the VCU). This is because the model does not For the electrical part of the model, it was necessary to calibrate the power required at the battery terminals, inserting two efficiencies, one for the discharge case and one for the charging case. These efficiencies could represent the initially neglected power dissipations in the inverters and in the BMS. Figure 9 shows the comparison between the power obtained experimentally and the battery power resulting of the calibrated model while Figure 10 shows the comparison regarding current and voltage of the battery pack. For the electrical part of the model, it was necessary to calibrate the power required at the battery terminals, inserting two efficiencies, one for the discharge case and one for the charging case. These efficiencies could represent the initially neglected power dissipations in the inverters and in the BMS. Figure 9 shows the comparison between the power obtained experimentally and the battery power resulting of the calibrated model while Figure 10 shows the comparison regarding current and voltage of the battery pack.     The differences between battery current and voltage obtained through simulation and acquired by the BMS (real data) are partly due to the fact that the battery model ("Datasheet Battery") does not consider transients. For example, between 100 and 200 seconds elapsed from the start of the test there are about 20 seconds in which the vehicle is stationary, the current outgoing from the battery pack is constant and equal to about 2 Amperes and the battery voltage in output from the model is constant and equal to about 356 Volts. The current is not zero since, even when the vehicle is stationary, the auxiliaries must be powered. In real data it is possible to observe that the battery voltage does not remain constant in these 20 seconds but gradually increases. This is an effect due to the transient, in fact the Open Circuit Voltage (OCV) of a battery pack at rest tends to increase until it stabilizes at a maximum value.
Finally, the Figure 11 shows the comparison between the SOC obtained experimentally thanks to the BMS (Battery Management System) and the SOC resulting of the model. The SOC acquired through the VCU has a sensitivity of only 0.5% of variation, for this reason the SOC curve represented in the graph of the Figure 11 is piecewise linear, it was obtained by joining the points where the BMS has detected a change in SOC. To obtain the performance indices of the model (shown in Table 3), the error was obtained (calculated as the difference between the output parameter of the model and the parameter acquired through the VCU prototype) and its mean and standard deviation were calculated. The mean and the standard deviation (std) were also calculated for the absolute value (abs) of the error. The differences between the model results and the experimental data can be considered negligible; the model is thus validated.  Table 3), the error was obtained (calculated as the difference between the output parameter of the model and the parameter acquired through the VCU prototype) and its mean and standard deviation were calculated. The mean and the standard deviation (std) were also calculated for the absolute value (abs) of the error. The differences between the model results and the experimental data can be considered negligible; the model is thus validated.

Validation with High-Performance Hypercar
For the validation of the model with data and operation typical of a high-performance vehicle, the data of an ultra-high performance hypercar, which is in the design stage, were considered. The speed profile adopted was obtained through a best lap time test of the car in question on the Nürburgring circuit, implemented in VI-CarRealTime (VI-Grade). As already mentioned in Section 1, the results from the TEST model were compared with those coming from a different simulation tool (PROPS) as reported in [8] and the comparison allowed for the performance of a correct calibration of the program.

Powertrain
The simulated hypercar is an APU (Auxiliary Power Unit) hybrid car, equipped with two electric motors, one acting on the front axle and one acting on the rear axle. Electric motors are powered by a lithium battery pack and they provide (or absorb) the same power at all times. Two generators are also installed on the vehicle, represented by two turbines powered by a liquid fuel, in particular by petrol. These generators are used to recharge the battery pack at constant power, unless limited by the battery pack itself. The generators are therefore always active while driving, rotating at constant speed, and their power is cut where the maximum charging limits (depending on the SOC) of the battery pack require it.

Traction Motor
The two electric motors of the car are identical, and they present the torque curve in maximum admission condition represented in Figure 12. The maximum torque of the motors is equal to 530 Nm and the rotation speed is limited to 23,000 RPM.

Battery Pack
The battery pack configuration consists of 226 cells in series and 4 in parallel, for a total of 904 cells, with a maximum capacity of 6.55 Ah. The operating temperature of the cells must remain around 60 • C and the maximum charge and discharge limits must not be exceeded, limits that depend on the SOC and they are represented in the Figure 13, where the positive powers refer to the discharge and the negative ones to the charge of the battery pack.
generators are therefore always active while driving, rotating at constant speed, and their power is cut where the maximum charging limits (depending on the SOC) of the battery pack require it.

Traction Motor
The two electric motors of the car are identical, and they present the torque curve in maximum admission condition represented in Figure 12. The maximum torque of the motors is equal to 530 Nm and the rotation speed is limited to 23,000 RPM.

Battery Pack
The battery pack configuration consists of 226 cells in series and 4 in parallel, for a total of 904 cells, with a maximum capacity of 6.55 Ah. The operating temperature of the cells must remain around 60 °C and the maximum charge and discharge limits must not be exceeded, limits that depend on the SOC and they are represented in the Figure 13, where the positive powers refer to the discharge and the negative ones to the charge of the battery pack.   In order not to exceed the maximum limits it was defined to remain within the limits with a buffer of 1500 Watts. From Figure 14 it is possible to observe how the Open Circuit Voltage (OCV) varies according to the SOC of the battery pack. The internal resistance of each cell varies as a function of SOC and temperature, as can be seen from Table 4. Furthermore, in Table 5 main vehicle data is reported.  In order not to exceed the maximum limits it was defined to remain within the limits with a buffer of 1500 Watts. From Figure 14 it is possible to observe how the Open Circuit Voltage (OCV) varies according to the SOC of the battery pack. The internal resistance of each cell varies as a function of SOC and temperature, as can be seen from Table 4. Furthermore, in Table 5 main vehicle data is reported. In order not to exceed the maximum limits it was defined to remain within the limits with a buffer of 1500 Watts. From Figure 14 it is possible to observe how the Open Circuit Voltage (OCV) varies according to the SOC of the battery pack. The internal resistance of each cell varies as a function of SOC and temperature, as can be seen from Table 4. Furthermore, in Table 5 main vehicle data is reported.

Generators
The vehicle in question is equipped with two generators for recharging the battery pack. Each generator can deliver a nominal power of 180 kW and a maximum torque of 530 Nm, thanks to the relative turbine which rotates at a constant speed of 84 thousand RPM. These values are shown in Table 5, which summarizes the main quantities of interest of the hypercar used for the validation of the model.

Target Speed Profile
The mission of the hypercar object of this model validation is of the MotorSport type. The target speed profile for validation was obtained thanks to a maximum performance test in VI-CarRealTime on the Nordschleife variant of Nürburgring racetrack as shown in Figure 15 while Table 6 shows the main data of the target speed profile obtained and Figure 16 shows the elevation profile of the track.

Generators
The vehicle in question is equipped with two generators for recharging the battery pack. Each generator can deliver a nominal power of 180 kW and a maximum torque of 530 Nm, thanks to the relative turbine which rotates at a constant speed of 84 thousand RPM. These values are shown in Table 5, which summarizes the main quantities of interest of the hypercar used for the validation of the model.

Target Speed Profile
The mission of the hypercar object of this model validation is of the MotorSport type. The target speed profile for validation was obtained thanks to a maximum performance test in VI-CarRealTime on the Nordschleife variant of Nürburgring racetrack as shown in Figure 15 while Table 6 shows the main data of the target speed profile obtained and Figure 16 shows the elevation profile of the track.

Model Calibration
Once the results of TEST and PROPS [8] were compared, a deviation was noted between the torques required (required by the electric motors) to perform the same speed profile imposed. By isolating blocks of the program gradually, it was found that the problem arises with the balance of forces, in the TEST program the resisting forces are overes-

Model Calibration
Once the results of TEST and PROPS [8] were compared, a deviation was noted between the torques required (required by the electric motors) to perform the same speed profile imposed. By isolating blocks of the program gradually, it was found that the problem arises with the balance of forces, in the TEST program the resisting forces are overestimated at low speeds, for the vehicle in question, due to the various approximations of the model. The latter therefore requires calibration. The calibration was carried out by studying the acceleration phase, imposing a speed ramp, with constant acceleration, from 50 to 380 km/h in 30 seconds. The ramp starts from 50 km/h and not from zero speed for a correct comparison with the results of the PROPS [8] program, which presents problems at low speeds (speeds close to zero).
Furthermore, to allow the PROPS [8] results to stabilize, a 30-second interval at a constant speed of 50 km/h is taken before the ramp. The speed profile imposed for the simulations of TEST and PROPS [8], necessary for the calibration of the model, is shown in Table 7 and in Figure 17. For the comparison of the results between TEST and PROPS [8], the total motor torque was considered, equal to the sum of the torque delivered by the electric motor acting on the front axle with that delivered by the rear electric motor. The torques necessary for the execution of the ramp, obtained from the TEST (without calibration) and PROPS [8] programs, are shown in Figure 18.    From Figure 18 it is possible to see the difference between the two torque trends. In particular, the behaviour of the ratio between the TEST and PROPS [8] torque result was analysed, represented in the Figure 19 as a function of the vehicle speed. To obtain "clean" results, the results were analysed starting from the 35 seconds elapsed from the start of the simulation. In this way the results of the PROPS [8] model have time to stabilize. The coefficients of the second-order polynomial equation that approximate the ratio between Total Motor Torque (Nm) Figure 18. Comparison between TEST (without calibration) and PROPS total torques during the execution of the calibration speed profile. From Figure 18 it is possible to see the difference between the two torque trends. In particular, the behaviour of the ratio between the TEST and PROPS [8] torque result was analysed, represented in the Figure 19 as a function of the vehicle speed. To obtain "clean" results, the results were analysed starting from the 35 seconds elapsed from the start of the simulation. In this way the results of the PROPS [8] model have time to stabilize. The coefficients of the second-order polynomial equation that approximate the ratio between the torques were found. The result of the approximation function is shown in red in Figure 20. The function identified for the approximation is expressed unction identified for the approximation is expressed by Equation (51).
The lower order coefficient of the squared speed indicates that the ratio between the torques has an approximately linear trend as a function of the speed, in particular the results of TEST and PROPS [8] tend to realign for high vehicle speeds. Equation (51) mentioned above was then used to perform the TEST calibration for the hypercar described in Section 4.2.

Conditions for Validation of the Model
Total Motor Torque Ratio Figure 20. Second degree polynomial (in red) that approximate the ratio between the TEST and PROPS torques (in blue).
The lower order coefficient of the squared speed indicates that the ratio between the torques has an approximately linear trend as a function of the speed, in particular the results of TEST and PROPS [8] tend to realign for high vehicle speeds. Equation (51) mentioned above was then used to perform the TEST calibration for the hypercar described in Section 4.2.

Conditions for Validation of the Model
For the validation of the TEST model equipped with calibration, a comparison was made once again with the PROPS [8] results, this time on the speed profile of the Nürburgring obtained with VI-CarRealTime. The version of the PROPS [8] adopted does not allow to cut power to the generators if the limitations of the batteries require it, they provide constant power throughout the simulation.
Therefore, in order to also validate the electrical part of the model, it was decided to turn off both generators for the entire TEST and PROPS [8] simulations, to obtain comparable SOC, current, voltage and power data of the battery pack. Furthermore, the same braking logic of the TEST model has also been adopted for the PROPS [8].

Comparison between TEST and PROPS Results
Towards the end of the simulation the battery pack is completely discharged, as can be seen from the Figure 21. To make a comparison, it is therefore better to focus on the first 150 seconds that have passed since the start of the simulation. In fact, in these first 150 seconds the battery pack has a SOC higher than about 20% and therefore there are no problems of excessively discharged pack. The results of state of charge as a function of time in TEST and PROPS [8] model are not perfectly aligned, but the difference between the two can still be considered acceptable. In the first 150 seconds the total torque results of TEST and PROPS [8] are comparable, as can be seen in Figure 22.
first 150 seconds that have passed since the start of the simulation. In fact, in these first 150 seconds the battery pack has a SOC higher than about 20% and therefore there are no problems of excessively discharged pack. The results of state of charge as a function of time in TEST and PROPS [8] model are not perfectly aligned, but the difference between the two can still be considered acceptable. In the first 150 seconds the total torque results of TEST and PROPS [8] are comparable, as can be seen in Figure 22. Returning to the parameters of the battery pack, also the results of power, input (negative) or output (positive) current from the pack and voltage at the battery terminals can be considered consistent between the two analysed models (always focusing on the first 150 seconds from the start of the simulation). It is possible to compare the results by observing the graphs shown in Figure 23, Figure 24 and Figure 25.
As can be seen from the graphs of Figure 22, Figure 23, Figure 24 and Figure 25, the results of the PROPS [8] program are more fluctuating. This is due to the presence of the PI controller, which is absent in the TEST model.  Returning to the parameters of the battery pack, also the results of power, input (negative) or output (positive) current from the pack and voltage at the battery terminals can be considered consistent between the two analysed models (always focusing on the first 150 seconds from the start of the simulation). It is possible to compare the results by observing the graphs shown in Figures 23-25.
As can be seen from the graphs of Figures 22-25, the results of the PROPS [8] program are more fluctuating. This is due to the presence of the PI controller, which is absent in the TEST model. ative) or output (positive) current from the pack and voltage at the battery terminals can be considered consistent between the two analysed models (always focusing on the first 150 seconds from the start of the simulation). It is possible to compare the results by observing the graphs shown in Figure 23, Figure 24 and Figure 25.
As can be seen from the graphs of Figure 22, Figure 23, Figure 24 and Figure 25, the results of the PROPS [8] program are more fluctuating. This is due to the presence of the PI controller, which is absent in the TEST model.  To obtain the performance indices of the TEST model (shown in Table 8), the error was obtained (calculated as the difference between the output parameter of the TEST model and the output parameter of the PROPS model, which has been validated with realworld data [8]) and its mean and standard deviation were calculated. The mean and the  To obtain the performance indices of the TEST model (shown in Table 8), the error was obtained (calculated as the difference between the output parameter of the TEST model and the output parameter of the PROPS model, which has been validated with realworld data [8]) and its mean and standard deviation were calculated. The mean and the To obtain the performance indices of the TEST model (shown in Table 8), the error was obtained (calculated as the difference between the output parameter of the TEST model and the output parameter of the PROPS model, which has been validated with real-world data [8]) and its mean and standard deviation were calculated. The mean and the standard deviation (std) were also calculated for the absolute value (abs) of the error.
It is worth highlighting that both tools have on average the same accuracy and estimation capabilities as shown in Table 8; however, the proposed method requires a lower computational burden as it is designed using the "Backwards-Facing" technique as mentioned in Section 1, which has been proved to be more efficient. This makes this simulation tool suitable for real time applications such as driving simulators [20][21][22][23]. The same applies if compared with [13,15].
Furthermore, it is key to note that sampling time t s plays an important role on simulation performance, so that a sensitivity analysis has been carried out to assess its influence. In fact, when t s is too big the computation is faster but the final accuracy is poor due to aliasing effect, especially when t s is lower or close to the sampling rate of the input target speed profile. On the other hand, when t s is too small the computational burden grows exponentially without being justified by a substantial increase in accuracy. In general, using a sampling time between 0.05 s and 0.01 s is recommended.

Conclusions
The main target of this tool was to obtain shorter calculation times and perform closedloop simulation in a more efficient way comparing to other tools reported in literature. Such tool is reliable, robust and numerically stable. It is also intuitive and easy to use for people with no specific training, thanks to a specifically designed graphical user interface. Moreover, it features the possibility to avoid any PID (or PI) controllers to perform closed-loop simulation with a target speed profile, hence avoiding complex calibration procedures. This is possible due to the "Backwards-Facing" design technique adopted for its development. The TEST simulation tool allows also to simulate performance of a multitude of hybrid or full electric powertrains with low computational burden, short simulation time and good accuracy of results. Due to the approximations adopted in the calculation of the forces, the model may require a calibration as function of the vehicle speed. The electrical part of the model requires the knowledge of all the electrical efficiencies, for calculating the power at the battery terminals. If some of these efficiencies are unknown it is possible to consider them as calibration coefficients.
Furthermore, the program is made up of several blocks, thus resulting in a program that is modular, flexible and open to simple modifications. By making the appropriate modifications to the blocks, replacing some blocks or integrating the program with additional modules, it is possible to use the model for the simulation of other types of vehicles, for example, fuel cell vehicles. This allows for high flexibility in the simulations.
Validation is also provided, based on a comparison with another consolidated simulation tool [8]. Maximum error on mechanical quantities is proved to be within 5% while it is always lower than 10% on electrical quantities.
Author Contributions: G.S. contribution was concerned to conceptualization, methodology, software, data curation and writing-original draft preparation; M.G. contribution was concerned to writingreview and editing, visualization and supervision; D.C. contribution was concerned to validation, formal analysis, writing-review and editing, data curation and supervision. All authors have read and agreed to the published version of the manuscript.
Funding: This research received no external funding.

Institutional Review Board Statement: Not applicable.
Informed Consent Statement: Not applicable.

Data Availability Statement:
The data presented in this study are available on request from the corresponding author. The data are not publicly available due to University of Brescia privacy policy.

Conflicts of Interest:
The authors declare no conflict of interest. The difference in distance travelled, between the current instant and the previous calculation instant dz

Appendix A
The difference between the altitude of the road at the point considered and the altitude of the point of the instant of calculation preceding that considered F aero Aerodynamic resistance, drag (calculated using vehicle speed of the previous instant of calculation) F brake Force given by the traditional brakes F brake_max Maximum force that can be generated by the braking system F brake_req Force required to traditional brakes F d Aerodynamic resistance, drag F inertia_F Force lost due to inertia of the front wheels ("backward-facing" approach) F inertia_R Force lost due to inertia of the rear wheels ("backward-facing" approach) f r Static rolling resistance coefficient F r Rolling resistance F re f _wheels Total traction force required at the wheels F tr Traction force F tr_F Portion of traction force which must be guaranteed by the front motor F tr_R Portion of traction force which must be guaranteed by the rear motor F wheels_inertia_F Force lost due to inertia of the front wheels ("forward-facing" approach) F wheels_inertia_R Force lost due to inertia of the rear wheels ("forward-facing" approach) F θ Additional force given by the presence of the slope of the ground g Gravitational acceleration I Battery pack current I chrg_limit Charging limitation expressed as current I dischrg_limit Discharging limitation expressed as current I prev Battery current of the previous calculation instant I req Theoretically required battery current (if there are no limitations) I wheel_F Front wheel inertia I wheel_R Rear wheel inertia J in_F Inertia coefficients of the moving mechanical parts in input to the reducer/gearbox of the front motor J in_R Inertia coefficients of the moving mechanical parts in input to the reducer/gearbox of the rear motor J motor_F Inertia coefficient of the front electric motor J motor_R Inertia coefficient of the rear electric motor Available power which can be taken from the battery pack to power the motors P batt_F Available power which can be taken from the battery pack to power the front motor P batt_R Available power which can be taken from the battery pack to power the rear motor P battI2R Total power of all cells, dissipated by Joule effect in the entire battery pack p brake_max Maximum pressure that can be generated inside the master cylinder of the brake system P bu f f er Constant power that is used to keep within the discharge and charge limits with a defined tolerance P chrg_limit Charging limitation expressed as power P dischrg_limit Discharging limitation expressed as power P gen Power supplied to the batteries by the generators P gen_nom Nominal power of a generator P gen_th Total maximum power that the generators can supply as input to the battery pack PI Proportional-Integral controller PID Proportional-Integral-Derivative controller P mot_tot Total power that the motors absorb from the battery P req_F Power required to the battery pack by the front motor P req_R Power required to the battery pack by the rear motor PROPS Powertrain ROad Performance Simulation P tot_req Total power required to the battery pack by the motors R Resistance of the single cell of the battery pack R cable_F Electric resistance of the front connection cables R cable_R Electric resistance of the rear connection cables R m_disc_F Average radii of application of the braking force on the front discs R m_disc_R Average radii of application of the braking force on the rear discs R wheel_F Rolling radius of the front wheels R wheel_R Rolling radius of the rear wheels SOC State of Charge TEST Target-speed EV Simulation Tool T mot_F Front drive torque T mot_R Rear drive torque

TractRatio acc
Distribution of torque between the front and rear electric motors (towards the front) in the case of the accelerator pedal pressed

TractRatio brak
Distribution of torque between the front and rear electric motors (towards the front) in the case of the brake pedal pressed T re f _F Front motor torques required