WALNUT CREEK, Calif. – California must be fully electrified 40 years from now, with residents driving only electric cars and plugging them into a grid powered by carbon-free power plants, if the state is to meet its most far-reaching climate goals, according to a new study.

Not only will electricity be carbon-free, California will need a lot more of it to make up for the loss of gasoline, natural gas and coal.

The equivalent of 1½ to 2 nuclear power plants would have to be built each year between now and 2050 to meet the growing electricity demand, said study co-author Margaret S. Torn, a biogeochemist at the Lawrence Berkeley National Laboratory.

The study, published Friday in the journal Science, is the first peer-reviewed analysis of how a large economy can meet ambitious greenhouse gas reduction targets using detailed models of power grids, available resources and infrastructure, Torn said.

State law calls for reducing greenhouse gas emissions by 2020 to 1990 levels. But the law also sets a goal of cutting emissions 80 percent more by 2050.

Friday’s study found that meeting that long-term goal is possible and does not require major technological or behavioral breakthroughs. But it will require a lot of innovation and investment, Torn said.