system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: In a few billion years when the sun expands and grows into a red giant, how fast will it expand and "swallow" the inner planets?
gpt
The sun is expected to last another 5.4 billion years before the hydrogen in the core runs out. 

When that happens, the core will start to collapse in on itself due to its own gravity, and will increase in temperature. This allows for hydrogen fusion outside the core to happen (the strong temperature gradient doesn’t allow the layers outside the core to mix with the core and supply more hydrogen to maintain it; the core needs to grow in size for the next step) This is when the sun enters the subgiant phase. 

In the subgiant phase, the core is having a battle with itself. On one hand, it’s so dense and heavy that it wants to collapse in on itself. But at the same time, it’s way too hot to make that possible (heat makes atoms move faster, so it’s harder to get them to collect at a single point). At this point, the core gets so hot, that even outside the core it gets hot enough for hydrogen to fuse. Hydrogen that fuses turns into heavier helium which then grows the core a little again (the boundary of the core isn’t very exact). The energy that’s produced in this process pushes the outer shells of the sun farther out. The sun grows to roughly three times it size, becomes a little dimmer as the same amount of energy is spread out over a larger outer surface to radiate off. This is called the subgiant state and this state lasts for about 2 billion years for our sun. 

After the sun has been a subgiant for a good long while, suddenly an event happens: the core does no longer contract. This is called core degeneracy. At this point, the repulsive force of the electrons around the helium nuclei give enough backpressure that gravity can no longer collapse the core any further. So now all the energy being fused around the edge of the core can’t go anywhere, what now? The sun starts to grow in size tremendously, growing to 100x it’s current size. Lots of hydrogen is fused into helium at the edge of the core and a lot of energy is convected to the outer layers of the sun. The sun becomes a lot more luminous, too. This is the first red giant phase, and lasts about 100 million years. 

As the core continues to gain more mass, slowly but surely it eventually reaches a point where the core reaches 100 million Kelvin, at which the core finally can start back up again, fusing helium into carbon. This happens in an impressive explosive called the helium flash. In a matter of minutes, most helium in the core is converted into carbon, releasing a tremendous amount of energy. Because of this energy, gravity is overcome and the core expands again. The star decreases in size to around 10 times the size it is today in a very short period and it stays this way for about 50 million more years, while it fuses helium into carbon in the core. 

When the helium is all used up and the entire core is made of carbon, the core once again goes into hibernation and something like the earlier red giant phase happens again. The core starts to collapse again and becomes hotter. Now there are two layers around the core, the inner layer is so hot that helium is fused into carbon, and the outer layer is fusing hydrogen into helium again. As this happens, a lot of energy is produced that’s not going in the core, but is used to expand the sun again. 

The sun now finally enters the real red giant phase, in which it grows to about 250x it’s size today. This is the point where the Earth may very well be taken up by our sun. This phase lasts about 20 million more years, in which the instability of the sun will make the sun pulsate, throwing off enormous amounts of its outer shell material until finally, the hot carbon core becomes visible, at which point we consider the sun to no longer be a red giant, but a white dwarf. The white dwarf is still tremendously hot and it radiates a lot of high energy UV light. This UV light pushes and illuminates the old outer shell that’s veered off into space, and that creates a planetary nebula. 

So, when and how fast will the planets be consumed? Mercury should be seriously concerned in the first growth. That’s in about 7.4 billion years. We have another 150 million years roughly until we’re finally taken into the outer edges of our sun. Which is really no time at all in astronomic terms. 

Better enjoy the sun the way it is today while it lasts.