I am a bit confused regarding the nuclear fusion that occurs during star formation. For example, suppose there is a huge hydrogen cloud. It gets more mass and therefore pulls in more and more hydrogen, but it could just do this endlessly and get endlessly big. What causes it to stop growing? Is it because of the heat generated by the huge mass?
This is not meant as a detailed description of how fusion starts in stars: I just want to convince you that it can start, and where the energy comes from to start it.
Let's start with a big ball of hydrogen (and let's assume it's not spinning very fast). There are two things which determine what happens to it:
- it has a lot of mass, and so gravity wants it to get smaller;
- pressure wants it to get bigger.
If we were very careful and built this ball very slowly and carefully we could get to a state where it just sat in equilibrium (so long as it was not too big when bad things famously happen) with pressure just counteracting gravity.
But in fact what happens is that it starts off with quite a low pressure, so gravity wins, and starts making it smaller. What this means is that all the hydrogen atoms start moving down the gravitational potential gradient: they are losing gravitational potential energy. But energy is conserved, so they must be gaining some other kind of energy. And that's kinetic energy: they start moving faster, and bouncing around off each other as you'd expect.
Well, a thing where the atoms have a lot of kinetic energy like this is hot: that's what being hot is. So the ball of gas bargains gravitational potential energy into heat, and starts getting really hot.
Some of this heat -- in fact half of it, thanks to the virial theorem -- gets radiated away into space, but it's a big ball of gas, so its surface area is relatively small compared to its volume, so the rate at which it can radiate stuff away is relatively low. So as it continues to shrink it gets really hot, especially in the centre.
Really hot means that the hydrogen atoms in the centre are moving really fast (they also get ionized so they end up as a plasma). The centre of the ball of the gas also gets really dense as the thing falls in, so the atoms (really, the protons) start being more likely to crash into other protons, and to do so with lots of energy.
If the ball is too small, then eventually the pressure becomes high enough to halt the collapse and then the thing sits there radiating away heat and slowly cooling.
But if the ball is big enough then the centre gets hot and dense enough that some of these collisions have high enough energy that fusion starts. This releases more energy, so the temperature in the centre climbs further, and the protons have more kinetic energy and more fusion happens. It's kind of astonishing that this process settles down at some point to being a star which is stable for millions or billions of yeas rather than causing what you'd naively expect, which is a huge explosion as fusion runs away and blows the thing to bits.
a huge hydrogen cloud, it gets more mass therefor it pulls more and more hydrogen but it could just do this endlessly and get endlessly big.
Yes, it could. This is related to the questions "why is the unviverse homogeneous down to $10^-5$ as seen in the the microwave background radiation?"
Graph of cosmic microwave background spectrum measured by the FIRAS instrument on the COBE, the most precisely measured black body spectrum in nature. The error bars are too small to be seen even in an enlarged image, and it is impossible to distinguish the observed data from the theoretical curve.
The curve is the best fit to the black body distribution, BUT, and it is a big BUT, the graph is the same in every direction of the universe ,where radiation could not travel due to the light cones at that early time, (the time of photon decoupling, see plot below) to set up a thermodynamic equilibrium.
Nine Year Microwave Sky The detailed, all-sky picture of the infant universe created from nine years of WMAP data. The image reveals 13.77 billion year old temperature fluctuations (shown as color differences) that correspond to the seeds that grew to become the galaxies. The signal from our galaxy was subtracted using the multi-frequency data. This image shows a temperature range of ± 200 microKelvin. Credit: NASA / WMAP Science Team WMAP
The second question related to yours is "why there are inhomogeneities below that level?".
The uniformity is modeled by proposing quntization of gravity and and an inflationary period where quantum mechanics homogenizes the universe, with small statistical inhomogeneity, the colered regions in the plot, which become the seeds of concentration of matter.
So your question, within the Big Bang model, is answered by positing that the original energy distribution of the universe was homogenized quantum mechanically. The uncertainty principle in quantum mechanics allows for inhomogeneities which as the universe progresses to hydrogen creation have regions in space with more concentrated mas, which will then attract gravitational more and more mass and generate the clusters of galaxies, galaxies and the present day universe.
I think that the reason it doesn't keep getting bigger and bigger is that once it has enough mass, it starts fusion so it's making photons. Now those photons have momentum so they can collide with the surrounding gas particles and keep them from reaching the star. It's just a wild guess tho.. could be wrong.