top of page

Modeling the Universe (ASTR 4260)

Keywords:

#Hydrostatic       #Equilibrium       #Astrophysics       #Python

As part of a hands-on course in scientific computing for astronomy, I completed a series of coding-based projects that introduced key numerical methods such as integration, root finding, model fitting, and machine learning, all through the lens of astrophysical problems. The course culminated in a final project where I modeled the internal structure of a main-sequence star using the equations of stellar hydrostatic equilibrium, numerically solving a system of coupled differential equations.

mu2.png
mu1.png

 Course & Projects

Throughout the course, we worked on a series of small projects using Python to explore computational techniques in astrophysics. These included simulating planetary structures, solving orbital N-body problems, fitting transit data, and exploring machine learning in astronomy. Each problem set built foundational skills in numerical analysis and scientific modeling, with an emphasis on clear, reproducible code managed via GitHub.

For the final project, I chose to explore solving the stellar structure equations to simulate how mass, pressure, temperature, and luminosity vary with radius inside a star. The goal was not just to produce internal profiles, but to connect the model outputs to observable properties like surface temperature and luminosity.

Hydrostatic Equilibrium 

The core of the project was solving the coupled differential equations that govern a star's internal structure, describing how pressure, temperature, density, and luminosity evolve with radius. Each equation posed its own challenges: for instance, modeling pressure required incorporating multiple contributions (ideal gas, radiation, and degeneracy pressure), while the temperature profile depended on whether radiative or convective heat transfer was dominant.

To solve the system efficiently, I implemented an adaptive Runge-Kutta method for numerical integration. I built the entire model within a Python class, which allowed for clean parameter management and modular testing. Despite early attempts at modularizing the code with separate files, I found that using a class structure dramatically improved performance, with results generated in seconds compared to failed runs that took over an hour.

Visualizing Stellar Profiles

Once the numerical solutions were complete, I plotted the variation of stellar parameters with radius and also experimented with polar coordinate visualizations to capture the radial distribution more intuitively. While my attempt to automate the generation of a full HR diagram by varying initial central temperatures and densities proved challenging, I manually tested different values to show how stars of different types would appear on the diagram. These plots illustrated how the interior equations aligned with observed trends, for example, temperature and pressure decreasing outward, and luminosity increasing with mass.

You can view all the codes including my final project in this repository: TBD

bottom of page