Jupyter notebook PHY213 Coursework/stellarinteriors.ipynb
Modelling Stellar Interiors: Jupyter Notebook
Defining the Dimensionless Lane-Emden equation as: Where using the Chain rule expands the equation to give: As this can't be solved analytically, we need to consider what happens at the step, and how it compares when at position , leading the equation: Where is a known step value, as well as also being known.
At position :
In which all quantities on the Right Hand Side (RHS) are known, and hence can be calculated using numerical integration.
Writing the function to solve the Lane Emden Equation
Theta intercepts of the Lane Emden graph
The theta intercept when n=5 is , hence it cannot be calculated through linear interpolation like the other intercepts.
Comparison to the Sun:
SSM data
In order to test which polytropic index is the most accurate when compared to the Sun, the dimensionless radius and density must be converted back into their real quantities.
Starting with the equation of mass conservation: Re-arranging to calculate what the mass of the star is in integral form: As the value of r can be rewritten as , so at the surface , therefore: Therefore: Where is known, and and can be calculated.
Using the average density of the sun: When re-arranged for
With this the central density can be calculated as all the values are known. The value of is equal to the x-intercept of the xi, theta graph for each value of n.
As is able to be calculated, the value of can be calculated using , and hence a graph of log against radius (in units of solar radii) can be plotted.
Constants and calculating r/R_sun
Mass and Density
Plotting for Density and Mass
Pressure and Temperature
Using the Polytropic equation of state: Where K is a known constant from the definition of : Hence a value of K can be calculated for each value of n, which can then be used to calculate values of the internal Pressure (P) of the star, which was graphed against radius in solar radii