Although the aim of this project is to develop a numerical algorithm that permits you to construct the relativistic structure of a spherical polytrope, it is strongly recommended that you begin by developing a numerical algorithm that lets you build a nonrelativistic (i.e., a Newtonian model of a) polytrope. I suggest that you use an n = 1 polytropic equation of state because we know what the correct answer is, analytically.
Begin by constructing two arrays: One labeling the star's internal radial zones and the other labeling the star's mass density in each of those zones from i = 1 at the star's center to i = imax = 100 (say) at the star's surface. Then, set r1 = 0.0; rimax = 1.0; and ri = (i-1)/(imax-1), and "guess" that in every zone, rhoi = 1.0.
Now, determine how much mass M(ri) is contained interior to each radial zone. For example, M1 = 0; M2 = (4/3) p r1(r2)3; M3 = M2 + (4/3) p r2 [(r3)3 - (r2)3]; etc.
Then, determine the pressure at each radial zone by converting the hydrostatic balance equation into a finite-difference expression of the following form:
Now, in general this central pressure will not be the correct value, so you have to "guess" a new density distribution and, from it, calculate a better set of M(r) and P(r). The new "guess" for the density distribution should be gotten from the derived pressure distribution, through the equation of state:
ri = [Pi/P1](n/(n+1))
Keep iterating on this density/pressure distribution until the solution does not change very much from iteration cycle to iteration cycle.
Required: Show that your density distribution (and central-to-mean density ratio) and total mass match the values that are gotten from a solution of the Lane-Emden equation.
Further comments to help with comparison to analyic results.
Part II: Relativistic Polytrope
In connection with the relativistic structure of a spherical, compact star, The following is an excellent reference that is accessible via the web:This reference quickly summarizes the task at hand, referring to it as the "TOV Solutions," because this problem was first addressed by Tolman, Openheimer, and Volkoff back in the 1940s. For the details, you need to download a large postscript file (that is referred to as the "report" in the above web page): The most relevant section is section 4.5.3, beginning on p. 46 of this postscript file.
Most of the basic elements of the principal set of equations are also presented by Padmanabhan, in his Vol. I chapter on General Relativity. See specifically eq. (11.157) on p. 541 of Vol. I. It shows that the statement of hydrostatic balance is as follows: