Scientists at MIT and Harvard University have devised a way to store solar energy in molecules that can then be tapped to heat homes, water or used for cooking.

The best part: The molecules can store the heat forever and be endlessly re-used while emitting absolutely no greenhouse gases. Scientists remain a way’s off in building this perpetual heat machine but they have succeeded in the laboratory at demonstrating the viability of the phenomenon called photoswitching.

“Some molecules, known as photoswitches, can assume either of two different shapes, as if they had a hinge in the middle,” MIT researchers said in statement about the paper published in the journal Nature Chemistry. “Exposing them to sunlight causes them to absorb energy and jump from one configuration to the other, which is then stable for long periods of time.”

To liberate that energy all you have to do is expose the molecules to a small amount of light, heat or electricity and when they switch back to the other shape the emit heat. “In effect, they behave as rechargeable thermal batteries: taking in energy from the sun, storing it indefinitely, and then releasing it on demand,” the scientists said.

The researchers used a photoswitching substance called an azobenzene, attaching the molecules to substrates of carbon nanotubes. The challenge: Packing the molecules closely enough together to achieve a sufficient energy density to generate usable heat.

It appeared that the researchers had failed when they were only able to pack fewer than half the number of molecules needed as indicated by an earlier computer simulation of the experiment.

But instead of hitting a projected 30 percent increase in energy density, they saw a 200 percent increase. It turned out that the key was not so much packing azobenzene molecules tightly on individual carbon nanotubes as packing the nanotubes close together. That’s because the azobenzene molecules formed “teeth” on the carbon nanotubes, which interlocked with teeth on adjacent nanotubes. The result was the mass needed for a usable amount of energy storage.

That means different combinations of photoswitching molecules and substrates might achieve the same or greater energy storage, according to the researchers.

So how would molecular solar storage work if the technology can be commercialized? Timothy Kucharski, the paper’s lead author and a postdoc at MIT and Harvard, told The Atlantic that most likely the storage would take a liquid form, which would be easy to transport.

“It would also enable charging by flowing the material from a storage tank through a window or clear tube exposed to the sun and then to another storage tank, where the material would remain until it's needed,” Kucharski said in an email. “That way one could stockpile the charged material for use when the sun's not shining.”

The paper’s authors envision the technology could be used in countries where most people rely on burning wood or dung for cooking, which creates dangerous levels of indoor air pollution, leads to deforestation and contributes to climate change.

“For solar cooking, one would leave the device out in the sun during the day,” says Kucharski. “One design we have for such an application is purely gravity driven – the material flows from one tank to another. The flow rate is restricted so that it's exposed to the sun long enough that it gets fully charged. Then, when it's time to cook dinner, after the sun is down, the flow direction is reversed, again driven by gravity, and the opposite side of the setup is used as the cooking surface.”

“As the material flows back to the first tank, it passes by an immobilized catalyst which triggers the energy-releasing process, heating the cooking surface up,” he adds.

Other versions of such device could be used to heat buildings.

Kucharski said the MIT and Harvard team is now investigating other photoswitching molecules and substrates, “with the aim of designing a system that absorbs more of the sun's energy and also can be more practically scaled up.”

Todd Woody is an environmental and technology journalist based in California. He has written for The New York Times and Quartz, and was previously an editor and writer at Fortune, Forbes, and Business 2.0.