As computers continue to develop and grow, so do the things they’re capable of; just about any laptop capable of playing FarmVille can also run a sophisticated astrophysics simulation. In college, it took me a few minutes with a room-sized supercomputer to derive the Chandrasekhar Limit. The same derivation can now run in JavaScript, embedded in a web page, in a fraction of a second.
The Science
I’m recreating a study I did several years ago in college on the Chandrasekhar Limit. This limit is the absolute mass a star can possess to end its life as a white dwarf – anything heavier will instead collapse into a neutron star or, if sufficiently large, a black hole.
Stellar Structure
Every star in the sky obeys the same four physical laws:
- Hydrostatic Equilibrium – the force of gravity pushing in balances the pressure pushing out
- Energy Transport – energy moves from hot to cool
- Conservation of Mass – the total mass is equal to the sum of the mass of all composite layers
- Conservation of Energy – the total energy is equal to the sum of the energies of composite layers
The variables above:
- – Pi
- – the pressure of a layer of the star
- – the gravitational constant typical in stellar calculations
- – the density at a particular point in the star relative to its center
- – the distance from the center of the star to the point above
- – the energy of the star
- – the star’s luminosity
- – the charge of an electron
- , , – constants dictating the energy of a star. .
The Death of Stars
All stars are initially composed of the same material: hydrogen. The difference is in the amount of hydrogen present. Some of the smallest stars[ref]Red dwarfs typically have a mass below ~0.4 time that of our sun.[/ref] are called red dwarfs. Due to their small size, mass, and temperature they can burn for a long time without running out of fuel.
Larger stars progress on to the next stage of stellar evolution. After the hydrogen fuel in a star is completely exhausted, the star will expand into a giant and begin to burn the helium that is left over.
The giants fuse this helium in their cores. Generated by enormous heat and pressure, a core of carbon and oxygen builds up with helium fusion taking place in a shell surrounding it. Continued helium fusion adds carbon to the star’s core, forcing more contraction, heat, and fusion – leading also to the star’s expansion.
Sometimes the outer layers of the star are driven away to create planetary nebulae – the Ring Nebula is a great example. The core of a smaller star becomes a stellar corpse – what we call a “white dwarf” because of its high temperature and small size.
Electron Degeneracy
Each atom has electron orbitals that can have, in the 1s and 2s orbitals, at most two electrons or, in the 2p orbital, at most six electrons. Electron degeneracy[ref]The Pauli Exclusion Principle is the theory that there are only so many differences between electrons and no two electrons can occupy the same point in space if they are identical.[/ref] is responsible for sustaining a white dwarf against its own gravity. Identical electrons in the matter that makes up a white dwarf will push against each other, preventing the star from collapsing.
Equation of State
A white dwarf with low mass has a low pressure, thus its electrons can be treated non-relativistically. In this case, the equation of state defining the relation between pressure and density is rather simple.
In most cases, μe, the mean molecular weight per electron, is about equal to 2. This equation can then be used in conjunction with four equations above to generate a rough computer model of the structure of a white dwarf.
Under higher pressures, electrons are moving around so rapidly that they need to be treated relativistically. Broken into several steps, the equation of state becomes:
Once again, μe is about equal to 2. In this system, the pressure-density relation approaches the non-relativistic relation when x (and thus P) is small. Relativity will affect the equation for hydrostatic equilibrium as well:
The Code
Euler’s Method
Due to the complexity of the equations above, we use Euler’s Method to approximate the integral. We simulate several stars with varying initial densities. For each star, we’ll start in the center, then take a small step towards the outer radius and make an estimation, followed by another step, and another. This will continue until the density of the star drops far enough that we can call it zero.
Once we reach this point, we’ll have both a mass for the star – the total mass of all the layers we just estimated – and a radius – the point at which we just stopped.
Why JavaScript?
The original code for this simulation was written in Fortran. Fortran is old and requires an environment that’s largely inaccessible to modern developers.
JavaScript, however, is accessible to everyone who has a web browser. Unlike Fortran, it requires no compilation, is continuously being developed by the community as a whole, and there is a plethora of resources available online to learn to use it.
The Simulation
To make things efficient, the code below is broken up into two parts – one object-oriented, one procedural. Take a second to read through the code, then I’ll explain each part:
Everything is contained inside a closure so we don’t have too many objects floating around in the global scope. Within the closure, we define a handful of global constants, a single object for modelling a star, and a set of loops for running the simulation.
The Dwarf object accepts initial values for , , and – these define the conditions at a point near the center of our simulated star.
Our first for loop will create a total of 50 simulated stars, in order, with various initial central mass densities. It then calculates the mass of the star with that density near its center and instantiates a Dwarf object (flagging that we want to use a classical, non-relativistic model).
The first while loop will tell the Dwarf object to start stepping outwards from the center of the star, using Euler’s Method to calculate the changes in mass, radius, and density as it goes. When we reach a point where the density is sufficiently small, we move on.
The next while loop does exactly the same thing, except assuming a relativistic model for calculating the changes in the star’s internal conditions.
Finally, we add the mass and radius of each star to two arrays exported to window.dataset. All of this happens in less than a second on the average modern home computer.[ref]The same simulation, in Fortran, took over an hour to run on the laptop I had in college. Even on the college mainframe system, it would take at least two minutes to loop through the various integration steps involved.[/ref]
Results
The Chandrasekhar Limit is a well-known constant with an accepted value of about (about one and a half solar masses). This means any star heavier than will not collapse into a white dwarf but will instead become a neutron star – or if sufficiently massive, a black hole – at the end of its life.
The relationship between mass and radius is plotted on the chart below (solar masses on the x-axis, solar radii on the y-axis):
[chanda_plot]
Conclusion
Studying astrophysics often involves complex mathematics and computer models to make sense of the world around us. In the past, this involved archaic programming syntax, specialized equipment, and development environments with significant learning curves. The astrophysics of today, however, is accessible to anyone with a computer and a web browser.
In fact, if you’re seeing the charts above, it means you just executed this very astrophysics simulation. In your own browser. In real time.