Explore the Hybrid Electric Vehicle P0 Reference Application

The hybrid electric vehicle (HEV) P0 reference application represents a full HEV model with an internal combustion engine, transmission, battery, motor, and associated powertrain control algorithms. Use the reference application for hardware-in-the-loop (HIL) testing, tradeoff analysis, and control parameter optimization of a HEV P0 hybrid. To create and open a working copy of the reference application project, enter

By default, the HEV P0 reference application is configured with:

  • Lithium-ion battery pack

  • Mapped electric motor

  • Mapped spark-ignition (SI) engine

This diagram shows the powertrain configuration.

This table describes the blocks and subsystems in the reference application, indicating which subsystems contain variants. To implement the model variants, the reference application uses variant subsystems.

Reference Application ElementDescriptionVariants

Analyze Power and Energy

Double-click Analyze Power and Energy to open a live script. Run the script to evaluate and report power and energy consumption at the component- and system-level. For more information about the live script, see Analyze Power and Energy.


Drive Cycle Source block — FTP75 (2474 seconds)

Generates a standard or user-specified drive cycle velocity versus time profile. Block output is the selected or specified vehicle longitudinal speed.

Environment subsystem

Creates environment variables, including road grade, wind velocity, and atmospheric temperature and pressure.

Longitudinal Driver subsystem

Uses the Longitudinal Driver or Open Loop variant to generate normalized acceleration and braking commands.

  • Longitudinal Driver variant implements a driver model that uses vehicle target and reference velocities.

  • Open Loop variant allows you to configure the acceleration, deceleration, gear, and clutch commands with constant or signal-based inputs.

Controllers subsystem

Implements a powertrain control module (PCM) containing a P0 hybrid control module (HCM), an engine control module (ECM), and a transmission control module (TCM).

Passenger Car subsystem

Implements a hybrid passenger car that contains drivetrain, electric plant, and engine subsystems.

Visualization subsystem

Displays vehicle-level performance, battery state of charge (SOC), fuel economy, and emission results that are useful for powertrain matching and component selection analysis.


Evaluate and Report Power and Energy

Double-click Analyze Power and Energy to open a live script. Run the script to evaluate and report power and energy consumption at the component- and system-level. For more information about the live script, see Analyze Power and Energy.

The script provides:

  • An overall energy summary that you can export to an Excel® spreadsheet.

  • Engine plant, electric plant, and drivetrain plant efficiencies, including an engine histogram of time spent at the different engine plant efficiencies.

  • Data logging so that you can use the Simulation Data Inspector to analyze the powertrain efficiency and energy transfer signals.

For more information about the live script, see Analyze Power and Energy.

Drive Cycle Source

The Drive Cycle Source block generates a target vehicle velocity for a selected or specified drive cycle. The reference application has these options.


Output sample time

Continuous (default)

Continuous operator commands


Discrete operator commands

Longitudinal Driver

The Longitudinal Driver subsystem generates normalized acceleration and braking commands. The reference application has these variants.

Block Variants


Longitudinal Driver (default)



PI control with tracking windup and feed-forward gains that are a function of vehicle velocity.


Optimal single-point preview (look ahead) control.


Proportional-integral (PI) control with tracking windup and feed-forward gains.

Low-pass filter (LPF)


Use an LPF on target velocity error for smoother driving.


Do not use a filter on velocity error.



Stateflow® chart models reverse, neutral, and drive gear shift scheduling.


Input gear, vehicle state, and velocity feedback generates acceleration and braking commands to track forward and reverse vehicle motion.


No transmission.


Stateflow chart models reverse, neutral, park, and N-speed gear shift scheduling.

Open Loop

Open-loop control subsystem. In the subsystem, you can configure the acceleration, deceleration, gear, and clutch commands with constant or signal-based inputs.

To idle the engine at the beginning of a drive cycle and simulate catalyst light-off before moving the vehicle with a pedal command, use the Longitudinal Driver variant. The Longitudinal Driver subsystem includes an ignition switch signal profile, IgSw. The engine controller uses the ignition switch signal to start both the engine and a catalyst light-off timer.

The catalyst light-off timer overrides the engine stop-start (ESS) stop function control while the catalyst light-off timer is counting up. During the simulation, after the IgSw down-edge time reaches the catalyst light-off time CatLightOffTime, normal ESS operation resumes. If there is no torque command before the simulation reaches the EngStopTime, the ESS shuts down the engine.

To control ESS and catalyst light-off:

  • In the Longitudinal Driver Model subsystem, set the ignition switch profile IgSw to 'on'.

  • In the engine controller model workspace, set these calibration parameters:

    • EngStopStartEnable — Enables ESS. To disable ESS, set the value to false.

    • CatLightOffTime — Engine idle time from engine start to catalyst light-off.

    • EngStopTime — ESS engine run time after driver model torque request cut-off.


The Controller subsystem has a PCM containing an ECM, HCM, and TCM. The controller has these variants.

ECMSiEngineController (default)

Implements the SI Controller


Implements the CI Controller



Implements an equivalent consumption minimization strategy (ECMS)2 that minimizes energy consumption while maintaining the battery state of charge (SOC).

Implements either adaptive or non-adaptive ECMS.

  • (default) Non-adaptive — ECMS uses a constant equivalence factor. Use this method to determine the best fuel economy over a drive cycle.

  • Adaptive — ECMS adjusts an equivalence factor with the output of a PI controller. Use this method to help sustain the charge over different drive cycles.



Implements the transmission controller

ECMS Control

The HCM implements a dynamic supervisory controller that determines the engine torque, motor torque, starter, clutch, and brake pressure commands. Specifically, the HCM:

  • Converts the driver accelerator pedal signal to a wheel torque request. To calculate the total powertrain torque at the wheels, the algorithm uses the maximum engine torque and motor torque curves and the transmission and differential gear ratios.

  • Converts the driver brake pedal signal to a brake pressure request. The algorithm multiplies the brake pedal signal by a maximum brake pressure.

  • Implements a regenerative braking algorithm for the traction motor to recover the maximum amount of kinetic energy from the vehicle.

The HCM implements an ECMS algorithm2 that optimizes the torque split between the engine and motor to minimize energy consumption while maintaining the battery state of charge (SOC). Specifically, the ECMS:

  • Assigns a cost to electrical energy, so that using stored electrical energy is equal to consuming fuel energy.

    Battery ModeEquivalent Electrical EnergyDescription



    Battery discharges stored electrical energy when the electric machine is in use.



    Battery stores electrical energy from either the:

    • Engine and electric machine acting as a generator.

    • Electric machine acting as a generator during regenerative braking.

  • Is an instantaneous minimization method that the software solves at every controller time step. It can provide near optimal control for a known drive cycle. To implement the strategy at every controller time step, ECMS:

    1. Creates a control torque vector of the driver torque command and full motor torque range.


    2. Checks actuator and battery constraints. Determines if any elements in the control torque vector are infeasible.

      τactuatormin(ω)τactuator τactuatormax(ω)Pbattcharge(SOC)Pbatt Pbattdischarge(SOC)Ibattcharge(SOC)Ibatt Ibattdischarge(SOC)SOCminSOC SOCmax

    3. Calculates and minimizes the equivalent consumption using these equations.


  • Implements either adaptive or non-adaptive ECMS method. The HEV architectures are charge-sustaining, meaning the battery SOC must remain in a specified range because there is no plugin capability to recharge the battery. The battery is an energy buffer, and all energy comes from the fuel if the change in SOC is minimized over a drive cycle. To charge sustain over a specified drive cycle, the reference application implements either of these ECMS methods.

    ECMS MethodDescription

    Non-adaptive ECMS (default)

    Reference application uses a constant equivalence factor.

    • By default, the reference application uses a single constant. You can also use a vector of equivalence factors.

    • Use this method to determine the best fuel economy over a drive cycle.

      • Use an iterative method to find an equivalence factor which minimizes the delta SOC over a drive cycle. If the delta SOC is minimized, you can compare the fuel economy directly to a conventional powertrain. If there is difficulty with charge sustaining over a single drive cycle, simulate the drive cycle cyclically 2 or 3 times.

      • If you change the drive cycle or HEV architecture, retune the equivalence factor.

    Adaptive ECMS

    Reference application adjusts the equivalence factor with the output of PI controller.

    • PI controller minimizes the error between the target SOC and current SOC.

    • Use this method to maintain the SOC and minimize the delta SOC over many drive cycles.

      • Tune the PI controller gains.

      • Robustly sustains the SOC.

The equations use these variables.


Equivalent consumption


Engine power based on fuel flow


ECMS equivalence factor


Multiplicative penalty to assist with sustaining charge


Multiplicative penalty shape function


Electrical power from battery voltage and current


Constraint penalty cost


Engine power rate change cost

SOCtarget, SOCmax, SOCmin

Target SOC, maximum SOC, and minimum SOC, respectively


Torque command

MinMotTrq, MaxMotTrq

Minimum motor torque and maximum motor torque, respectively

τactuator, τactuatormin, τactuatormax

Actuator constraint, minimum actuator constraint, and maximum actuator constraint, respectively

Pbatt, Pbattcharge, Pbattdischarge

Battery power constraint, battery power discharge constraint, and battery power charge constraint, respectively

Ibatt, Ibattcharge, Ibattdischarge

Battery current constraint, battery current discharge constraint, and battery current charge constraint, respectively

Passenger Car

To implement a passenger car, the Passenger Car subsystem contains drivetrain, electric plant, and engine subsystems. To create your own engine variants for the reference application, use the CI and SI engine project templates. The reference application has these subsystem variants.


Drivetrain SubsystemVariantDescription

Differential and Compliance

All Wheel Drive

Configure drivetrain for all wheel, front wheel, or rear wheel drive. For the all wheel drive variant, you can configure the type of coupling torque.

Front Wheel Drive (default)
Rear Wheel Drive

Torque Converter Automatic Transmission

Ideal Fixed Gear Transmission

Configure locked and unlocked transmission efficiency with either a 1D or 4D (default) lookup table.

Torque Converter

Configure for external, internal (default), or no lockup.


Vehicle Body 1 DOF Longitudinal

Configured for 1 degrees of freedom

Wheels and Brakes

Longitudinal Wheel - Front 1

For the wheels, you can configure the type of:

  • Brake

  • Force calculation

  • Resistance calculation

  • Vertical motion

For performance and clarity, to determine the longitudinal force of each wheel, the variants implement the Longitudinal Wheel block. To determine the total longitudinal force of all wheels acting on the axle, the variants use a scale factor to multiply the force of one wheel by the number of wheels on the axle. By using this approach to calculate the total force, the variants assume equal tire slip and loading at the front and rear axles, which is common for longitudinal powertrain studies. If this is not the case, for example when friction or loads differ on the left and right sides of the axles, use unique Longitudinal Wheel blocks to calculate independent forces. However, using unique blocks to model each wheel increases model complexity and computational cost.

Longitudinal Wheel - Rear 1

Electric Plant

Electric Plant SubsystemVariantDescription



Configured with Lithium Ion battery

Electric Machine


Mapped Motor with implicit controller


Engine SubsystemVariantDescription


Dynamic SI Core Engine with turbocharger

SiMappedEngine (default)

Mapped SI Engine with implicit turbocharger


Deep learning SI engine


Dynamic CI Core Engine with turbocharger


Mapped CI Engine with implicit turbocharger


MathWorks® used the SI Core Engine and SI Controller to calibrate the hybrid control module (HCM). If you use the CI Core Engine and CI Controller variants, the simulation may error because the HCM does not use calibrated results.


MathWorks would like to acknowledge the contribution of Dr. Simona Onori to the ECMS optimal control algorithm implemented in this reference application. Dr. Onori is a Professor of Energy Resources Engineering at Stanford University. Her research interests include electrochemical modeling, estimation and optimization of energy storage devices for automotive and grid-level applications, hybrid and electric vehicles modeling and control, PDE modeling, and model-order reduction and estimation of emission mitigation systems. She is a senior member of IEEE®.


[1] Balazs, A., Morra, E., and Pischinger, S., Optimization of Electrified Powertrains for City Cars. SAE Technical Paper 2011-01-2451. Warrendale, PA: SAE International Journal of Alternative Powertrains, 2012.

[2] Onori, S., Serrao, L., and Rizzoni, G., Hybrid Electric Vehicles Energy Management Systems. New York: Springer, 2016.

See Also

| | | | | | | |

Related Examples

More About