Orbit Lab

eGet the handout: Lab-Orbit.docx

To run the orbit program:

1. Run DOS Box and type these commands into the prompt:

cycles max

mount c c:/orbit

c:

dir/w

2. You will be looking at a list of the programs (*.exe files)

3. Type "orbit2" at the prompt, read the directions, and use a time increment of about 50 or so for these computers

4. You can type alt-enter to go full screen if you would like. The command "exit" at the prompt will close DOS Box. You can also just close the DOS Box window.

Orbit

Here you will try an orbital simulation. This is your chance to pilot a space ship and maybe even get it into orbit. Take your own sheet of paper to the computer, and make sure that everyone in the group gets a chance to fly the spaceship.

Part 1 - Orbit (Write down your own answers to the bold questions)

1. Type "orbit2" at the prompt and then hit "Enter". You will see a list of instructions which you should read, and maybe even take a few notes on. (The control keys will be displayed as you play the game, so don't worry) Strike any key to continue. When the program asks you for a time increment type 50. The larger the increment, the faster the simulation runs, the smaller the increment, the more accurate it is.

2. Play the game. Practice until you can make your ship orbit in a near circular path, a goodly distance from the star. (If you venture too close the computer simulation breaks down due to errors in calculation. This is evidenced by the failure of your ship to follow the same path more than once around the star even when you make no control commands. In real life you would follow the same path over and over and over.)

3. Start over, and quickly type the “o” key to put yourself into a perfect circular orbit. Let the spaceship complete one revolution and then slow the ship down abruptly by hitting the “r” key 5 times quickly.

Do you eventually speed up or slow down?

•What is the relationship between the new orbit and the old? Draw a picture of the new orbit in relationship to the old. (There is a unique relationship - called Duggan's Theorem by the great TD himself) Can you get back to the old orbit by hitting the ”s” key 5 times?

4. Compare the orbital speeds of a close orbit to a far orbit.

Which orbit is faster?

5. Get into an elliptical orbit and observe your motion.

Draw a picture of your orbit, and label the regions where you are going the fastest and the slowest.

•Conservation of energy would imply that the total energy of a satellite would remain constant. Kinetic energy is the energy of motion, and if you are moving faster, you have more kinetic energy. Gravitational potential energy in the case of a satellite is the greatest when it is farthest from the planet. The sum of these should remain constant. •Draw a diagram of an elliptical orbit, and •show where the object has more potential energy, and where it has more kinetic. •Is this consistent with conservation of energy? (That the total remains constant)

Write your own personal (unlike any other person's) answer to all 5 bulleted (•) questions from steps 3-5 on a sheet of your own paper.

Part 2 – New Orbit (nothing to write down)

1. Type neworbit at the prompt and follow the directions. (The time increment is the same as orbit) Use the concept of tangent orbits to get your spaceship into both the upper and lower orbits. To program your fire, type p, a number, and then r to slow down, or s to speed up. See if you can figure out the perfect program to go into one of the suggested orbits.

2. Isn’t that neat.

Part 3 – Apollo mission (nothing to write down)

1. Type apollo2 at the prompt. You will initially be in orbit around the earth, and the moon will be in the lower right corner of the screen. Make sure that the caps lock key is off. When the program asks you for a time increment use .5

2. Use the “s” key at the proper time to boost your ship out of orbit, and toward the moon.

3. Use the arrow keys on the number pad to make mid course corrections to your path. You want to come in toward the moon a little to the side.

4. See what happens if you let it coast.

5. Type z to start over, and repeat steps 2 and 3, but this time hit the retro rockets right when you are next to the moon. Hit it too many times and you will crash into the moon, too few, and you will be lost in space.

6. Do this until you can get into orbit around the moon. Then do the same procedure to get back to earth orbit. Practice your skills!

7. Isn’t that neat!

Pandemic Version:

Part 1 - Orbit (Write down your own answers to the bold questions)

1. Type "orbit2" at the prompt and then hit "Enter". You will see a list of instructions which you should read, and maybe even take a few notes on. (The control keys will be displayed as you play the game, so don't worry) Strike any key to continue. When the program asks you for a time increment type 50. The larger the increment, the faster the simulation runs, the smaller the increment, the more accurate it is.

2. Play the game. Practice until you can make your ship orbit in a near circular path, a goodly distance from the star. (If you venture too close the computer simulation breaks down due to errors in calculation. This is evidenced by the failure of your ship to follow the same path more than once around the star even when you make no control commands. In real life you would follow the same path over and over and over.)

3. Start over, and quickly type the “o” key to put yourself into a perfect circular orbit. Let the spaceship complete one revolution and then slow the ship down abruptly by hitting the “r” key 5 times quickly.

Do you eventually speed up or slow down?

•What is the relationship between the new orbit and the old? Draw a picture of the new orbit in relationship to the old. (There is a unique relationship - called Duggan's Theorem by the great TD himself) Can you get back to the old orbit by hitting the ”s” key 5 times?

4. Compare the orbital speeds of a close orbit to a far orbit.

Which orbit is faster?

5. Get into an elliptical orbit and observe your motion.

Draw a picture of your orbit, and label the regions where you are going the fastest and the slowest.

•Conservation of energy would imply that the total energy of a satellite would remain constant. Kinetic energy is the energy of motion, and if you are moving faster, you have more kinetic energy. Gravitational potential energy in the case of a satellite is the greatest when it is farthest from the planet. The sum of these should remain constant. •Draw a diagram of an elliptical orbit, and •show where the object has more potential energy, and where it has more kinetic. •Is this consistent with conservation of energy? (That the total remains constant)

To use orbit at home, download the .zip below, and place it in your root directory. Install DOS BOX on your computer. (Or any good DOS environment for your OS) Then follow their directions to run the orbit simulation. (Currently, anything resembling DOS BOX is disabled for Chromebooks - but there is definitely a W10 version out there that works well)

OK so you are really Geeky - and you want to see the program for orbit:

Go Here: http://tuhsphysics.ttsd.k12.or.us/DocumentsAndLectures/Documents/Misc/C_Programs/ (Links to an external site.)

and open the program ORBIT2.CPP (Links to an external site.)

And you will see this:

/* Orbit 1.2 - by chris murray. A single object of insignificant mass orbiting the sun at lunar distance. (With nifty keyboard controls) */ #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> #include <dos.h> #include <ctype.h> #include <math.h> #define true 1 #define false 0 #define background 8 /* setting up the colors */ #define black 0 #define darkblue 1 #define darkgreen 2 #define greyblue 3 #define red 4 #define purple 5 #define brown 6 #define grey 7 #define darkgrey 8 #define blue 9 #define green 10 #define lightblue 11 #define brick 12 #define violet 13 #define yellow 14 #define white 15 /* initialization parameters */ #define initx 1.6e9; #define inity 1.6e9; #define initvx 0.0; #define initvy 0.0; /* setting up external screen control variables */ int plotmaxx,plotmaxy,maxx,maxy,maxcolor; double plotscrsizex,plotscrsizey; int main() { extern int plotmaxx,plotmaxy,maxcolor,maxx,maxy; extern double plotscrsizex,plotsxcrsizey; /* request autodetection */ int gdriver = DETECT,gmode,errorcode; /* program variables */ int color,done,suncolor,shipcolor,intdt,i; double dt,mxp,ax,ay,x,y,vx,vy,vinc,vm,xsun,ysun,scrsize,msun; double nx,ny,nvx,nvy,g; char c; struct body { int type, color, trail; double x,y,vx,vy; }; int plot(double x,double y,int color); int setwindow(double size); char retch(); printf("Greetings Commander,\n"); printf("Your ship, the H.M.S. Murray, is adrift in the gamma quadrant. (In the upper\n"); printf("right corner of the screen) You are 1 astronomical unit from the star\n"); printf("Alpha 5, and your ship is currently motionless, but not for long! The\n"); printf("powerful gravity well is sucking you in, and if you do nothing, you and\n"); printf("your ship will be destroyed. Your goal is to place your ship into a stable\n"); printf("orbit around Alpha 5. Your controls are as follows:\n"); printf(" Key on KEYPAD Function\n"); printf(" UP ARROW Upward thruster [ Use the KeyPAD for ]\n"); printf(" RIGHT ARROW Right thruster [ maximum control. It ]\n"); printf(" LEFT ARROW Left thruster [ doesn't matter if ]\n"); printf(" DOWN ARROW Down thruster [ the NUM LOCK is on. ]\n"); printf(" lower case 'r' Slow down [ ** HAPPY SPACING ** ]\n"); printf(" lower case 's' Speed up\n"); printf(" ENTER Start over\n"); printf(" ESC Quit\n"); printf("These will be displayed at the top of the screen for your convenience.\n"); printf("Your ship is the little yellow dot initially in the upper right and corner\n"); printf("of the screen, and the star is the big yellow thing in the middle.\n"); printf("\n"); printf(" Strike any key\n"); getch(); /* initialize graphics and local variables */ initgraph(&gdriver,&gmode,""); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* an error occurred */ { printf( "Graphics error: %s\n",grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); /* terminate with an error code */ } maxx = getmaxx() + 1; maxy = getmaxy() + 1; maxcolor = getmaxcolor() + 1; /* setting up the orbit situation */ vm = .95; x = initx; y = inity; vx = initvx; vy = initvy; vinc = 1.02e3/10; msun = 5.98e24; g = -6.67e-11; xsun = 0.0; ysun = 0.0; /* dt = 75.0; */ gotoxy(1,1); printf("Please enter time increment> "); scanf("%d",&intdt); dt = (double) intdt; gotoxy(1,1); printf(" "); //dt = 100.0; gotoxy(1,1); setcolor(white); printf(" (up) || -> (right) || (down) || <- (left) || r (slower) \n"); printf("s (faster) || ESC (quit) || ENTER (startover) || o (Orbit)"); scrsize = 1.6e9; suncolor = yellow; shipcolor = white; setwindow(scrsize); plot(xsun,ysun,suncolor); setcolor(suncolor); for (i=1;i<4;++i) circle(320,240,i); done = false;

Here is the main program loop: do { plot(x,y,shipcolor); if (kbhit()) Deal with keyboard hits { c = retch(); switch( c) { case (72): Deal with the directional thrusters vy = vy + vinc; break; case (80): vy = vy - vinc; break; case (77): vx = vx + vinc; break; case (75): vx = vx - vinc; break; case ('r'): Slow Down (vm is less than one) vx = vx*vm; vy = vy*vm; break; case ('s'): Speed up vx = vx/vm; vy = vy/vm; break; case ('o'): Put it in a pre programmed orbit vx = 0; vy = 576.53; Moving up the screen at this velocity y = 0; x = 1.2E9; At this distance break; case (13): Start over vx = initvx; vy = initvy; y = inity; x = initx; cleardevice(); setcolor(suncolor); for (i=1;i<4;++i) circle(320,240,i); gotoxy(1,1); printf(" (up) || -> (right) || (down) || <- (left) || r (slower) \n"); printf("s (faster) || ESC (quit) || ENTER (startover) || o (Orbit)"); break; case (27): Escape = quit done = true; break; }; }; /*Here is the numerical approximation stuff*/ mxp = g*msun/pow(pow(x-xsun,2.0)+pow(y-ysun,2.0),1.5); Big floating point calculation ax = (x-xsun)*mxp; Calculate the x acceleration ay = (y-ysun)*mxp; And the y acceleration nvx = vx + ax*dt; v = u + at (in the x direction) nvy = vy + ay*dt; v = u + at (in the y direction)

nx = x + dt*(vx+nvx)/2; position = old position + displacement. (s = (u+v)t/2) ny = y + dt*(vy+nvy)/2; position = old position + displacement. (s = (u+v)t/2)

plot(x,y,background); Erase the old position x = nx; New becomes old y = ny; vx = nvx; vy = nvy; } while (!done); /*clean up */ closegraph(); return 0; } int setwindow(double size) /* initialize screen variables */ { extern int plotmaxx,plotmaxy,maxx,maxy; extern double plotscrsizey,plotscrsizex; plotmaxx = maxx/2; plotmaxy = maxy/2; plotscrsizey = size; plotscrsizex = size*maxx/maxy; return 0; } int plot(double x,double y,int color) { int px,py; extern int plotmaxx,plotmaxy,maxx,maxy,maxcolor; extern double plotscrsize; px = (int) plotmaxx*(1.0+x/plotscrsizex); py = (int) plotmaxy*(1.0-y/plotscrsizey); if ((px>0)&&(px<=maxx)&&(py>0)&&(py<=maxy)) putpixel(px,py,color); return 0; } char retch() { char ch = getch(); switch (ch) { case ('8'): ch = 72; break; case ('2'): ch = 80; break; case ('4'): ch = 75; break; case ('6'): ch = 77; break; case ('+'): ch = 43; break; case ('-'): ch = 45; break; } return ch; }