本次CS代写的主要涉及如下领域: Python代写,北美程序代写,美国程序代写,PHYSICS113代写,Drexel University代写
PHYSICS 113– Recitation Assignment 3
Name
Recitation Assignment # 3 – The Two-Body Problem
October 16, 2019
Today’s recitation will involve the general form of gravity, and, in particular, you will show using a computer that two bodies will orbit one another in an elliptical orbit. Moreover, you will use numerics to determine the optimal speed for a particle traveling in a circular orbit. Note, for simplicity, when I use the symbol , it means “of the sun”, and when I use⊕, it means, “of the earth.”
You may complete this in class. However, if you are unable to do so, it is expected that you complete this for recitation next time. Remember to submit your program to Virginia via the submission webpage.
You should also include a comment line in your code indicating whose program it is (i.e. yours).
If you have any questions, please ask.
New Concepts:
Physical
- Central gravity
- Two body interaction
Computational
- Mag and Pow functions
We will model the earth-sun system. Since the sun is much more massive than the earth, we will be able to make the assumption that the sun is stationary.
- Log into a workstation, pull up firefox, make yourself comfortable, etc.
- In your “progs” directory, create a “prog3.py” using emacs.
xphy8:~> emacs prog3.py &
where (again) the ampersand will allow you to use the shell while emacs is open.
- As with all of your python programs which use graphics, you will want:
from vpython import *
at the top.
- Create two spheres. Make one yellow, and at the origin, and the other should look like the earth, and at a position 1. 5 × 1011 m (1 “Astronomical Unit”) from the sun, and along the x-axis. One of the most efficient ways to program is to define all of your physical and other parameters up at the top of the program. A partial list might look like:
AU=1.5e
G=6.67e-
Msun=2e
Mearth=6e
yr=3.15e
and so forth. These parameters are all in MKS units. Python is not keeping track of the units, so you
should.
You may choose to add other parameters. Thus, when you create the earth, it might look like:
earth=sphere(pos=vec(1*AU,0,0),radius=0.1*AU)
The radius, obviously, is gargantuan compared to the real earth, but this allows it to be seen. Note
that “vec” is a shorthand used by vpython for vectors.
- Add the following lines to your code:
scene.range=1.3*AU
scene.autoscale=
The first line makes the viewscreen large enough to see a bit beyond the “orbit” of the earth, and the
second command tells the code not to automatically resize the picture if the earth flies out of the field
of view.
- Here’s where we start to add physics. The sun has a mass of 2× 1030 kg, and the earth has a mass of 6 × 1024 kg. Set both of these. For example, the mass of the sun can be set by writing:sun.m=Msun and similarly for the earth. Give the earth an initial velocity of 35 km/s=35000m/s in the y-direction. This can be done by entering: earth.v=vec(0,35000,0)
- In the non-relativistic limit: ∆~r=~v∆t At each timestep, you have to evolve the position of the earth, according to this formula. Put in the following additions to your code:
dt=0.005*yr
t=
while (t < 2*yr) :
rate (20)
earth.pos=earth.pos+dt*earth.v
t=t+dt
The first two commands tell the code how many seconds there are in a year. The second tells it what
the value of ∆tis. The third tells it to “start the clock” at t=0.
- As we saw, the earth just flies in a straight line, when, in fact, we know that it moves around the sun. What makes it move? Gravity! The acceleration due to gravity can be expressed as:
F~⊕=−GM^ M⊕
r^3 sun−earth
(~r⊕−~r )
whereG= 6. 67 × 10 −^11 Nm
2
kg^2 is the gravitational constant.
In order to compute the rest of the terms in the force, you may need to do a bit of searching on the
vpython or python webpages, or using google.
Incidentally, the reason that the denominator has anr^3 (rather thanr^2 ) is that the difference in vectors
in the numerator divided by one power of r produces the unit vector, ˆr(think about it).
You’ll need to use the “mag” and “pow” functions. E.g:
F=G*sun.m*earth.m*(sun.pos-earth.pos)/pow(mag(sun.pos-earth.pos),3)
Remember, this needs to be in the loop, and it needs to be computed every time. Thus, the velocity
of the earth needs to be updated, as well as that of the sun:
∆~v⊕=
F~
m⊕
∆t
∆~v =−
F~
m
∆t
Notice the minus sign. Just defining the variable,F, isn’t sufficient. You need to apply it to an
equation.
Within the loop, calculate the force, and update the velocity.
Notice, too, that you’ll need to update the position of the sun in terms of its momentum as well as
that of the earth. However, since the sun is far more massive, it won’t move very much.
- Put in a blue “curve” following the position of the position of the earth. (You did this in recitation # 2, so you may want to look at your program to see what you did).
- Adjust the initial velocity of the earth so that it moves more nearly in a circular orbit.
- Run the code for 20 years rather than 2. After doing so, make sure that the orbit of the earth is a
perfectly repeating ellipse (at least to the precision of the program). If it isn’t, reduce the size of your dt. 12. Put Jupiter into your system. Find the mass, distance from the sun, and orbital velocity of Jupiter by using google. This is more complicated than it might look. In particular, keep in mind to:
(a) Expand the size of your view window to accomodate the new planet.
(b) Compute thetotalforce on each of the three bodies. That means that you should compute three
combinations of forces and get the total:
F~⊕=F~⊕−Jupiter+F~⊕−
Be careful with your signs!
(c) Put a trail on Jupiter
- Observe the system. What happens if you change the mass of Jupiter? Make it 100 times larger than normal (roughly 10% the mass of the sun).
- As always, send your solution to Virginia when you are done.