N-Body Simulation
Instead of studying for my English and Chemistry final, I jump-started my first Astrophysics Project. When deciding what the project would be, I asked Mr. GPT for a good first project. The coolness factor of an N-Body Simulation got me!
This project used VPython to model how a group of stars moves under their mutual gravitational attraction. I created 50 stars with random starting positions within a 3D region, gave each star an equal fraction of the system’s total mass, and assigned them initial momentum based on a small angular velocity, so the system would exhibit rotational motion.
Theoretically, this simulation is explained by Newton’s Law of Universal Gravitation, except in this case, there are 49 gravitational forces acting on each individual star.
The simulation calculates the gravitational force between every pair of stars, using a small softening length to prevent unrealistically huge forces when stars get too close. Then, using Euler integration—I have no idea what that means, but I know it runs my program—it updates each star’s momentum and position over time, allowing the viewer to watch the system evolve dynamically in 3D.
Pretty cool first project! It gave me a taste of what’s possible when I combine my curiosity of Astrophysics with the content I learn in class—CS1 and XL Physics.
Onto the next!