Skip to main content
emobility.academy
B.Tech / BEVehicle & powertrain modellingBeginner About 4 weeksMATLAB & Simulink

Longitudinal EV Model in Simulink with IDC, MIDC and WLTP Drive Cycles

Build a forward-facing longitudinal EV model in Simulink, with a driver PI controller, road-load forces, motor, gearbox and battery, and run it on IDC, MIDC and WLTP drive cycles to compare energy consumption per kilometre and regenerated energy.

Tools: MATLAB Ā· Simulink

Longitudinal EV Model in Simulink with IDC, MIDC and WLTP Drive Cycles: Electric scooters used for hands-on training at DIYguru
Representative photo from DIYguru's EV lab, not of this specific project.

The problem

Range and energy use are the first questions asked about any EV design, and they depend strongly on the drive cycle. Indian urban driving (IDC, MIDC) is slow and stop-start, while WLTP includes high-speed phases. A transparent road-load model lets a student see exactly where energy goes, and is the foundation for almost every later EV simulation project.

Objectives

  • Derive and implement the road-load equation for rolling resistance, aerodynamic drag, grade and inertia.
  • Build a forward-facing model with a driver controller that tracks a reference speed trace.
  • Model motor torque limits, a constant drivetrain efficiency and a simple battery energy balance including regeneration.
  • Compare Wh/km, peak power and regenerated energy across IDC, MIDC and WLTP.
  • Run parameter sweeps on mass, drag area and rolling resistance with sim() and report sensitivities.

What you need

Tools and toolboxes

  • MATLAB — Parameter scripts, drive-cycle import from CSV, sim() sweeps and plotting.
  • Simulink — The forward-facing vehicle model built from base blocks (Integrator, Gain, 1-D Lookup Table, MATLAB Function, PID Controller).
  • Powertrain Blockset (optional) — Its Drive Cycle Source block can supply standard cycles such as WLTP and FTP-75; the base-Simulink route with From Workspace works equally well.

Software

  • MATLAB R2023b or later
  • Simulink
  • Excel/CSV files for IDC, MIDC and WLTP speed–time data

Extra parts and data

None beyond the software above.

Key concepts

Road-load equation
Tractive force F = m·g·Crr·cosθ + ½·ρ·Cd·A·v² + m·g·sinθ + m·a. Each term can be logged separately to show where the energy goes.
Forward-facing model
A driver controller compares reference and actual speed and commands torque, and the vehicle speed comes from integrating force over mass. It respects actuator limits, unlike a backward-facing model.
Regenerative braking energy
When the motor torque is negative, power flows back to the battery, reduced by drivetrain and motor efficiency and limited by the motor and battery.
Wh/km
Net battery energy over the cycle divided by distance travelled. It is the standard figure for comparing EV consumption across cycles.

Step-by-step guide

  1. 1

    Fix requirements and example parameters

    Write a parameter script for an example compact car: test mass 1500 kg, Cd 0.30, frontal area 2.2 m², Crr 0.010, wheel radius 0.30 m, gear ratio 9:1, motor peak 200 N·m and 80 kW, drivetrain efficiency 0.92, motor efficiency 0.90 and a 40 kWh battery. Label these clearly as example values. Define outputs: Wh/km at the battery, peak tractive power, regenerated energy and speed-tracking error for each cycle.

    Checkpoint: A parameter script that runs without error and a one-page requirements table listing outputs and acceptance criteria.

  2. 2

    Prepare drive-cycle data

    Import the IDC, MIDC and WLTP speed–time traces from CSV with readmatrix, convert km/h to m/s and resample to a uniform 0.1 s grid with interp1. Compute distance by cumtrapz and the maximum and mean speed of each cycle. Store each cycle as a timeseries object for a From Workspace block, or use the Powertrain Blockset Drive Cycle Source block for WLTP if you have it.

    Checkpoint: Computed distance, duration and maximum speed for each cycle match the published values within about 1 per cent.

  3. 3

    Model the vehicle body

    In Simulink, build a subsystem that takes tractive force at the wheel and outputs speed. Compute rolling, aerodynamic and grade forces with Gain and Product blocks, sum them with the tractive force and divide by an equivalent mass that includes a rotating-inertia allowance of about 3–5 per cent. Integrate acceleration with an Integrator block whose lower limit is zero so the car cannot roll backwards on flat ground.

    Checkpoint: With a constant 500 N tractive force, the car accelerates and settles at the speed where drag plus rolling resistance equal 500 N, which you can check by hand.

  4. 4

    Add motor and drivetrain

    Convert wheel speed to motor speed through the gear ratio. Limit commanded torque with a 1-D Lookup Table of maximum torque against speed (constant torque up to base speed, then constant power). Multiply torque by gear ratio and efficiency to get wheel force when motoring, and divide by efficiency when regenerating. Log motor torque, speed and mechanical power with signal logging.

    Checkpoint: A full-throttle run from standstill reaches the expected top speed and the torque trace follows the torque–speed envelope.

  5. 5

    Add the driver controller

    Use a PID Controller block (PI form) acting on speed error to command a normalised torque between āˆ’1 and +1, with anti-windup by clamping. Add a feed-forward term from the road-load equation at the reference speed to reduce lag. Tune Kp and Ki on WLTP until the speed error stays small through the high-speed phase without oscillating at stops. Record the final gains in the parameter script so every later run uses the same driver.

    Checkpoint: Speed tracking error stays within ±2 km/h for most of each cycle, shown on a Simulation Data Inspector overlay of reference and actual speed.

  6. 6

    Model battery energy

    Compute battery power as motor electrical power plus a constant auxiliary load (for example 300 W). Integrate power to energy and compute SOC from usable capacity. Limit regenerative power to a set value and add mechanical braking for the remainder. Use a fixed-step solver (ode4, 0.01 s) or a variable-step solver with a maximum step of 0.1 s; check that both give the same energy within 0.5 per cent.

    Checkpoint: Energy drawn on WLTP gives a consumption in a sensible range for the example car, roughly 130–180 Wh/km at the battery.

  7. 7

    Verify the energy balance

    Log the energy dissipated by each road-load term, by drivetrain and motor losses, by mechanical braking and the kinetic energy at the end of the cycle. Sum them and compare with the net battery energy. Any mismatch above 1 per cent points to a sign error or a missing loss path. Repeat this check on all three cycles before drawing any conclusions.

    Checkpoint: An energy-balance table for each cycle that closes within 1 per cent.

  8. 8

    Compare the three cycles

    Write a script that loops over cycles, sets the From Workspace variable, runs sim() and collects Wh/km, peak power, regen fraction and share of energy spent on each road-load term. Plot stacked bars of energy by term for IDC, MIDC and WLTP. Explain why aerodynamic drag dominates WLTP while inertia and rolling resistance dominate IDC. Keep the script generic so that a new cycle, such as a logged city route, can be added by dropping its CSV file into the cycles folder.

    Checkpoint: Stacked-bar plot and table for three cycles, with regen recovering a larger share of traction energy on the urban cycles than on WLTP.

  9. 9

    Run sensitivity sweeps

    Use a Simulink.SimulationInput array to sweep mass (±20 per cent), CdA (±20 per cent) and Crr (±30 per cent), one factor at a time, and run them with sim() (or parsim if Parallel Computing Toolbox is available). Plot the percentage change in Wh/km against the percentage change in each parameter for each cycle. Compute an approximate sensitivity coefficient from the slope.

    Checkpoint: Sensitivity plots showing, for example, that drag area matters more on WLTP and mass matters more on IDC.

  10. 10

    Report the results

    Write up the model equations, block diagrams, parameter table with sources, verification checks, cycle comparison and sensitivity results. Estimate range for the example 40 kWh pack using 90 per cent usable energy on each cycle and discuss why a single published range figure can mislead. State the limits: constant efficiencies, no thermal effects and a flat road unless grade is added.

    Checkpoint: A report with reproducible scripts, closed energy balances and range estimates for all three cycles.

Testing & validation

  • Cycle distance and duration match the published cycle definitions.
  • Constant-force and full-throttle tests agree with hand calculations.
  • Energy balance closes within 1 per cent on every cycle.
  • Results are insensitive to solver step size (less than 0.5 per cent change).
  • Speed-tracking error stays within a stated band.

Expected results

A reusable Simulink longitudinal EV model with closed energy balances, a cycle-by-cycle comparison of consumption and regeneration on IDC, MIDC and WLTP, and sensitivity coefficients for mass, drag and rolling resistance.

Take it further

  • Replace constant efficiencies with a motor efficiency map.
  • Add a road-grade profile from a real route.
  • Add an equivalent-circuit battery to see voltage sag and its effect on power limits.
  • Compare the forward-facing result with a backward-facing QSS model of the same car.

Viva and review questions

Why use a forward-facing model rather than a backward-facing one?

A forward-facing model includes a driver and respects torque and power limits, so it shows whether the car can actually follow the cycle. A backward-facing model assumes the cycle is followed and computes the required power, which is faster but hides limit violations.

Why does Wh/km differ so much between IDC and WLTP?

WLTP has long high-speed phases where aerodynamic drag, which grows with v², dominates. IDC is slow and stop-start, so rolling resistance and acceleration losses matter more, and a good share of kinetic energy is recovered by regeneration.

How did you check your model was correct?

By hand-calculated constant-force and top-speed tests, by confirming the cycle distances, and by closing the energy balance between battery energy and the sum of all losses within 1 per cent.

What is the effect of solver choice?

Too large a fixed step makes the integration of force and energy inaccurate and can destabilise the driver loop. I compared two solvers and step sizes and confirmed energy changed by less than 0.5 per cent.

Learn it at DIYguru

These DIYguru courses and programmes teach what this project needs.

Related EV projects

All 100 MATLAB & Simulink EV projects