How to get "range" and "0-100kph accelerate time" by Virtual Vehicle Composer as shown in this video?

19 visualizaciones (últimos 30 días)
Hello everyone!
I'm currently learning "Virtual Vehicle Composer" app by wacthing this video "Optimize EV Battery Performance Using Simulation". However, I can't get the "range" and the "0-100kph accelerate time" as shown in the video. I assumed that I need to calculate these parameters by changing the Virtual Vehicle Compose autobuild simulink model, which means adding some new blocks or algorithms in it.
But I can't find anyother documents or videos to learn how to calculate the range in a typical drive cycle, or get 0-100kph time as a parameter which can be changed by optimization algorithm. I also want to use these parameters to do further research, such as “optimization” which is also shown in the video.So how can I get these parameters?

Respuesta aceptada

Lorenzo
Lorenzo el 30 de Mayo de 2023
Hello Bobby,
Your assumption is correct: To estimate range and acceleration time you need to employ a bit of MATLAB scripting. I can help you with that.
I will show you how to do this by using the Virtual Vehicle Composer in the 23a version (the procedure should work also for previous versions). In the explanation below, I use as example a vehicle model generated with the Virtual Vehicle Composer which includes only longitudinal dynamic.
Calculate accelration time:
To calculate the acceleration time you have to first select the Wide Open Throttle (WOT) test in the Reference Generator Block (contained in the Scenarios subsystem). Once the WOT is selected, do not forget to click on "Set Model Simulation Time" button right below.
This will activate the Wide Open Throttle test. The driver will try to follow the speed profile given by this test. To estimate the acceleration time, you cannot use the speed profile given by the Reference Generator since this is the profile that the driver will try to follow and does not correspond to the actual speed of the vehicle.
Therefore, you have to monitor the actual vehicle speed over time. By default the vehicle speed is one of the signal that is logged in the model created by the Virtual Vehicle composer:
Again by default the simulation results of a model created with the Virtual Vehicle Composer are saved in the MATLAB Workspace in a variable named out. You can visualize the logged signal after a simulation by calling the following line in the command window
out.logsout
Which will show a list of the logged signals (see below):
We are interested in the speed and we can retrieve it by using the command
speed(:,1) = out.logsout.getElement('<xdot>').Values.Time; % Time vector of the simulation
speed(:,2) = out.logsout.getElement('<xdot>').Values.Data; % Speed vector
% Plot speed over time:
plot(speed(:,1),speed(:,2))
Now you can further analyze this vector to estimate how much time it takes to the vehicle to reach the speed of 100 km/h (pay attention that the first second of the WOT the vehicle does not move and make sure you are using the correct units for the speed).
Calculate range:
The range calculation follows a similar pattern as above. First of all, you have to select in the Reference Generator Block which drive cycle you want to use for the consumption simulation (in the presentation you linked we used the WLTP).
Now you have to log the vehicle consumption. This signal is not logged by default. The easiest way to start is to log the battery power signal, which logs the power output of the battery over time during the simulation. You can log this signal by going in the subsytem: ConfiguredVirtualVehicleModel/Vehicle/Plant Models/Simulink Models (ConfiguredVirtualVehiclePlantModel)/Electrical System/Electrical System (see below).
The signal will be logged under the name 'BattPwr' (the same name it has in the simulink model) and can be called after the simulation with this line of code:
simTime = out.logsout.getElement('BattPwr').Values.Time;
pwrBatt = out.logsout.getElement('BattPwr').Values.Data;
With this you can calculate the energy power taken out from the battery
energyUsed = trapz(simTime, pwrLoss)/3600/1000; % Used energy in kWh
Now you can just divide this value for the length of the cycle (for example in km) to derive the vehicle consumption in kWh/km.
Finally, based on the battery energy content that you have set (normally expressed in kWh) you can extrapolate the range of the vehicle.
Hope this helps,
Best,
Lorenzo
  12 comentarios
Lorenzo
Lorenzo el 28 de Mzo. de 2024
Hello Jamie,
The reason is simple: In this case you did not create a variable "pwrLoss" in your MATLAB workspace. Consequently, when you call that line of code, you get the error.
As I showed above the power loss variable could be anything (you have to choose where to measure the losses). However, let us do a quick example on how this work. In any part of the model where there is a power signal, you can log this (not the blue WiFi symbol in the figure below):
Now after simulation, the results are normally saved in the variable out, and you can visualize the logged signal by calling
out.logsout
Which will display the following, note that among those signals
On the column name you find the name of the signal. This is the SAME name as the signal in the model, so if in your model your signal is named BatPwr, you should find it also listed in the column name.
Assuming that BatPwr is the signal you want to use to measure the losses you can use the following code:
simTime = out.logsout.getElement('BattPwr').Values.Time;
pwrBatt = out.logsout.getElement('BattPwr').Values.Data;
energyUsed = trapz(simTime, pwrBatt)/3600/1000; % Used energy in kWh
To calculate the energy used by the battery.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Virtual Vehicles en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by