24-hour Simulation of a Vehicle-to-Grid (V2G) System

This example shows a vehicle-to-grid system used to regulate the frequency on a microgrid when events occur during a full day. The phasor mode of Simscape™ Power Systems™ allows a fast simulation of a 24 h scenario.


The microgrid is divided into four important parts: A diesel generator, acting as the base power generator; A PV farm combined with a wind farm, to produce renewable energy; a V2G system installed next to the last part of the system which is the load of the grid. The size of the microgrid represents approximatively a community of a thousand households during a low consumption day in spring or fall. There are 100 electric vehicles in the base model which means that there is a 1:10 ratio between the cars and the households. This is a possible scenario in a foreseeable future.

Diesel Generator

The diesel generator balances the power consumed and the power produced. We can determine the frequency deviation of the grid by looking at the rotor speed of its synchronous machine,.

Renewable Energy

There are two sources of renewable energy in this microgrid. First, a PV farm produces energy proportional to three factors: the size of the area covered by the PV farm, the efficiency of the solar panels and the irradiance data. Second, a simplified model of a wind farm produces electrical power following a linear relationship with the wind. When the wind reaches a nominal value, the wind farm produces the nominal power. The wind farm trips from the grid when the wind speed exceeds the maximum wind value, until the wind gets back to its nominal value.


The V2G has two functions: Controls the charge of the batteries connected to it and uses the available power to regulate the grid when an event occurs during the day. The block implements five different car-user profiles:

  • Profile #1: People going to work with a possibility to charge their car at work.

  • Profile #2: People going to work with a possibility to charge their car at work but with a longer ride

  • Profile #3: People going to work with no possibility to charge their car at work

  • Profile #4: People staying at home

  • Profile #5: People working on a night shift


The load is composed of residential load and an asynchronous machine that is used to represents the impact of an industrial inductive load (like a ventilation system) on the microgrid. The residential load follows a consumption profile with a given power factor. The asynchronous machine is controlled by a square relation between the rotor speed and the mechanical torque.


The simulation lasts 24 hours. The solar intensity follows a normal distribution where the highest intensity is reached at midday. The wind varies greatly during the day and has multiple peaks and lows. The residential load follows a typical pattern similar to a normal household consumption. The consumption is low during the day and increases to a peak during the evening, and slowly decreases during the night. Three events will affect the grid frequency during the day:

  • The kick-off of the asynchronous machine early at the third hour

  • A partial shading at noon affecting the production of solar power

  • A wind farm trip at 22h when the wind exceeds the maximum wind power allowed


Run the example model and observe different signals from the scopes in the model. It is possible to observe the rotor speed behavior in the scope on top of the model.

By clicking on the Scopes and Power measurements subsystem, it is possible to access information from various nodes. The state of charge of each car profile is also available in that subsystem. A negative value of state of charge means that the car is on the road or not pluqged.

Was this topic helpful?