Skip to content

mathworks/Simscape-Battery-Electric-Vehicle-Model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Battery Electric Vehicle Model in Simscape™

View Battery Electric Vehicle Model in Simscape on File Exchange

Version 3.0

Introduction

This is a MATLAB® Project containing a Battery Electric Vehicle (BEV) model and its components such as motor, high voltage battery, and longitudinal vehicle. This project demonstrates Simscape's modular and multi-fidelity modeling technology.

The abstract BEV model is built in a simple and modular fashion, and it can run faster than real-time. It is suitable as a baseline model for drive cycle simulation to estimate vehicle's electrical efficiency and other vehicle-level information.

This project also contains the model of a detailed permanent magnet synchronous motor (PMSM) and controller. It captures the detailed behaviors of the AC motor drive unit and can estimate the electrical efficiency at the unit level.

A Live Script demonstrates how to obtain the electrical efficiency from the slow but detailed motor drive unit and use the result as the block parameter of the simple but fast motor drive block in the BEV model.

BEV system model:

Screenshot of the battery electric vehicle model

FTP75 drive cycle simulation result:

Screenshot of the simulation result plots

Simple drive pattern simulation result:

Screenshot of the simulation result plots

Use BEV Project Navigator App to quickly access some key files and tools.

Screenshot of the longitudinal vehicle performance design app

Use Vehicle1D Performance Design App to design the basic performance parameters of a road vehicle.

Screenshot of the longitudinal vehicle performance design app

Use Motor Drive Unit Efficiency App for System Thermal Model to understand how the model parameters are affecting the motor efficiency.

Screenshot of the motor drive unit efficiency app for system thermal model

Use Motor Drive Unit App to select model and run simulation for the Motor Drive Unit.

Screenshot of the motor drive unit app

Whats' New in 3.0 (July 2025)

Past What's New contents have been moved to Change Log.

Plain-text Live Scripts

From R2025a, you can save Live Scripts as plain-text files.

All Live Scripts in the project are now plain-text with .m extensions. The use of plain-text files improves the compatibility with source control systems. Text-based search and replace work with not only conventional MATLAB code files but also all Live Script files in the project.

Revamped Component Folders

A model for testing a component is now placed in the component top folder. This improves the discoverability of models for component testing.

Component models that are built as Referenced Subsystems such as Basic model or System model are stored in separate subfolders, such as Model-Basic or Model-System, respectively. Related resources for a referenced subsystem including simulation case scripts and test code files are saved in the same folder, improving the isolation of each component model.

Unit testing with Build Tool and buildfile.m

For running unit tests, the project now uses the Build Tool with buildfile.m.

From R2025a, you can run Build Tool tasks using the Run Build button in the Toolstrips in addition to using the buildtool command on the Command Window.

This project has several buildfile.m files. The Editor recognizes the buildfile.m file as a Build Tool file and shows the Run Build button in the Editor Toolstrip. The project finds the buildfile.m file in the project root folder and shows the Run Build button in the Project Toolstrip.

Updated Reducer Component

Reducer component now has a test model and supporting files.

Also, the Reducer component uses Simscape selective data logging, which simplifies the way data in Simscape blocks is logged during simulation. Other components will use the same approach in the future.

Signal Design App

To edit physical input signals using PS Lookup Table (1D) blocks in the Reducer component, Signal Tool is used.

  • For graphically editing signals, you can use SignalDesignApp which is included in the project and you can find in Project root > Utility > SignalTool folder.

    Screenshot of the longitudinal vehicle performance design app

  • For programmatically editing signals, you can use functions in the SignalTool1 name space. See the Live Scripts in Project root > Components > Reducer > Model-Basic > SimulationCases folder for example usages.

Tool Requirements

Supported MATLAB Version: R2025a or newer releases

Required: MATLAB, Simulink®, Powertrain Blockset, Simscape, Simscape Driveline™, Simscape Electrical™

Optional: MATLAB Test, Parallel Computing Toolbox™

How to Use

Open BatteryElectricVehicle.prj in MATLAB, and it will automatically open the project main page BEV_main_script.html. The script contains the description of the model and hyperlinks to models and scripts.

How to Use in MATLAB Online

You can try this in MATLAB Online. In MATLAB Online, from the HOME tab in the toolstrip, select Add-Ons > Get Add-Ons to open the Add-On Explorer. Then search for the submission name, navigate to the submission page, click Add button, and select Save to MATLAB Drive.

Testing and quality assurance

BEV system model and its components are tested using MATLAB Unit Testing framework.

  • Some tests are passing tests that check if code runs or not and do not use the verify* functions. They simply run scripts, functions, classes, or models, and check that they run without errors. Passing tests are designed to finish quickly so that they can be used in day-to-day development activities in a short iteration cycle.

  • This project uses the buildtool with buildfile.m to check code, run tests, measure code coverage, and generate test reports and code coverage reports. See buildfile.m in this project for how the buildtool is configured. Checking code with the buildtool is done by Code Analyzer.

Remote test automation / Continuous integration

The git repository of this project in github.com/mathworks is set up for test automation using GitHub Actions and MATLAB Actions. Unit tests in this project are run automatically when changes are pushed to the repository in github. See the .github/workflows folder for configuration files.

Additional Notes

See Also

MATLAB Central File Exchange

Visit the File Exchange page of this project.

Hybrid Electric Vehicle Model in Simscape

Electric Vehicle Design with Simscape

License

See license.txt.

Copyright 2020-2025 The MathWorks, Inc.

About

A Battery Electric Vehicle (BEV) model in Simscape for longitudinal powertrain analysis

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •