GravSim v.1.1 A.Wade 1987/8 Based on an idea for the Spectrum by Roy Mansfield "Your Computer" 1984 ----------------------------------------------------------------------- Description:- GravSim is a simple program which shows the effects of two bodies upon each other in a universe with no other influences. Features:- Easy to use, GEM-based front end. Access provided to all variables for maximum flexibility. Load and Save user definable systems (i.e. Earth/Moon etc). DECAY function to simulate orbital decay to to friction. Collision detection. GROUNDLINE:- enables realistic simulation of objects thrown on Earth i.e. can show parabola described by a ball. Objects stop when they return to 'earth'. Path co-ordinates can be displayed on screen and/or printer. Source code provided for modification and examination. ************************************************************** In use:- The first step in using GravSim is to input the initial data. The computer must be told the initial starting positions velocities and masses of the two bodies under examination. Position : This is given as a cartiesian (normal) co-ordinate The X part is entered first followed by RETURN and then the Y part. The visible screen starts at the top left hand corner and extends to about 640,600 at the bottom right.Coordinates greater than 640 or less than 0 are possible. Position is a single precision floating point number. Velocity : This is entered as a 2 part vector. The velocity determains the initial speed and direction of the body.The first number entered is the X or horizontal part of the vector and the second number is the Y. Remember that a positive Y part of the vector will move the body towards the bottom of the screen. A body with an initial vector of (0) (0) is at rest. Velocity is a single precision floating point number Mass :This is entered as a single number. It must be noted that GravSim is a simulation and that there are no set units. However the ratios are correct and so to simulate an Earth/Moon system you should try to enter Masses with a ratio of roughly 1:4 (I think!) A certain amount of experimentation is required to get the hang of judging the masses accurately. Mass is a single precision floating point number. In addition to these basic definitions you may wish to alter the three other variables in the DEFINE menu. These are:- Gravity:- in the interests of speed the Gravitational constant has been scaled up from 6.12 E-11 to 10. This variable simply defines how strong the force of gravity is in the simulation universe. By entering a minus value, antigravity (electromagnetic repulsion?) can be shown. Gravity is a single precision floating point number. Speed:- this governs the speed of the simulation. Unfortunately the trade off in accuracy and speeds below 500 give very poor results. As the variable SPEED is increased the speed of the simulation drops.Confusing eh? Speed is a single precision integer value (-32000 to 32000) Title :- Nothing special here, this allows you to give your system a name which will be displayed when the simulation is going and helps you to know what you are looking at when you load data from disk. Default >blank< Maximum length 80 characters. Once these values have been entered you are ready to RUN the simulation. RUN is found under the OPERATE menu. also under this menu are.. STOP :- stops the simulation. CONTINUE :- continues the simulation where it left off. (identical to RUN) RESET :- resets the velocity,positions etc to their load-up values OR to their values when the DEFINE menu was last used. BEWARE of stopping the simulation and forgetting to RESET as this will leave all velocities ,positions etc. as they were at the moment the simulation was stopped. The GOODIES menu allows the following options:- GROUNDLINE:- draws a line along the bottom of the screen,fills it in and stops the simulation if BODY 2 goes below it. See sample data 'BALL' DECAY:- simulates atmospheric friction around the two bodies. The closer they approach the more velocity is lost and the orbit decays fairly quickly. COLLISION:- turns the collision detector on and off. PRINTER:- Triggered every ten cycles (approx 2 second) Sends current VELOCITIES and POSITIONS to a large array which fills up as the simulation continues.When then array is full (after 60 entries = 600 cycles=2 minutes approx.) the simulation pauses while the array is emptied onto a centronics printer.ENSURE that the printer is ready when the PRINTER option is selected and that it remains on. If the printer fails to respond after a considerable delay, the simulation stops with an error message,and all choices in the GOODIES menu are turned off. SHOWDATA:- This is also triggered every ten cycles and prints the current POSITIONs and VELOCITIES at the bottom of the screen This option slows the simulation down considerably and also makes GROUNDLINE look messy. Data save and load. ------------------- The main drawback with these is that I am unable to produce a directory listing from Hisoft Basic.I therefore advise you to keep a written record of the data files on the gravsim disk. SAVE data will dump the values in the DEFINE menu to disk including the title along with the current GOODIES selected. Enter the name you wish to give to the data file (including pathnames if necessary) but leave off the .xxx suffix. e.g. earth , system, stars, flight are all OK but earth.dat is NOT. (GravSim will automatically put a .GSD suffix on) Press return and providing there is no error everything will be automatic. The procedure for loading is very similar. Remember to ommit the suffix and include any necessary pathnames. The data is saved in simple ASCII and can be altered with almost any text editor and SHOWN from the desktop.It is saved in the following order... AW87 ' a simple string to ' identify a GravSim file. title$ posit1 x posit1 y veloc1 x veloc1 y mass1 G posit2 x posit2 y veloc2 x veloc2 y mass2 SPEED flag 1 ' used by 'collision' subroutine. flag 2 flag 3 ' groundline on=-1 off=0 flag 4 ' decay on=-1 off=0 flag 5 ' collision detection on/off flag 6 ' data to printer on/off flag 7 ' showdata on/off flag 8 ' For future expansion flag 9 ' ditto and likewise. flag 10 ' simulation running / stopped EOF ******************************************** The three sample data files provided are:- orbit :- this simulates a small mass in a circular orbit around a much larger mass. ball :- this shows the trajectory of a small mass i.e. a ball or bullet when thrown or shot on a planet. Enable GROUNDLINE before running this simulation. sl_shot :- demonstrates the slingshot principal used in the Voyager and Pioneer space probes where the gravity of a very large mass e.g. Jupiter is used to accelerate the probe. No energy is added to the system as the large mass is given an equally large push in the opposite direction to that of the probe. However this force must move a huge mass and so the velocity is almost nill. By contrast the mass of the probe is very small and the equivilant force will produce a large increase in velocity. ------------------------------------------------------------ If you posess a copy of Hisoft Basic the source code is provided and should be quite easy top alter.Should you find a major bug please write or phone me (see READ.ME file on this disk.) ------------------------------------------------------------ SETTING UP ---------- First, set the Ramdisk D: to about 80 to 90K (the RAM_DISK icon should already be present, if not click once on icon FLOPPY A find the INSTALL DRIVE option on the menu bar and click on it. Alter the name to RAM_DISK and the identifier to D: not A: Press return Drag the new icon to underneath the FLOPPY B: icon. ok. Now copy this GS_INSTR,GRAVSIM.PRG and any data files you wish to use onto drive D: List the directory of drive d: Double click on GRAVSIM.PRG When you have finished using Gravsim,use the QUIT option to return to the desktop.Copy any new data files you may have created from drive D to A. Providing you save your data,it is quite easy to leave GRAVSIM to look at the instructions and then return to the simulator and continue work. -------------------------------------------------------------