Sei sulla pagina 1di 13

Cross Section Volume 1 (2007)

Probing the Effects of Alternate Jupiters


on the Inner Planets with Blender 3D
Ron Proctor, Department of Physics, Weber State University

Abstract: While the consequences of an alternate Jovian position and mass are generally
understood, it seems that the nature of gravity on an astronomical scale is not. We
believe an improvement in visualization techniques can address this problem. We
propose the creation of an interactive solution, in which a model of the inner solar system
and Jupiter is simulated. It is believed that, through manipulation of the model
(changing the mass, position, and other properties of Jupiter), a learner might gain
greater understanding of gravity on an astronomical scale..

INTRODUCTION
The question, “what happens if we do this?” is best answered with manipulation,
exploration, and observation. When given a physical model of a complex system (such as the
Sun-Earth-Moon System), it has been shown that students are better able to learn correct
explanations for observed phenomena (e.g. Phases of the Moon) (Trundle, et al. 2001). If a
concept can be transformed into something we can touch and see, we stand a much better
chance of understanding the system.
It turns out that some systems are difficult to produce as tabletop kits. The gravitational
interactions of massive bodies is one example. In this case, a virtual model is more appropriate
(and safer) for classroom or museum use.
Using Blender 3D and Python Scripting, we have produced a model of the inner solar
system plus Jupiter. Though still under development, our code allows the user to change the
orbital properties and mass of Jupiter, run a simulation to find out what happens, record the
output of the simulation for playback, and does this while visualizing the system in three
dimensions as the calculation progresses.

http://dewey.weber.edu/crossection/
74 R. Proctor

Introducing Blender 3D
Blender 3D is an open source 3D modeling, animation, compositing and rendering software.
Blender contains an impressive feature set that rivals (and in some cases exceeds) the features of
leading commercial 3D software titles. Blender provides a handy visualization framework for
our project: we need only pass time and position data to the program to receive a dynamic view
of our model.
A benefit of using Blender is that the interface is highly customizable. The user can make
things as simple or as complicated as necessary. Blender also offers customizable buttons and
menus that can be declared within a Python script. One of the long-term goals of this project is
to create such a graphical user interface (at present, the user must modify the Python script to
interact with the program).

Figure 1. The Blender Interface. Beginning at top-left and proceeding clockwise: our source code in a Script
Window, an orthographic "overhead" view of the system, an orthographic side view, a perspective view, Scene
Outliner, and IPO Curve Editor. The timeline spans the main window, below the other elements.

Cross Section 2007


Probing the Effects of Alternate Jupiters on the Inner Planets with Blender 3D 75

METHODS
Our simulation code is written in Python, a high-level programming language (named for
the British comedy troupe, not the snake). Python focuses on being human-readable, meaning
that anyone with a basic understanding of programming should be able to work out what the
source code is trying to do (and fix the various errors features of the code).
Although the visual geometry for the system (the Sun, planets, path markers, et cetera) can
be defined in the python script, we decided to create named objects in Blender and have the
script reference those. This saves a bit of computation time. Creating our own objects also
gives us flexibility in changing the size, shape, and appearance of the objects.

Figure 2. Program flowchart.

http://dewey.weber.edu/crossection/
76 R. Proctor

In the code, masses and initial positions are declared. A circular orbit is assumed and the
initial velocities are determined by:

vy0 = (2πA)/A(3/2) = (2π)/A(1/2),


where A is the semimajor axis. This is derived from Kepler’s Third Law:

p2/A3 = 1 => p = (A3)(1/2) = A(3/2),

where p is a planet’s orbital period and A is its semimajor axis.

Our code declares a Z position for objects, but calculates nothing in the Z direction. This is
done to simplify the visualization, since motion in two dimensions provides an adequate
representation of the forces and consequences in the model. We plan to add calculations in the
Z direction at a later date. True 3D calculations will be useful in the production of advanced
visualizations.
A “while loop” is declared. This means the enclosed code will repeat itself while a
condition is met. Loops are where the program does its “heavy lifting.” The loop cycles once
for every time-step of the simulation. Blender is instructed to update its timeline to match the
current simulation time-step.
Our code employs an enhancement of the Euler Algorithm known as the Midpoint Method.
As the calculation progresses, all acceleration values are calculated twice: at a half time-step and
again at a full time-step. The Midpoint Method usually offers more accuracy for the CPU time
than the Euler Algorithm (Griffiths, et al. 1991).
Accelerations are calculated using Newtonian physics:

Fg = GMm/r2 => ag = GM/r2


Our code iteratively adds the forces exerted on the body in question by all the other bodies
in the system. Currently, these operations are “hard-coded.” Future development will
introduce an array based construct to handle the objects in the system.
For every time-step, Blender inserts keyframes for all simulation objects. (A keyframe
represents the position of an object at a specific point in time.) This allows us to replay
interesting simulation results, or render a video of the result.

Cross Section 2007


Probing the Effects of Alternate Jupiters on the Inner Planets with Blender 3D 77

FIRST RUN: INVESTIGATING THE TOOL


In this section, we investigate the accuracy of the tool we have developed. In this baseline
run, all planets are set to default locations and masses (based on the real Solar System):

Planet Name Mass (mSol) Semimajor Axis (AU)


Mercury 1.66x10-7 0.38
-6
Venus 2.45x10 0.72
-6
Earth 3.00x10 1.00
-7
Mars 3.23x10 1.52
-4
Jupiter 9.55x10 5.20

Blender produces graphs of object keyframes (also known as IPO Curves). These are
essentially position vs time graphs. We have added particle systems to the planets in the
simulation. For every time-step, the particle systems emit one particle at zero velocity. This
essentially plots the path of the planet during the simulation.

Figure 3. Planet positions with plotted paths. Major divisions = 1 AU.

http://dewey.weber.edu/crossection/
78 R. Proctor

The code appears to produce a consistent orbit for Jupiter and the inner planets, with the
exception of Mercury. The data for Mercury show an orbital precession:

Figure 4. Orbital precession of Mercury, a difference of 8 years. Major divisions = 1 AU.

While the orbit of Mercury really does precess, our code produces an exaggerated result.
This is caused by a large time-step (0.01 years) and rounding errors. A smaller or an adaptive
time-step would reduce these errors at the expense of computation time.

Figure 5. A position vs. time graph for Earth, showing the x-position in AU, relative to the Sun.
100 time-steps = 1 year.

Despite some minor rounding errors, our results show the simulation to be a reasonable
approximation of the Inner Solar System. Figure 5 shows the timing to be reasonably accurate
(Earth's orbit cycle = 100 time-steps = 1 year).

Cross Section 2007


Probing the Effects of Alternate Jupiters on the Inner Planets with Blender 3D 79

SECOND RUN: BULLYING MARS


Jupiter is moved to a semimajor axis of 2.00 AU, this places Jupiter about 0.5 au from the
orbit of Mars. At this distance, Jupiter has a significant effect on the orbit of Mars.

Figure 6. Precession of the Orbit of Mars, a difference of approximately 70 years. Major divisions = 1 AU.

The data show a noticeable elongation and precession in the orbit of Mars over 100 years.
Given enough simulation time, we expect Mars to be ejected from the system.

http://dewey.weber.edu/crossection/
80 R. Proctor

THIRD RUN: JUPITER ATTACKS!


It is important to show that displacement due to gravity is cumulative. Likewise, it is
important to show that gravity acts over vast distances. But alone, these do not effectively
demonstrate the mechanics of gravity. Since our Solar System has settled into a stable
configuration, observations of it tell only half the story. Gravity in a less stable, “in your face”
scenario begins to demonstrate the importance of proximity. This is especially useful when
discussing the formation of the solar system, stellar nurseries, the centers of galaxies, and black
holes.
In this run, Jupiter is just “passing through” when it is captured by the Sun. Our initial
conditions for Run 3 set Jupiter at (+5 AU, +5 AU ) [the Sun is at ( 0 AU, 0AU )]. Jupiter is given
a nudge in the X direction of -1.00 AU/Year. Jupiter assumes a highly elliptical orbit, with a
perihelion (closest approach to the Sun) of less than 0.5 AU (for comparison, Mercury orbits at
about 0.4 AU). After a close encounter with Jupiter, Earth's orbit is drastically elongated to an
aphelion (furthest distance from the Sun) that exceeds the orbit of Mars. A second close
encounter a few years later ejects Earth from the system.

Figure 7. With some help from Jupiter, Earth achieves escape speed. Major Divisions = 1 AU.

When allowed to run for thousands of years, Jupiter continues its comet-like orbit,
elongating the orbits of the remaining inner planets, ultimately ejecting them from the system.

Cross Section 2007


Probing the Effects of Alternate Jupiters on the Inner Planets with Blender 3D 81

CONCLUSIONS
Our code appears to produce a reasonably good approximation of the inner Solar System,
plus Jupiter. We believe that, with further development, this project will be a valuable tool for
teaching gravitational interactions on an astronomical scale.

Although it works, the code needs major improvements:

1. The Sun should be affected by the other planets (it is currently static).
2. A graphical user interface is needed (currently, users must edit the code).
3. Code needs to be optimized to handle n bodies (addition of asteroids, et cetera).
4. An adaptive time-step should be introduced to improve calculation accuracy.

From personal experience, we can report that this program is a lot of fun to operate. The
still images in this paper are nothing compared to seeing it in motion!

REFERENCES

Griffiths, D. V.; Smith, I. M. (1991). Numerical methods for engineers: a programming


approach. Boca Raton: CRC Press, page 218. ISBN 0-8493-8610-1.

Malmrose, M. (2007). Using Python Scripting in Blender.


<http://weber.edu/planetarium/productionshare/production_tools/monty.pdf>
Accessed 13 December 2007.

Trundle, K., Atwood, R., & Christopher, J. (2001). Preservice Elementary Teachers'
Conceptions of Moon Phases before and After Instruction. Journal of Research in Science
Teaching, 39, 633-658.

http://dewey.weber.edu/crossection/
82 R. Proctor

APPENDIX: SOURCE CODE

#!BPY

# Bully!
# November 2007 - Ron Proctor (ronproctor@gmail.com)
#
# Physical Model of Sol, Jupiter, and Inner Planets!
# For Visualization in Blender v2.44

# Import tools and method modules for script


import Blender
from Blender import *
from Blender.Mathutils import *
import bpy
import math
from math import *

# Last Frame of Simulation (first frame is 1)


endCount = 2400

# Time Step for Simulation (Smaller steps, more accuracy, longer calculation time)
dt = 0.01

# Counts calculation steps and frames (usually = 1)


stepCount = 1

# Newton's G natural units for this sim: AU**3/year**2


G = 4*pi*pi

# Get the object named "Sol" from the .blend scene (Named Object Required)
sol = Blender.Object.Get("sol")

# Initialize Sol Position (AU)


# Assumed to be (0,0,0)
sol.LocX = 0
sol.LocY = 0
sol.LocZ = 0

# Init Sol Mass (Solar Masses)


mSol = 1

# Get the object named "jupiter" from the .blend file (Named Object Required)
jupiter = Blender.Object.Get("jupiter")

# Init Jupiter Position (AU)


jupiter.LocX = 5.204
jupiter.LocY = 0
jupiter.LocZ = 0

# Initialize Jupiter Mass (9.55e-4 Solar Masses), Velocity (AU/year), and Acceleration
(AU/year**2)
mJup = 9.55e-4
vxJup = 0
vyJup = 2*pi/jupiter.LocX**0.5
axJup = 0
ayJup = 0

# Get objects from .blend scene (Named Objects Required)


mercury = Blender.Object.Get("mercury")
venus = Blender.Object.Get("venus")
earth = Blender.Object.Get("earth")
mars = Blender.Object.Get("mars")

Cross Section 2007


Probing the Effects of Alternate Jupiters on the Inner Planets with Blender 3D 83

# Init planet positions in x dir (AU)


mercury.LocX = 0.38
venus.LocX = 0.72
earth.LocX = 1.00
mars.LocX = 1.52

# Init planet positions in y dir (AU)


mercury.LocY = 0
venus.LocY = 0
earth.LocY = 0
mars.LocY = 0

# Init planet positions in z dir (AU)


# Always 0 -- sim is 2D (x,y) as of this version.
mercury.LocZ = 0
venus.LocZ = 0
earth.LocZ = 0
mars.LocZ = 0

# Initialize planet mass (Solar Masses)


mMercury = 1.66e-7
mVenus = 2.45e-6
mEarth = 3.00e-6
mMars = 3.23e-7

# Init velocity in x dir (AU/year)


vxMercury = 0
vxVenus = 0
vxEarth = 0
vxMars = 0

# Init velocity in y dir (AU/year)


vyMercury = 2*pi/mercury.LocX**0.5
vyVenus = 2*pi/venus.LocX**0.5
vyEarth = 2*pi/earth.LocX**0.5
vyMars = 2*pi/mars.LocX**0.5

# init acceleration in x dir (AU/year**2)


axMercury = 0
axVenus = 0
axEarth = 0
axMars = 0

# init acceleration in y dir (AU/year**2)


ayMercury = 0
ayVenus = 0
ayEarth = 0
ayMars = 0

# Physics and Keyframing Loop, using Runge-Kutta Midpoint Method (badly)


while stepCount<=endCount:
Blender.Set('curframe',stepCount)

# Update position from velocity


jupiter.LocX = jupiter.LocX + vxJup*dt + 0.5*axJup*dt*dt
jupiter.LocY = jupiter.LocY + vyJup*dt + 0.5*ayJup*dt*dt
# Update velocity from acceleration
vxJup = vxJup + 0.5*axJup*dt
vyJup = vyJup + 0.5*ayJup*dt

# Update position from velocity


mercury.LocX = mercury.LocX + vxMercury*dt + 0.5*axMercury*dt*dt
mercury.LocY = mercury.LocY + vyMercury*dt + 0.5*ayMercury*dt*dt

http://dewey.weber.edu/crossection/
84 R. Proctor

# Update velocity from acceleration


vxMercury = vxMercury + 0.5*axMercury*dt
vyMercury = vyMercury + 0.5*ayMercury*dt

# Update position from velocity


venus.LocX = venus.LocX + vxVenus*dt + 0.5*axVenus*dt*dt
venus.LocY = venus.LocY + vyVenus*dt + 0.5*ayVenus*dt*dt
# Update velocity from acceleration
vxVenus = vxVenus + 0.5*axVenus*dt
vyVenus = vyVenus + 0.5*ayVenus*dt

# Update position from velocity


earth.LocX = earth.LocX + vxEarth*dt + 0.5*axEarth*dt*dt
earth.LocY = earth.LocY + vyEarth*dt + 0.5*ayEarth*dt*dt
# Update velocity from acceleration
vxEarth = vxEarth + 0.5*axEarth*dt
vyEarth = vyEarth + 0.5*ayEarth*dt

# Update position from velocity


mars.LocX = mars.LocX + vxMars*dt + 0.5*axMars*dt*dt
mars.LocY = mars.LocY + vyMars*dt + 0.5*ayMars*dt*dt
# Update velocity from acceleration
vxMars = vxMars + 0.5*axMars*dt
vyMars = vyMars + 0.5*ayMars*dt

# Update acceleration from positions


axJup = (-G*mSol*jupiter.LocX)/((jupiter.LocX-sol.LocX)**2 + (jupiter.LocY-
sol.LocY)**2)**1.5
ayJup = (-G*mSol*jupiter.LocY)/((jupiter.LocX-sol.LocX)**2 + (jupiter.LocY-
sol.LocY)**2)**1.5
# Update velocity from acceleration
vxJup = vxJup + 0.5*axJup*dt
vyJup = vyJup + 0.5*ayJup*dt

# Update acceleration from positions


axMercury = ((-G*mSol*mercury.LocX)/((mercury.LocX-sol.LocX)**2 +
(mercury.LocY-sol.LocY)**2)**1.5) + ((-G*mJup*mercury.LocX)/((mercury.LocX-
jupiter.LocX)**2+(mercury.LocY-jupiter.LocY)**2)**1.5) + ((-
G*mVenus*mercury.LocX)/((mercury.LocX-venus.LocX)**2+(mercury.LocY-
venus.LocY)**2)**1.5) + ((-G*mEarth*mercury.LocX)/((mercury.LocX-
earth.LocX)**2+(mercury.LocY-earth.LocY)**2)**1.5) + ((-
G*mMars*mercury.LocX)/((mercury.LocX-mars.LocX)**2+(mercury.LocY-mars.LocY)**2)**1.5)
ayMercury = ((-G*mSol*mercury.LocY)/((mercury.LocX-sol.LocX)**2 +
(mercury.LocY-sol.LocY)**2)**1.5) + ((-G*mJup*mercury.LocY)/((mercury.LocX-
jupiter.LocX)**2+(mercury.LocY-jupiter.LocY)**2)**1.5) + ((-
G*mVenus*mercury.LocY)/((mercury.LocX-venus.LocX)**2+(mercury.LocY-
venus.LocY)**2)**1.5) + ((-G*mEarth*mercury.LocY)/((mercury.LocX-
earth.LocX)**2+(mercury.LocY-earth.LocY)**2)**1.5) + ((-
G*mMars*mercury.LocY)/((mercury.LocX-mars.LocX)**2+(mercury.LocY-mars.LocY)**2)**1.5)
# Update velocity from acceleration
vxMercury = vxMercury + 0.5*axMercury*dt
vyMercury = vyMercury + 0.5*ayMercury*dt

# Update acceleration from positions


axVenus = ((-G*mSol*venus.LocX)/((venus.LocX-sol.LocX)**2 + (venus.LocY-
sol.LocY)**2)**1.5) + ((-G*mJup*venus.LocX)/((venus.LocX-jupiter.LocX)**2+(venus.LocY-
jupiter.LocY)**2)**1.5) + ((-G*mMercury*venus.LocX)/((venus.LocX-
mercury.LocX)**2+(venus.LocY-mercury.LocY)**2)**1.5) + ((-
G*mEarth*venus.LocX)/((venus.LocX-earth.LocX)**2+(venus.LocY-earth.LocY)**2)**1.5) +
((-G*mMars*venus.LocX)/((venus.LocX-mars.LocX)**2+(venus.LocY-mars.LocY)**2)**1.5)
ayVenus = ((-G*mSol*venus.LocY)/((venus.LocX-sol.LocX)**2 + (venus.LocY-
sol.LocY)**2)**1.5) + ((-G*mJup*venus.LocY)/((venus.LocX-jupiter.LocX)**2+(venus.LocY-
jupiter.LocY)**2)**1.5) + ((-G*mMercury*venus.LocY)/((venus.LocX-
mercury.LocX)**2+(venus.LocY-mercury.LocY)**2)**1.5) + ((-

Cross Section 2007


Probing the Effects of Alternate Jupiters on the Inner Planets with Blender 3D 85

G*mEarth*venus.LocY)/((venus.LocX-earth.LocX)**2+(venus.LocY-earth.LocY)**2)**1.5) +
((-G*mMars*venus.LocY)/((venus.LocX-mars.LocX)**2+(venus.LocY-mars.LocY)**2)**1.5)
# Update velocity from acceleration
vxVenus = vxVenus + 0.5*axVenus*dt
vyVenus = vyVenus + 0.5*ayVenus*dt

# Update acceleration from positions


axEarth = ((-G*mSol*earth.LocX)/((earth.LocX-sol.LocX)**2 + (earth.LocY-
sol.LocY)**2)**1.5) + ((-G*mJup*earth.LocX)/((earth.LocX-jupiter.LocX)**2+(earth.LocY-
jupiter.LocY)**2)**1.5) + ((-G*mMercury*earth.LocX)/((earth.LocX-
mercury.LocX)**2+(earth.LocY-mercury.LocY)**2)**1.5) + ((-
G*mVenus*earth.LocX)/((earth.LocX-venus.LocX)**2+(earth.LocY-venus.LocY)**2)**1.5) +
((-G*mMars*earth.LocX)/((earth.LocX-mars.LocX)**2+(earth.LocY-mars.LocY)**2)**1.5)
ayEarth = ((-G*mSol*earth.LocY)/((earth.LocX-sol.LocX)**2 + (earth.LocY-
sol.LocY)**2)**1.5) + ((-G*mJup*earth.LocY)/((earth.LocX-jupiter.LocX)**2+(earth.LocY-
jupiter.LocY)**2)**1.5) + ((-G*mMercury*earth.LocY)/((earth.LocX-
mercury.LocX)**2+(earth.LocY-mercury.LocY)**2)**1.5) + ((-
G*mVenus*earth.LocY)/((earth.LocX-venus.LocX)**2+(earth.LocY-venus.LocY)**2)**1.5) +
((-G*mMars*earth.LocY)/((earth.LocX-mars.LocX)**2+(earth.LocY-mars.LocY)**2)**1.5)
# Update velocity from acceleration
vxEarth = vxEarth + 0.5*axEarth*dt
vyEarth = vyEarth + 0.5*ayEarth*dt

# Update acceleration from positions


axMars = ((-G*mSol*mars.LocX)/((mars.LocX-sol.LocX)**2 + (mars.LocY-
sol.LocY)**2)**1.5) + ((-G*mJup*mars.LocX)/((mars.LocX-jupiter.LocX)**2+(mars.LocY-
jupiter.LocY)**2)**1.5) + ((-G*mMercury*mars.LocX)/((mars.LocX-
mercury.LocX)**2+(mars.LocY-mercury.LocY)**2)**1.5) + ((-
G*mEarth*mars.LocX)/((mars.LocX-earth.LocX)**2+(mars.LocY-earth.LocY)**2)**1.5) + ((-
G*mEarth*mars.LocX)/((mars.LocX-earth.LocX)**2+(mars.LocY-earth.LocY)**2)**1.5)
ayMars = ((-G*mSol*mars.LocY)/((mars.LocX-sol.LocX)**2 + (mars.LocY-
sol.LocY)**2)**1.5) + ((-G*mJup*mars.LocY)/((mars.LocX-jupiter.LocX)**2+(mars.LocY-
jupiter.LocY)**2)**1.5) + ((-G*mMercury*mars.LocY)/((mars.LocX-
mercury.LocX)**2+(mars.LocY-mercury.LocY)**2)**1.5) + ((-
G*mEarth*mars.LocY)/((mars.LocX-earth.LocX)**2+(mars.LocY-earth.LocY)**2)**1.5) + ((-
G*mEarth*mars.LocY)/((mars.LocX-earth.LocX)**2+(mars.LocY-earth.LocY)**2)**1.5)
# Update velocity from acceleration
vxMars = vxMars + 0.5*axMars*dt
vyMars = vyMars + 0.5*ayMars*dt

mercury.insertIpoKey(3)
venus.insertIpoKey(3)
earth.insertIpoKey(3)
mars.insertIpoKey(3)
jupiter.insertIpoKey(3)

# Redraw 3D Window
Blender.Redraw()

# advance stepCount
stepCount = stepCount+1

# Loop from "while..." until endCount is reached.

# It's Over!

http://dewey.weber.edu/crossection/

Potrebbero piacerti anche