Main Content

Reduced Order Modeling of Battery Electric Vehicle Thermal Management System

This example shows how to use AI to create a static reduced order model (ROM) that functions as a surrogate for a battery electric vehicle (BEV) thermal management system.

You can apply this example workflow to any third-party finite element analysis (FEA) or computational fluid dynamics (CFD) model that runs too slowly to use for design analysis or optimization problems, where the detailed model needs to be evaluated thousands of times.

In this example, you use the Reduced Order Modeler app to:

  • Specify ROM inputs and outputs.

  • Design experiments.

  • Generate input and output data from the virtual vehicle model.

  • Train an AI-based surrogate model from the input and output data using preconfigured training templates.

You can then use the trained surrogate model for:

  • Iterative optimization of designs for different design scenarios, changing requirements, and competing criteria

  • Performing rapid trade-off and "what-if" studies

Battery Electric Vehicle Thermal Management System.

This example requires the Reduced Order Modeler for MATLAB® add-on, which you can install using the instructions in Get and Manage Add-Ons.

For more information, see Reduced Order Modeling (Simulink).

Open Virtual Vehicle Model and Reduced Order Modeler App

Open the Simulink® model BEV_Thermal_Management and update it by clicking Update Model on the Modeling tab. Simulink evaluates the model block parameter expressions, determines their values, and prepares the model for simulation.

open_system("BEV_Thermal_Management")

Battery Electric Vehicle Thermal Management Simulink Model.

The virtual vehicle model in this example is a Simscape™ model of a mid-size battery electric vehicle that includes the powertrain, driveline, thermal management system, and all required interdependencies. To analyze the overall energy consumption, the model is set up to simulate the vehicle traveling 700 km for 8.33 hours over a drive-and-charge scenario. This holistic vehicle model provides a way to perform analysis and virtual testing on the entire vehicle for different scenarios. For more information on how to model a thermal management system of a battery electric vehicle, refer to Electric Vehicle Thermal Management (Simscape Fluids).

To optimize the design of the thermal management system for minimal overall energy consumption, you can directly leverage the virtual vehicle model with Simscape, or you can create an AI-based static ROM to serve as a surrogate model. A static ROM is a time-independent function that maps input values to output values. In this example, the input values are the design parameters of interest in the electric vehicle, and the output value is the total energy consumed by the vehicle. Creating a static ROM incurs a one-time cost of collecting data from the virtual vehicle model and using that data to train an AI model. However, the static ROM has a faster inference time than the original model, so it is useful for applications that require many simulation evaluations. For example, you might use a static ROM for design analysis, iterative optimizations, or rapid trade-off and "what-if" studies.

Open the Reduced Order Modeler app.

reducedOrderModeler("BEV_Thermal_Management")

This example describes the complete workflow to create a static ROM. However, you can choose to begin at the Run Experiment step or the Create Static ROM Using MLP Network step by loading the session files mentioned in these steps. These session files provide the same results as if you had completed the steps up to that point. To use a ROM that was pretrained by following the steps in this example, begin at the Use Trained ROM step.

Select ROM Inputs and Outputs

Specify the ROM inputs and outputs.

  • In the app, on the Reduced Order Model tab, click New Session. The Select ROM I/Os dialog box opens.

  • In the Select ROM I/Os dialog box, click Select Parameters. The Simulink model appears in a mode where you can interact with it and select parameters.

  • To select a parameter, click the corresponding block in the model and then select the parameter in the list that appears. Select these parameters.

Parameter

Block

blower_Ki

BEV_Thermal_Management/Controls/Cabin Air Control/PID Controller

blower_Kp

BEV_Thermal_Management/Controls/Cabin Air Control/PID Controller

compressor_Ki

BEV_Thermal_Management/Controls/Compressor Control/PID Controller

compressor_Kp

BEV_Thermal_Management/Controls/Compressor Control/PID Controller

heater_max_power

BEV_Thermal_Management/Heater/Max Power [W]

ptc_max_power

BEV_Thermal_Management/PTC/Max Power [W]

vehSpeedMax

BEV_Thermal_Management/Scenario/Drive Cycle Logic

The parameters you select appear in the Select ROM I/Os dialog box, in the table below Select Parameters. Keep the I/O Type of each parameter as the default type, ROM & Simulation Input. Specifying the parameters as both ROM and simulation inputs allows you to collect data for different combinations of parameter values representing different conditions.

To capture the energy consumed by the electric vehicle as the output, use the post-processing function calcEnergyConsumption.m. This function accesses the simulation logs after each simulation run and computes the energy consumption, consDriving.

  • In the Select ROM I/Os dialog box, click Select Signals. The Simulink model appears in a mode where you can interact with it and select signals.

  • Select the VehDst signal from BEV_Thermal_Management/Scenario by clicking the signal in the model and then selecting it in the list that appears.

  • Change the I/O Type of this signal to ROM Output.

  • Select Transform ROM output signal and then select Use function to transform. Click Browse and select the function calcEnergyConsumption.m.

Select ROM I/Os dialog box showing the selected signals and parameters.

  • The Transform Output Signal dialog box opens. Click OK.

Transform Output Signal dialog box.

  • In the Select ROM I/Os dialog box, click OK. The selected parameters and outputs appear in the Inputs/Outputs pane in the Reduced Order Modeler app.

Configure Experiment

Specify the ranges within which parameters can vary and create experiments for generating input and output data from the original model.

  • On the Reduced Order Model tab, click New Experiment. The Experiment and Experiment Signals tabs open.

  • In the Configure Experiment pane, set the Method to Distribution and then click Edit Distributions.

  • In the Edit Distributions dialog box, select Latin Hypercube from the Sampling Method menu.

  • Select Distribution as Uniform for all parameters.

  • Enter the lower and upper limits for each parameter based on your knowledge of the physical system. By default, these limits are set to -10% and +10% of the parameter values obtained from a baseline simulation of the model. Click OK.

Parameter

Lower Limit

Upper Limit

blower_Ki

0.006

0.007

blower_Kp

0.037

0.05

compressor_Ki

0.2

0.4

compressor_Kp

0.9

1.1

heater_max_power

5000

7000

ptc_max_power

2000

3000

vehSpeedMax

110

140

Edit Distributions dialog box showing the different options.

For each simulation in the experiment, the app uses the Latin Hypercube sampling method to choose random values of the parameters within their specified ranges.

  • In the Configure Experiment pane, set Number of samples to 100 and click Apply.

For more information on the options available for configuring experiments, see Configure Options in Reduced Order Modeler (Simulink).

Experiment tab in the Reduced Order Modeler app.

Run Experiment

Note: You can begin at this step by loading the BEV_Thermal_Management_ROMSession_expsetup.mat session file in the app. This session file includes the same experiment configuration as if you had completed the previous steps in the example. To load the file, on the Reduced Order Model tab, click Open Session, find the session file, and open it. To view the experiment configuration, in the Experiments pane, double-click the experiment.

Log the parameter and output data for training the ROM by running the virtual vehicle model with the experiment you configured.

This experiment definition produces 100 simulation runs over the drive-and-charge scenario using different combinations of parameter values. If you have Parallel Computing Toolbox™ software, you can run these simulations in parallel:

  • On the Reduced Order Model tab, click Simulation Options.

  • In the Run Options dialog box, select Use Parallel when running multiple simulations.

  • Click OK.

  • If the parallel pool is not already enabled, at the MATLAB command line, type parpool('local').

To run the simulations, on the Reduced Order Model tab, click Run Simulations.

Reduced Order Modeler app showing the simulation results.

Create Static ROM Using MLP Network

Note: You can begin at this step by downloading and opening the BEV_Thermal_Management_ROMSession_results.mat session file in the app. This session file contains simulation data from the virtual vehicle, collected using the same experiment configuration demonstrated in this example. To download the file, run the following code:

url = 'https://ssd.mathworks.com/supportfiles/rom/ROMSessionResults.zip';
websave('ROMSessionResults.zip',url);
unzip('ROMSessionResults.zip');

To load the file, on the Reduced Order Model tab, click Open Session, find the session file, and open it. To view the simulation results, on the Reduced Order Model tab, click Open Results.

After you generate or import the simulation results, the available options for the type of ROM to create appear in the Create Model section on the Reduced Order Model tab.

Reduced Order Model tab showing the Create Model section.

To create the static ROM, train a multilayer perceptron (MLP) network that predicts the total energy consumed by the vehicle consDriving based on the values of the input parameters.

  • On the Reduced Order Model tab, in the Create Model gallery, select MLP Network as the model type. The Export Results dialog box opens.

  • To fit an MLP network using the selected experiment results, in the Export Results dialog box, select the experiment and output signal and click OK.

  • In the Create Experiment dialog box, select New Project, click OK, and save the experiment project. The Experiment Manager app opens.

Experiment Manager creates an experiment to train an MLP network using the simulation results. To view experiment information such as the high-fidelity system, ROM model type, and test data percentage in Experiment Manager, view the Description text box on the Experiment1 tab.

Set the Hyperparameters Strategy to Exhaustive Sweep. Experiment Manager sweeps over different hyperparameters to train different models, then determines which models work best. For training, use the default hyperparameters:

  • HiddenLayerSize — [16 32]

  • NumberLayers — [1 2]

You can edit the function used to train the MLP network. To open the training function, in the Training Function section, click Edit. For this example, use the default training function, Experiment1_training1.

Train the models. If you have Parallel Computing Toolbox software, you can run multiple trials at the same time or offload your experiment as a batch job in a cluster. To train the models in parallel, on the Experiment Manager tab, in the Execution section, set Mode to Simultaneous. Click Run.

On the Experiment1 | Result1 tab, each row in the results table represents a trained model. The row for each model displays each of its hyperparameter values, as well as model performance information and metrics:

  • TrainingMSE is the mean squared error calculated on the training data set. It is the average squared difference between the output obtained by simulating the original model and the output predicted by the trained model, using the training data values. Because the training data values were used to train the model, TrainingMSE shows how well the model fits the data used to train it.

  • TestMSE is the mean squared error calculated on the test data set. It is the average squared difference between the output obtained by simulating the original model and the output predicted by the trained model, using the test data values. Because the test data values were not used to train the model, TestMSE shows how well the model performs on new data.

  • TrainingLoss is the measure of inaccuracy of the model predictions calculated on the training data set. It shows how the model progresses by learning from the training data.

Sort the trained models by TrainingLoss in ascending order by clicking the arrow on the right of the TrainingLoss column header and selecting Sort in Ascending Order in the list that appears.

The results table in Experiment Manager containing the trained models.

Of the models you trained, export the model with low TestMSE, reasonable TrainingMSE, and low TrainingLoss. To export a model as a workspace variable, first, select its row in the results table. On the Experiment Manager tab, in the Export menu, click Training Output. Name the workspace variable as trainingOutput_MLP and click OK. Because the experiment that generates the training data uses randomly sampled values for the input parameters, model performance might vary.

For more information on hyperparameters and metrics, see Configure Options in Reduced Order Modeler (Simulink).

Use Trained ROM

Note: You can begin at this step by loading a previously trained MLP network, BEV_trainedMLP.mat. This network was trained using data generated by experiments configured as shown in this example. To load the network, at the command line, enter:

load('BEV_trainedMLP.mat')

Use the MLP network you trained as a ROM of the virtual vehicle model. The trainingOutput_MLP variable stores the trained MLP network and the associated data, including normalization details.

trainingOutput_MLP
trainingOutput_MLP = struct with fields:
          Network: [1×1 dlnetwork]
     TrainingLoss: [1×1 dlarray]
         TestLoss: [1×1 dlarray]
    Normalization: [1×1 struct]

As part of model training, the MLP network normalizes the input and output values. Extract these normalization values for the input parameters blower_Ki, blower_Kp, compressor_Ki, compressor_Kp, heater_max_power, ptc_max_power, and vehSpeedMax.

meanX_mlp = trainingOutput_MLP.Normalization.Mu(1,1:7);
stdX_mlp = trainingOutput_MLP.Normalization.Sigma(1,1:7);

Extract the normalization values for the output energy consumption.

meanY_mlp = trainingOutput_MLP.Normalization.Mu(1,8);
stdY_mlp = trainingOutput_MLP.Normalization.Sigma(1,8);

Load an independent test data set. This data set contains a set of input parameter values. It also contains the output energy consumption value obtained by simulating the original virtual vehicle model using these input parameters.

load('BEV_testData.mat');

Normalize the input parameters using the input normalization values extracted from trainingOutput_MLP.

inputParametersN = (inputParameters - meanX_mlp)./stdX_mlp;

Predict the output using the normalized input parameters from the test data set. Calculate the time it takes to complete the prediction.

net = trainingOutput_MLP.Network;
tic;
predConsumption = predict(net,inputParametersN(1,1:7));
toc;
Elapsed time is 0.741210 seconds.

The ROM predicts the output for one simulation of the drive-and-charge scenario in around one second. In contrast, the original virtual vehicle model takes about three minutes to predict the output. The faster inference time of the surrogate model makes it the better option for rapid trade-off analysis and iterative optimization.

Denormalize the predicted energy consumption using the output normalization values extracted from trainingOutput_MLP.

predConsumptionDN = predConsumption*stdY_mlp+meanY_mlp
predConsumptionDN = single

14.8571

Compare this energy consumption with the actual energy consumption that you loaded from BEV_testData.mat.

actualConsumption
actualConsumption = 
14.9090

You can see that the energy consumption predicted using the trained ROM is similar to that obtained by simulating the original virtual vehicle model, as expected.

To identify the design parameters of the thermal management system that minimize overall energy consumption, you can use the trained static ROM within an optimization loop. You can further validate the optimized design parameters by using them in simultaions of the original virtual vehicle model in Simscape.

See Also

(Simulink) |

Topics