CSCI 150 - Lab 2 - Kepler and Newton

CSCI 150 - Lab 2
Kepler and Newton


Overview

In this lab you will write a program to help the user explore Kepler's Third Law of Planetary motion, using both Kepler's original equation and Newton's reformulation. This will give you practice writing, testing and maintaining simple Python programs that follow the Python style guide.

Materials

Description

A first step in searching for intelligent life elsewhere in the universe is to find other planets that may harbor life. While much time is being spent to analyze the closest possibility of Mars, researchers have made progress in recent years toward finding planets outside our solar system orbiting other stars. The first few of these extrasolar planets found were as large or larger than Jupiter with wildly eccentric orbits, however as our methods of detection become more precise we are starting to find Earth-sized planets that may provide a good foundation for life. In this lab we'll discuss planetary motion in general and apply our computing skills to study various exoplanets.

Step 0: Getting started

Open PyCharm and create a new project (by going to the "File" menu and selecting "New Project"). Name it something like "Lab 01 - Kepler and Newton". Accept the other defaults and click "Create".

At this point you will have a new, empty project. Each project can contain multiple Python files. To create a new Python file, you can either choose "New..." under the File menu, or right click on the project folder and select "New...". Make sure you select "New Python File". Then you can type in a name for the file. Note that you should not include .py on the end of the name; PyCharm will add .py for you.

Kepler

One astronomer who made a major advance in the understanding of our solar system and astrophysics in general was Johannes Kepler. In fact, NASA launched a satellite to search for habitable planets in 2009, and has named this mission after Kepler. In the early 1600s he published his now-famous three laws of planetary motion. These laws, based on years of stellar and planetary observation by Tycho Brahe, finally fixed any lingering anomalies in the Copernican theory that the Earth and other planets revolved around the Sun. The first law states that the planets orbited the Sun in ellipses with the Sun at one foci. The second law states that planets would travel faster the closer they are to the sun and slower when farther away.

The third law describes the relationship Kepler observed between a planet's distance from the sun and the time it takes to make one complete orbit around the sun. Kepler stated that the square of a planet's orbital period in years was equal to that planet's distance from the sun in Astronomical Units (AU) cubed, where and AU is the average distance of the Earth to the Sun (149 million kilometers).

Kepler's Third Law of Planetary Motion

Step 1

Create a Python program called orbit_kepler.py for Kepler's Third Law of planetary motion. (Remember that you should not type the .py part; PyCharm will add it for you.) This program will ask the user for the name of the planet and its orbital period in years. It should then calculate the average distance from the sun in astronomical units (AU) of this planet and display the result to the user. Make sure to follow the Python Style Guide when writing your program.

Test your code with the following values for planets orbiting the Sun:

Table 1: Planets and their Orbital Period

PlanetPeriodAU from Sun
Earth11
Saturn29.6609747482489619.58201720
Mercury0.240841733591790980.38709821

Newton

In 1687, Isaac Newton followed up on the laws of Kepler to publish his Principia Mathematica. In this work, he explained that it was the universal force of gravity which tied together the motion of the planets and the motion of objects here on Earth. Kepler's third law was found to be a special case of a more general law about the gravitational attraction between two objects in space, M1 and M2. Now, instead of Kepler's law being tied to the Earth and the Sun, we can now calculate the orbital period of any planet around any star as long as we know both their masses and the average distance of the star from the planet.

Newton's Revised Law of Planetary Motion

The big G in Newton's equation is the Gravitational Constant from physics, and is in terms of meters cubed over kilograms times seconds squared.

Step 2

Revise your program orbit_kepler.py into orbit_newton.py to use Newton's reformulation of Kepler's Third Law. The user will be asked to enter the name of the planet, the orbital period of the planet in days, the mass of the star in kilograms, and the mass of the planet in kilograms. Your formula requires the period in seconds, you will need to convert your input. Calculate the distance of the star from the planet next, and output the result to the user. Since Newton's law uses meters instead of AU, you will have to convert the output into the appropriate value, using the definition of 1 AU as 149 million kilometers.

Evaluate orbit_newton.py using the following data, based on the best estimates we have about recently discovered exoplanets that may fall into the Habitable Zone for life. Report your results for the orbital period of these planets in the Lab Evaluation described below.

Table 2: Promising Exoplanets

PlanetOrbital Period in DaysStar Mass in kgPlanet Mass in kg
Gliese 667 C c28.1436.1659 * 10^292.2693 * 10^25
Proxima Centauri b11.1862.4459 * 10^297.5852 * 10^24
Kepler 22 b289.861.9293 * 10^303.1532 * 10^26
HD 40307 g197.81.4917 * 10^304.891 * 10^25
Gliese 163 c25.6317.956 * 10^294.359 * 10^25
Gliese 581 d66.876.1659 * 10^292.2693 * 10^25
Kepler 452 b384.8432.0626 * 10^302.986 * 10^25

Hint: your answer for Gliese 667 C c should be close to 0.1. If you are getting an answer in the billions, or billionths, or anything like that, your program is wrong.

Step 3

Your programs were dependent on the value used in Python for math.pi, namely 3.1415926535897931. This is only an estimate of Pi; others have calculated 1,000,000 digits of Pi, but this is still only an estimate of this irrational number. Test out the sensitivity of your calculations above to different values of Pi, using 3.14 and 3.14159, and record your results in Lab Evaluation. Be sure to return your code to use the original math.pi before you turn in your code.

Evaluation

Answer the following questions in a file called Lab Evaluation:
  1. How much of your code were you able to reuse from orbit_kepler.py when writing orbit_newton.py?
  2. What are the AUs for the above exoplanets?
  3. Which do you think had a larger influence on the final calculation of the AU in orbit_newton.py, the Mass of the planet or period of the planet? Why?
  4. What was the effect of changing the value used for Pi in orbit_newton.py?
  5. What other sources for numerical error (like that from estimating Pi) do you see in the code you wrote?

What to Hand In

You will be handing in the three files you wrote today and the lab evaluation document. Turn in the files electronically via the submission form (linked from the course webpage). Make sure you run orbit_kepler.py and orbit_newton.py through the Python style guide checking program before you turn in your work. If you worked with a partner, make sure you put both names at the top of all your files, and only one of you should submit the lab.

Grading


© Mark Goadrich, Hendrix College