Calculating Energy consumption{Software simulation in Scilab and Xcos} Part 2 - swapnilmankame1995/EV-course GitHub Wiki

Simulating WLTC Drive cycle to get accurate range figures.

Now that we have set up our environment, its time to move forward and start our simulation.

But first, we need to understand all the mathematical expressions that go into calculating the energy consumption of a vehicle! as we will be simulating with the help of these equations.

The method to calculate the energy consumption is pretty straight forward The steps are as follows:

  1. Determine the mathematical expression of the energy consumption
  2. Create a Scilab script file (*.sce) for the vehicle parameters (input data)
  3. Create the Xcos block diagram (*.zcos)
  4. Run the simulation on the WLTC driving cycle
  5. Create a post-processing script (*.sce) and analyse the result

Mathematical expression of the energy consumption

The energy consumption is calculated based on the road loads. The total road load F-tot [N] is the sum of the inertial force, road slope force, road load (friction) force and aerodynamic drag force.


CodeCogsEqn (2).png

where:

  • Fi [N] – inertial force
  • Fs [N] – road slope force
  • Fr [N] – road load force
  • Fa [N] – aerodynamic drag force

The inertial force is given by the equation:

CodeCogsEqn (3).png

where:

  • mv [kg] – total vehicle mass
  • av [m/s2] – vehicle acceleration

The vehicle acceleration can be calculated as:

CodeCogsEqn (5).png

where:

  • Δv [m/s] – speed difference
  • Δt [s] – time difference

The road slope force is given by the equation:

CodeCogsEqn (6).png

where:

  • g [m/s2] – gravitational acceleration
  • αs [rad] – road slope angle

The road load (friction) force is given by the equation:

CodeCogsEqn (7).png

where:

  • crr [-] – road rolling resistance coefficient

The aerodynamic drag force is given by the equation:

CodeCogsEqn (8).png

where:

  • ρ [kg/m3] – air density at 20 °C
  • cd [-] – air drag coefficient
  • A [m2] – vehicle frontal area
  • vv [m/s] – vehicle speed

The total power P-tot [W] is calculated as the product between the total road forces and the vehicle speed:

CodeCogsEqn (9).png


By integrating the total power over time (for the whole duration of the cycle), we get the total energy consumption E-tot [J]:

CodeCogsEqn (10).png

All the equations above will be used in the Xcos block diagram in order to calculate the energy consumption of the vehicle over the drive cycle.

Vehicle parameters (input data).

Below is the script that will be implemented In scinotes Similar to the previous chapter, where we inserted the script to import the excel file

vehMassKerb = 1908 ; // [kg]
vehMassDriver = 80; // [kg]
vehMassfm = 1.05; // [-]
vehMass = vehMassKerb * vehMassfm + vehMassDriver; // [kg]
vehg = 9.81; // [m/s^2]
vehcd = 0.36; // [-]
vehfa = 2.42; // [m^2]
vehro = 1.202; // [kg/m^3]
roadSlope = 0; // [rad]
roadCrr = 0.011; // [-]

scinotesparameters.jpg

Once pasted, Click on save and execute. via the execute tab above,

Here,

  • vehMassKerb = kerb weight of the vehicle
  • vehMassDriver = weight of the driver
  • vehMassfm = Mass factor
  • vehMass = total mass of the vehicle
  • vehg = acceleration due to gravity.
  • vehcd = Coeff of drag
  • vehfa = vehicle frontal area
  • vehro = air density at 20 °C
  • roadSlope = Angle of inclination of the road in radians
  • roadCrr = road rolling resistance coefficient

Now To simulate it in XCOS

Xcos provides a modular approach for complex system modeling, using a block diagram editor. Xcos models are compiled and simulated in a single run.

Make sure you have Scilab open

With Scilab opened, you can launch Xcos in several ways:

  • by clicking the toolbar icon Xcos toolbar icon

utilities-system-monitor-65x65.png

  • or, from the menu bar, by clicking Applications -> Xcos
  • by entering at the Scilab console: xcos

When Xcos is launched, two windows are opened by default:

  1. A palette browser
  2. An editing window

Xcos-Palette-Browser-Libraries-and-Blocks-227x300.jpg1. Pallete browser

he Palette browser has two panes. The left pane contains the list of available predefined palettes (libraries). The right pane contains the available blocks for each palette. By clicking another palette in the left pane, a new set of blocks will appear on the right pane.

Xcos-new-model-file.jpg2. Xcos editing window

The editing window is the Xcos workspace for developing new models (diagrams). In order to add blocks in the diagram, select the block from the palette browser and drag & drop in the editing window.

You can also add block to the diagram by right-clicking the block in the library and Add to -> “name of the diagram“.


Now that you know the how to open the editor! i request you to play around and Build the block diagram given below by dragging and dropping all the blocks from the palette.

If you have any problems, make sure to ask

Range Estimation - Fixed.png

Here is a PDF tutorial Explaining how to get yourself familiar with Xcos - Download Pdf

Another tutorial here might help Xcos for beginners

After you have Built the Block diagram! you will need to change some settings.

  1. click on Simulation in the top bar and select setup,
  2. And enter "1800" in the Final integration time as the Test cycle only runs for 1800 seconds. so we will be integrating from 0 to 1800.

setup.jpg

The Xcos block diagram model is run for 1800 s, which is to total duration of the WLTC drive cycle.

A Clock block is used to generate a time step of 1 s. This time step is set because the input data (WLTC speed profile) is sampled at 1 s.

The Xcos block diagram model is run for 1800 s, which is to total duration of the WLTC drive cycle. A Clock block is used to generate a time step of 1 s. This time step is set because the input data (WLTC speed profile) is sampled at 1 s. The speed profile is read with a From workspace block.

We have already uploaded the speed profile in the previous chapter. basically uploading the excel sheet into a structure variable called WLTC containing the speed values and time (e.g. WLTC.time and WLTC.values

Since the sample time is 1 s, which means Δt = 1, the vehicle acceleration will be calculated as the difference between the current speed value and the previous speed value. In the WLTC driving cycle, the road slope is considered 0 rad, therefore will not have any influence on the energy consumption.

Depending on the sign of the total power, we can distinguish between the acceleration and braking (deceleration) phases of the vehicle. The integration of the power, for a Δt = 1, gives the energy. The acceleration and braking energies are calculated separately and then summed up to give the total energy.

From the Block diagram above

By dividing the last calculated value of the total energy (2622.67 Wh) to the total length of the WLTC drive cycle (23.266 km), we get the average energy consumption of the vehicle, 112.7 Wh/km.

Data post-processing

Using a Scilab script we can plot the drive cycle simulation result. In this particular case we are going to plot only the acceleration, braking and total energy.

plot(WLTC_vehTotEgy_kWh.time, WLTC_vehTotEgy_kWh.values,'k')
plot(WLTC_vehAccEgy_kWh.time, WLTC_vehAccEgy_kWh.values,'r')
plot(WLTC_vehBrkEgy_kWh.time, WLTC_vehBrkEgy_kWh.values,'b')
xgrid()
xlabel('Time [s]','FontSize',2)
ylabel('Energy [kJ]','FontSize',2)
title('Pupilfirst','FontSize',2)
legend('Total','Acceleration','Braking',2)

Running the above script will generate the following plot.

WLTC-energy-consumption.jpg

The same model can be used for any other vehicle, the only change needed being the input parameters update. Also, the simulation can be run for different drive cycles, like FTP or NEDC or for custom cycles which can include also a road gradient.

Once we complete the simulation! we can get the average energy consumption! based on this we will be selecting a battery for our vehicle.

Submissions for this chapter

Build the Block-diagram and calculating the average Energy consumption

Rubrics

  1. Install Scilab.
  2. Build Xcos Block Diagram.
  3. Submit screenshot of results.

Tips:

  • Refer this tutorial if you are stuck anywhere with Xcos - Download Pdf

  • Submit questions in the community forum if you are stuck.

The average energy consumption over WLTC drive cycle is 112.7 Wh/km. This value will be used to calculate the total energy required for the high voltage battery.