Lab 06 - Jay1337/computational_physics GitHub Wiki
Goal
In this lab our goal was to model planetary motion, and more specifically Earth's motion around the Sun. In order to do so we wanted to use the Euler-Cromer method, and Euler method for our setup, and with this setup we wanted to be able to adapt it for any two body system like other planets. We also aimed to be able to describe Earth's motion and how changing its velocity affects it and relates it to Kepler's first and second law.
Overview
This is a lab predicated on being able to understand and describe planetary motion. Through understanding planetary motion we used python in order to model circular or elliptical orbits, and through a model we highlighted the comparison between the Euler-Cromer method and the standard Euler method for updating the system’s state over time. When analyzing our planetary motion models for Earth's motion around the Sun it was seen that Kepler’s 1st Law that the orbits are ellipses, with circles being a special case, and Kepler’s 2nd Law that the planet moves faster when it is closer to the Sun and slower when it is farther away was reinforced. It was seen that the velocity value affects the orbital shape, and with the right velocity the orbit is circular and features constant radius and speed with deviations from this value produce elliptical orbits. Through this code which implements clear functions and uses visual plots to interpret the data, we gain an understanding of both the mathematical modeling and the physical principles that affect planetary motion, as well as showing how initial conditions affect orbital motion.
Part 1
In part 1 in order to model planetary motion we first had to allocate arrays for time, position (x and y), and velocity (vx and vy), as well as set the initial conditions for position and velocity.
Part 2
This next part was needed in order to define a function which computes the radial distance from the Earth to the Sun.
Part 3
Here we needed to calculate the Euler-Cromer method and Euler method through updating the position and velocity arrays using cromer=True for updating the position and velocity based on Euler-Cromer method and when cromer=False which updates position and velocity arrays based on Euler method.
Part 4
This parts defines a function which makes three plots, a scatter plot of the orbit (y vs. x) with points color-coded by time, plot of the x and y positions versus time, along with the calculated radial distance, and plot showing the x and y components of velocity along with the total speed.
Part 5
Lastly we need this part in order to make a main function which calls our initialize, then calculate, and finally make_plots functions to visualize the results. This main function returns the computed arrays, enabling further analysis of the simulation results, and allows us to modify our velocity by channing initial conditions, which helps us see the stability of the orbital model as well as letting us be able to describe planetary motion.