Thursday, October 1, 2015

Physics of The Martian: Traveling to Mars


(image credit: NASA)

In a contemporary, yet classic survival story, The Martian documents the struggle of astronaut Mark Watney to withstand the barrage of life-ending threats thrown by Mars. Although science fiction, author Andy Weir weaves physics, astronomy, botany, engineering, and chemistry into the book. One of the topics Weir deftly describes is the challenge imposed by traveling to Mars.

If you travel to Mars, there are three legs of your journey: (1) the launch from Earth; (2) the orbit around the Sun; and (3) the landing on Mars. During the launch and landing, you will use rocket fuel. But during the orbit, you will drift through space with Newton and the Sun driving.

Launch from Earth

To reach Mars, the rocket must launch from Earth at just the right time, speed, and direction so your orbit around the Sun is on a collision course with Mars. This window of opportunity only comes around every 26 months, which is the time it takes for Mars, Earth, and the Sun to align (though you will certainly not travel in a straight line). If you miss your flight, you will have to wait 26 months for the next one!

This simulation shows the 26 month interval between alignment of Earth, Mars, and the Sun. Click the scene to start. When Earth passes between Mars and the Sun, the simulation will stop. Click the scene to start it again and let it run until Earth again passes between Mars and the Sun. This shows you that whenever the best date of launch occurs, it will be 26 months before it occurs again.



Orbit to Mars

Earth's escape speed is 11 km/s. To leave Earth and not return, your rocket will have to reach a speed of at least 11 km/s shortly after takeoff. Once your rocket's fuel is exhausted, your orbit around the Sun will take you to Mars. Depending on your particular orbit, it can take from 130 to 330 days to reach Mars. For NASA's Mars missions, the average travel time is approximately 225 days, or about eight months. This is a long time, so you should definitely pack snacks and movies. The Mayflower took just over two months to cross the Atlantic. The journey to Mars is about four times longer than the Pilgrims' journey.

In this simulation, you can launch a rocket to Mars and measure its travel time.



The simulation starts with accurate positions and velocities of the planets as of Aug. 29, 2015. Click the scene to start. In this case, the travel time is 211 days, with the astronauts traveling from Dec. 22, 2015 to July 20, 2016.

If you want to play the role of Mission Director, try this simulation where you can control the day and direction that you launch.  (It may help to widen your browser window. In the right scene, you can adjust the direction of launch. Click the Run button to start the simulation. Click the Launch Rocket button to launch the rocket.)

Try various launch directions and launch days. You'll find a relatively small number of launch parameters that will get the rocket to Mars. (This is what Andy Weir calls the "launch window.")




Summary

In The Martian, author Andy Weir describes how the Hermes spaceship uses an ion engine to provide a small impulse on the way to Mars, thus decreasing the total travel time. Weir wrote simulations like this to determine an accurate travel time for the Hermes.

Introductory physics students can also write physically correct simulations. I suggest the book Matter and Interactions and the programming language VPython or GlowScript to learn how to create simulations of orbits and rockets.

Wednesday, September 30, 2015

Physics of "The Martian"

(image credit: NASA)

In a contemporary, yet classic survival story, The Martian by Andy Weir documents the struggle of astronaut Mark Watney to withstand a barrage of life-ending threats thrown by Mars. The Martian is a combination of Tom Hanks' Apollo 13 and Castaway. With in-depth scientific analysis, from physics and astronomy to chemistry, botany, and geology, Weir's book grabs both the mind and soul. 

A few weeks ago, students in my First Year Seminar course on the Search for Intelligent Life in the Universe at High Point University read The Martian. The purpose of our course is to investigate the question "Are we alone in the Universe?" In terms of the search for biological life, there's no better place to start than Mars. But if you are searching for a fun way to learn science, there's no better place to start than The Martian.

Tomorrow, the The Martian will be released as a film starring Matt Damon. With the release of the film and the recent finding by NASA that water flows on present-day Mars, interest in Mars is at an all-time high, making it a great excuse to talk about physics.

Let's begin with the length of a day on Mars -- a sol.

Solar Day

While on Mars, astronaut Mark Watney organizes his log (or journal) by sol. A sol is an abbreviation for solar day. If Watney starts a stopwatch at the moment the Sun is highest in the sky (noon) and stops the stopwatch the next time the Sun is highest in the sky, the reading on his stopwatch is one solar day.

A solar day is NOT the time required for a planet to rotate once on its axis relative to the background stars--this is called a sidereal day. To understand the difference between solar day and sidereal day, let's begin with Mercury.

Solar Day on Mercury

It takes 88 days (i.e. Earth days) for Mercury to complete one orbit around the Sun. This is a Mercurian year. How long is a solar day on Mercury?  In the GlowScript simulation below, the arrow represents an observer on Mercury at the equator. (The simulation assumes a circular orbit and no tilt of Mercury's axis of rotation.) Click the 3D scene to start the simulation.


A solar day is the time required for the arrow on Mercury, initially pointing toward the Sun, to point toward the Sun again. In the simulation, this requires two entire orbits, or two Mercurian years!

On Mercury, one solar day is equal to two years. Thus, it is daytime for one year and nighttime for one year. The side of Mercury facing away from the Sun gets very cold because it receives no sunlight for an entire year. This is one reason Watney is not making plans to go to Mercury.

Solar Day on Venus

Here is a GlowScript simulation of Venus. How long is a solar day on Venus? (Click the Run button below the scene to start the simulation.) The arrow is initially pointing at the Sun at t=0. Stop the simulation when the arrow points toward the Sun again. How many days elapsed? You should notice it is about 117 days. A solar day on Venus is a little more than half a Venusian year.



Did you notice anything else about Venus? It rotates clockwise about its axis as it orbits counterclockwise about the Sun. It is the only planet in our Solar System to do this.

Solar Day on Mars

Mars rotates about its axis much faster than Mercury or Venus. As a result, we will have to slow down the simulation. In this GlowScript simulation of Mars, the time step is only one minute. This is necessary if we are going to precisely measure a solar day.

To begin, click the Run button below the simulation. To help you measure a solar day, the simulation pauses after one rotation relative to the background stars (a sidereal day). Click the scene (not the button) to continue the simulation. Then it pauses when the arrow is pointing directly toward the Sun again (a solar day).



Notice that a solar day on Mars is 1 day, 40 min. It's 40 minutes longer than a (solar) day on Earth. That's not much, but when Mark Watney is gone for 549 sols, that's 564 days on Earth.

Acknowledgements

To learn the physics and programming behind the simulations, check out the textbook Matter and Interactions by Ruth Chabay and Bruce Sherwood and the programming language (and package) VPython and GlowScript. The book Matter and Interactions is an introductory calculus-based physics textbook that brings atomic and molecular applications and computational modeling to the introductory physics course.

Friday, August 14, 2015

Matter & Interactions Lecture Demo Programs

Here are bookmarks to lecture demo programs for the textbook Matter & Interactions by Ruth Chabay and Bruce Sherwood.

VPython


GlowScript



Choosing a version of VPython for Fall 2015


Recently Bruce Sherwood was asked for advice on choosing a version of VPython for Fall Semester, 2015. I'm sharing his comments here for others to see.

Python 2.7 plus VPython 6.11 is still the right decision. The holdup on running with Python 3.x is that at wxpython.org there is still no release of wxPython for Python 3, only nightly builds, and even these nightly builds are not mentioned at wxpython.org. VPython 6 uses wxPython to make windows and handle events (and provide the capability of including widgets such as buttons and sliders in a VPython program).

The VPython situation is not unlike that of many other projects that are waiting for some crucial library to be available for Python 3. The situation is not as bad as it may seem, in that Python 2.7 continues not only to receive bug fixes but even in some cases new features from Python 3.

If there is ever a wxPython library for Python 3 we will of course create installers for Python 3, but the time is still not yet. 

In other news, the GlowScript (browser) version of VPython is seeing wider use, in part because no installation is required.

The browser version of VPython is entirely adequate for the intro course but (at least at this time) not really appropriate for an upper-level computational physics course, where one wants full access to the huge Python ecology of capabilities. There is a new development which Ruth and I see as extremely promising, and one that our colleague Aaron Titus at High Point University used in a small computational physics course, namely iVisual for IPython notebook use (https://pypi.python.org/pypi/IVisual/0.1.99). John Coady implemented the VPython API in pure Python, and running on a local IPython server, it sends display information to an IPython notebook running in a browser, where he calls my GlowScript libraries to render the 3D scene, a unique combination of full Python plus GPU-based 3D rendering. There are some glitches in this environment, and John, Aaron, Steve Spicklemire (with whom I work on classic VPython), Ruth, and I are determined to fix them, to make this a better environment than either classic VPython or GlowScript VPython for upper-level courses. One of the huge advantages of a pure Python implementation, with the browser handling graphics and events, is that VPython installation will be trivial instead of daunting, cross-platform.

Saturday, August 1, 2015

Running VPython in a Browser with Anaconda, Jupyter, and iVisual

Installing iPython Jupyter and iVisual

In a previous post, I described how to install and run VPython using iPython Notebook. However, the previous instructions are now outdated due to the upgrade of Notebook to Jupyter. The instructions below are for Jupyter.

When you install Anaconda, it will automatically install iPython and Jupyter. The only additional package you need for running VPython programs in a notebook is iVisual. Here are the steps to install Anaconda and iVisual (more detailed instructions with screen captures are available):

  1. Install Anaconda. (http://continuum.io/downloads)
  2. From a command line, type:  pip install ivisual
  3. From a command line, type: ipython notebook
  4. The Jupyter home screen will open in your browser. The header of the page is shown below.




  5. Click the "New" menu and select "Python 2" as shown below.




    You will see a header for the new Jupyter notebook as shown below.


  6. Type the following program into the first cell.

from __future__ import division, print_function
from ivisual import *
#create scene
scene = canvas(title='3D scene')

sphere()

You will see a VPython scene with a white sphere as shown below.



My Classical Mechanics class used iPython Notebook and iVisual for an entire semester, and it worked wonderfully. Here's a presentation I gave to Guilford College with a notebook.

Monday, May 11, 2015

Python Graphing Tutorials in Trinket


Frequently you and your students need a reminder of the syntax for commonly used tasks in Python. Trinket can be used to post interactive Python code which your students can run in the browser or copy and paste for the purpose of running locally on their computer. Here are a few examples:


Graph Data in Python with Matplotlib






Graph Data and a Curve Fit in Python with Matplotlib




Introduction to Trinket

Trinket for Course Web Sites


In Fall 2014, I used Trinket for my course web site, PHY 3110 (Classical Mechanics).

I have developed web-based course material since 1994. Thus I have created many course web sites over the last 20 years. In recent years, I've used HTML and PHP. However I recognize the usefulness of tools that do not require programming. For example, teachers may simply use Blackboard, for example. Others might use a WYSIWYG editor like Dreamweaver or iWeb (by Apple).

However, I believe that Trinket is my now my favorite way to create a course web site. My favorite features are:


  1. the ability to write "markup" instead of HTML.
  2. the outline of topics along the left edge of the site. Before Trinket, my course web sites already had this style.
  3. the ability to embed YouTube videos, pdfs, and code.
  4. the ability to embed interactive Python Trinkets where students can directly edit the code and view the results.
  5. the ability to create interactive GlowScript Trinkets to create 3D physics models that students can edit.