Image copyright Getty Images Image caption Our electric cars could give power back to the grid when necessary

If electric cars really are the future, where is all the electricity to power them going to come from?

There are currently more than a billion vehicles on the road worldwide, 38 million of them registered in the UK. The overwhelming majority run on petrol or diesel.

But the world is changing.

Manufacturers are investing heavily in developing both hybrid and pure electric models to help meet tightening emissions standards.

Towns and cities want to impose restrictions on conventional cars to reduce pollution; and in the long term, some countries, including the UK and France, want to ban them altogether.

Although mass electrification will take time, experts agree the number of electric cars is almost certainly going to increase dramatically over the next few years.

Media playback is unsupported on your device Media caption WATCH: See the new Tesla Semi and Roadster

But will we be able to generate all the electricity that millions of battery-powered vehicles will require?

Here in the UK, National Grid has modelled a number of different scenarios, in an attempt to predict just how much extra power will be needed.

"By 2030 we could see as many as nine million electric vehicles on the road," says the company's energy insights manager, Marcus Stewart.

"That would add around 5% to the annual energy demand on the electricity system. So it's going to add demand, but maybe not as much as you might think."

One reason the anticipated demand isn't higher is because National Grid assumes that so-called "smart charging" will be widespread.

The principle is relatively straightforward.

If millions of people charge their cars at the same time - for example when they come home from work - it will put heavy strain on the grid. But that doesn't have to happen.

Image copyright Tesla Image caption Tesla envisages homes with solar roof tiles, electric cars and wall-mounted storage batteries

Smart chargers will allow vehicles to draw power only when it is readily available, avoiding peak periods, while ensuring that they are fully charged when their owners need them.

"By spreading the load overnight you can immensely vary the capacity needed," explains David Martell, chief executive of Chargemaster, which builds and operates charging systems.

"Going forward, electricity companies will offer different tariffs at different times of day, so that actually, financially it's worth your while doing that kind of thing."

Smart charging, then, could be a useful tool for managing demand when vehicles are parked for hours at a time, either at home or at the workplace.

But the carmaker Nissan is hoping to go a step further.

At the Nissan Technology Centre in Cranfield, Bedfordshire, a number of the company's electric Leaf models are lined up alongside a bank of chargers. But these cars aren't just drawing energy from the grid; they're also putting it back.

Image copyright Nissan Image caption Nissan was involved in the launch of the first vehicle-to-grid hub in Denmark last year

The system is called Vehicle to Grid, or V2G. The Japanese company is developing it in partnership with the Italian power firm Enel and is already operating a small trial hub in Denmark.

Electric cars are, in effect, energy storage devices, and because they spend much of their time parked up not doing anything they can help smooth out the peaks and troughs in energy demand.

"Basically, we can consider the car as a battery with wheels," says Maria Laura Corallini, the engineer in charge of the V2G project.

"You can use the energy storage capability in the battery to provide specific services back to the grid."

The system uses software to regulate the charging level of multiple vehicles.

When the grid needs extra power, it can draw very small amounts from each individual vehicle. When energy is abundant, it can top them up again. Users will get paid for the electricity they provide.

If thousands of cars are connected together, then the amount of energy given back to the grid can be substantial, and it can be varied on a second-by-second basis.

Image copyright Getty Images Image caption An electric car can be seen as "a battery with wheels" in the Vehicle to Grid project

Ms Corallini calls it "a virtual power station".

It is a complicated system, and Nissan has been testing it on a small scale at Cranfield for more than a year.

Initially the plan is to sell it to businesses that operate large fleets, although the company says it will also introduce a residential version. Other organisations are also experimenting with the technology.

Not everyone agrees that V2G makes commercial sense, however. The chief technical officer of Tesla, JB Straubel, for example, has suggested in the past that he doesn't see it becoming a viable solution, largely due to its cost and complexity.

Some experts have suggested it could accelerate battery degradation, although Ms Corallini insists the reverse is true, because the car is maintained in an optimum state of charge.

A recent study by researchers at Warwick University came to a similar conclusion, suggesting V2G technology could increase battery life by up to 10%.

More Technology of Business

Image copyright Getty Images

According to National Grid's Marcus Stewart, both V2G and intelligent charging could encourage the expansion of renewable energy, as well as helping to balance power supply and demand.

"Renewables, particularly solar and wind, don't always generate at the time they are needed the most," he says.

"A battery enables them to be used more effectively and less energy to be wasted, so electric vehicles and renewables work well from that perspective."

Ultimately, if National Grid's forecasts are correct, replacing our petrol and diesel cars with electric versions will add about five gigawatts to peak demand.

It is still a fair amount of energy - more than the output of a modern nuclear power station - but with technologies like smart charging in place, National Grid believes the extra demand can be met from a combination of sources, including renewables and gas generation.

There may be other obstacles to the mass take-up of electric cars - the availability of batteries for example, and the need to invest in charging infrastructure.

But if we manage demand properly, there's no reason why running our cars on electricity should stop us lighting our homes or boiling our kettles.