Scientists for years have known that the atmosphere of both Neptune and Uranus is a mixture of helium, hydrogen, and small concentrations of methane. Beneath these layers is a dense fluid of materials like methane, water, and ammonia, which also surrounds the core of these planets.

Even more interesting is the fact that in Neptune and Uranus, it's raining diamonds. It may sound like something out of an epic adventure film, but scientists may now have the answer as to why this amazing atmospheric phenomenon happens.

To find out how Neptune came to have diamond rain and how carbon transitions directly into crystalline diamond, researchers used the SLAC National Accelerator Laboratory's Linac Coherent Light Source (LCLS) X-ray laser.

Though Neptune and Uranus are among the most poorly understood planets in the Solar System, planets similar to their composition -- ice giants -- are fairly common in the Milky Way, according to NASA. Decades of research have led scientists to believe that it can rain in both planets, but until now there has not been an explanation as to why this occurs.

Physicist Dominik Kraus at the Helmholtz-Zentrum Dresden-Rossendorf in Germany led an experiment before which used X-ray diffraction to demonstrate this process. But now, he and his team are making a more advanced approach based on X-ray scattering, which will become useful in the discovery of more exoplanets.

By using LCLS and a tool to replicate the conditions inside Neptune at a depth of 6,214 miles, the team was able to create a model that mimicked what goes on inside it to find out how diamonds are formed. Shockwaves were then produced through pulses of optical laser in the polystyrene, heating the material to 8,540 degrees F. This process causes intense pressure of around 1.5 million bars, which according to Kraus is equivalent to the pressure exerted by the weight of 250 African elephants on the surface of a thumbnail.

In Kraus' previous experiment, he used X-ray diffraction to probe the material, particularly those with crystalline structures. In this new experiment, he went on a different route and measured how X-rays scattered off electrons in the polystyrene instead. This is how they were able to observe carbon transforming into a diamond and witnessed the remaining of the sample divided into hydrogen that left no carbon after.

Kraus and his team concluded that there is no alternative explanation as of the moment, and it also presented the idea of probing the interiors of other planets in the Solar System.

The study is published in the journal Nature Communications.