# Randomly generating plausible star types for a synthetic galaxy?

I'd like to randomly generate between 1 and 20 million stars for a spiral galaxy resembling our Milky Way. This is of course far fewer than our galaxy (estimated between 150 to 300 billion), but I'd like it to resemble ours in proportion. Generating the locations so that they resemble a spiral pattern was a little challenging from a geometry standpoint, but I think I have that part settled.

Now comes the hard part. I'd like this galaxy to have a plausible mix of the various types/sizes of stars. It won't be a proper simulation (so that there might be close features that shouldn't be near each other) and I'm ok with that. But I'd like to have approximately the right number of neutron stars, singularities, red dwarfs, and giants within this galaxy

Some of these things aren't settled scientifically (how many rogue planets float around in the intergalactic void, or are there any actual quark stars), but many of these it seems like we should have reasonable estimates.

So, what are those? I'm looking for a statistical distribution of stellar masses/radii, color, spectral types, temperatures, etc. Ideally these might vary according to their distance from the galactic center, but I could live without that if it doesn't exist.

Does the information exist to accomplish this? Occasionally I'll find an offhand remark about how some large fraction of the Milky Way is composed of barely visible red dwarfs, or that there are an estimated 100 million neutron stars within MW. But these rarely provide hard numbers/ratios.

• What is the purpose of this exercise? Is it for a computer game or a story where you can claim "artistic license", or science/education project, where you have to stick with the best science available? Jan 31, 2020 at 20:16
• @Alexander A Master-of-Orion (game) clone. With 4byte integers/fixed, I can have a 4 million LY extent, that's room for maybe two or three nearby galaxies, with a resolution down to the thousandth-of-a-lightyear. 12 megs storage for the XYZ coordinates is pretty cheap now days. Even with planets and other features, it'd be under a gig for all the data. Would be multiplayer, online... so even if the generation time is relatively slow wouldn't have to do it very often, potentially only once. Feb 1, 2020 at 20:30

This has actually been an area of intense research for decades now. Astronomers are quite interested in the distribution of stellar masses in a variety of different galaxies and clusters. The precise mix you're going to get of course depends on the environment you choose; galaxies with higher metal contents will produce stars with higher metallicities. In general, however, you can take your pick of different initial mass functions, or IMFs. An IMF is a function that tells you what fraction of stars have a mass between $$m$$ and $$dm$$, where $$dm$$ is some step size.

As an example, take the famous Salpeter IMF - one of the first created. The Salpeter IMF has the form $$\phi(m)dm=\phi_0m^{-2.35}dm$$ Therefore, if you have a given stellar population, the fraction of stars with a mass between $$m_1$$ and $$m_2$$ is $$f(m_1,m_2)=\int_{m_1}^{m_2}\phi(m)dm=\int_{m_1}^{m_2}\phi_0m^{-2.35}dm$$ Here, $$\phi_0$$ is a normalization constant.

The Salpeter IMF is a simple one, and it's great as a toy model. More realistic IMFs, like the Kroupa IMF (which is quite commonly used), are piecewise functions. They're also power laws, but the exponent is different over several different mass ranges.

If you want to play around, I've put some code on GitHub to let you play around with a couple IMFs (and generate stellar populations on your own, with some randomness thrown in). Here's a comparison of how stellar masses are distributed, according to the two IMFs I discussed above. The $$y$$-axis shows the fraction of stars $$f( with a mass less than $$m$$:

$$200M_{\odot}$$ is kind of an arbitrary upper limit, but in reality any population you synthesize will contain only a tiny, tiny number of stars with masses above $$100M_{\odot}$$. $$0.08M_{\odot}$$ is a realistic lower choice - it's the boundary between stars and brown dwarfs.

How do these stack up against L.Dutch's numbers? Using some stellar mass range tables, I found that the Salpeter IMF predicted 93.1% M stars, 3.03% K stars, and 0.926% G stars; The Kroupa IMF predicted 68.1% M stars, 13.6% K stars, and 4.2% G stars. The Kroupa model appears to be more realistic - as you might expect; after all, Salpeter came up with his IMF in 1955!

A couple things to bear in mind:

• The IMF only tells you the initial distribution of a population of stars. Stars of different masses age at different rates, so over time, as massive stars die, the population will skew towards lower masses. You arguably need to evolve your population over time - computationally expensive, even for basic toy approximations.
• This model assumes only one burst of star formation; in reality, most galaxies are continuously forming stars at different rates.
• As I said at the beginning, mileage may vary depending on your galactic environment. Using an IMF based on conditions in the Milky Way should give you a Milky Way-like population.

Right today NASA, on its daily APOD, has posted the following image

accompanied by the following caption

The Goldilocks zone is the habitable zone around a star where it's not too hot and not too cold for liquid water to exist on the surface of orbiting planets. This intriguing infographic includes relative sizes of those zones for yellow G stars like the Sun, along with orange K dwarf stars and red M dwarf stars, both cooler and fainter than the Sun. M stars (top) have small, close-in Goldilocks zones. They are also seen to live long (100 billion years or so) and are very abundant, making up about 73 percent of the stars in the Milky Way. Still, they have very active magnetic fields and may produce too much radiation harmful to life, with an estimated X-ray irradiance 400 times the quiet Sun. Sun-like G stars (bottom) have large Goldilocks zones and are relatively calm, with low amounts of harmful radiation. But they only account for 6 percent of Milky Way stars and are much shorter lived. In the search for habitable planets, K dwarf stars could be just right, though. Not too rare they have 40 billion year lifetimes, much longer than the Sun. With a relatively wide habitable zone they produce only modest amounts of harmful radiation. These Goldilocks stars account for about 13 percent of the stars of the Milky Way.

To summarize:

• G star type: 6%
• K star type: 13%
• M star type: 73%
• Wow, thank you! I think I can work with this. Jan 31, 2020 at 18:09
• G through M type stars only account for 92% of stars in the Milky Way. Are there resources for determining the distribution of high-mass stars among the other 8%? Jan 31, 2020 at 19:00