It is possible to program the simulation parameters by making a text file.
I) Instructions to make the file "Parameters.txt"
There are two options to create the parameters file:
1st) Construct a "Parameters.txt" file to program the parameters of the simulation. You can make this file by following the instructions below.
2nd) Automatically create and save a standard "Parameters.txt" file, ready for the simulation "Three balls. (default)". Use option (3) from the previous menu. Edit this file and change the values of the variables to create your personalized simulation.
Use any text editor, but always save the file as plain text ".txt". You can choose another name for the file and build files with different names for each simulation you make.
Once the file is created, upload it by selecting the option (1) from the previous menu and so you can run your specific simulations.
The file must contain all the variables (36 total). Each variable has to stay in a line with the format [the variable, one or more spaces, and the value], like this template:
VARIABLE value
Example:
NBALLS 2
This means that we are setting the parameter "NBALLS", which is the number of the balls in simulation, with the value "2".
Note: the maximum balls' number will depend upon the computer power you have, but internally it is limited to the size of the integer type variable (32767). We have not tested or programmed for these extreme conditions.
Example:
BALL_MASS 1.0
This means that we are setting the parameter "BALL_MASS", which is the mass of the balls in simulation, with the value "1.0".
An entire example of all the parameters, with the configuration to initialize the "Three balls. (default)" simulation (menu option 1), is below:
(Begin of file)
GAS_MODE 0
NBALLS 3
BALL_RADIUS 20
BALL_SPEED 60
BALL_MASS 0.1
BALL_GRAVITY 0
BALL_G 0
PUSH_PULL 1
COEF_RESTITUTION 1.0
IS_TESTING 0
BALL0_SPEED 0.0
BALL0_VEL_ANGLE 90
BALL0_X 0
BALL0_Y 0
BALL0_RADIUS 12
BALL0_MASS 1e-6
BALL0_TIME 0
BALL0_DELTA_SPEED 0.0
BALL0_DELTA_ANGLE 0
BALL1_SPEED 0
BALL1_VEL_ANGLE 0
BALL1_X 1000
BALL1_Y 1000
BALL1_RADIUS 200
BALL1_MASS 0.0
PISTON_MASS 10
PISTON_GRAVITY 0.0
BOTTOM_TEMP_MIN 0.0
BOTTOM_TEMP_MAX 100.0
BACKGROUND 1
SCREEN_WIDTH 480
PERCENT_WIDTH 0.50
SCREEN_HEIGHT 480
PERCENT_HEIGHT 0.80
WALL_WIDTH 20
ZOOM_FACTOR 1.0
(End of file)
Please do not write "(Begin of file)" and "(End of file)". Only write the names and values of all the 36 variables, and some blank lines between. The file has some blank lines between separate groups of related parameters. Those lines are optional. You may choose to make the file without them or put other ones to clarify the blocks.
Tip: 1) Select the entire area above with your mouse. 2) Right-click (and select "copy"). This action automatically "copies" the content to memory. 3) Go to the text editor and choose "paste". Even if spaces appear before each variable, the file will be understood correctly. 4) Save the file in ".txt" format.
Following, we are going to explain each group and variable.
The first group is:
GAS_MODE 0
NBALLS 3
BALL_RADIUS 20
BALL_SPEED 60
BALL_MASS 0.1
BALL_GRAVITY 0
BALL_G 0
PUSH_PULL 1
COEF_RESTITUTION 1.0
It contains the simulation mode (GAS_MODE x), number of balls (NBALLS x), ball radius (BALL_RADIUS x), ball initial speed (BALL_SPEED x), the mass of each ball (BALL_MASS x.x), the gravity that will operate on the balls (BALL_GRAVITY x), the gravitational constant in case of gravitational simulations (BALL_G x), the mode of the collision algorithm (PUSH_PULL x), and the coefficient of restitution for partially inelastic simulations (COEF_RESTITUTION x.x). The PUSH_PULL is an internal setting in the algorithm (you could test to see the differences), which could be "0" or "1", and the default is "1".
The next group has three blocks, and starts with IS_TESTING:
IS_TESTING 0
BALL0_SPEED 0.0
BALL0_VEL_ANGLE 90
BALL0_X 0
BALL0_Y 0
BALL0_RADIUS 12
BALL0_MASS 1e-6
BALL0_TIME 0
BALL0_DELTA_SPEED 0.0
BALL0_DELTA_ANGLE 0
BALL1_SPEED 0
BALL1_VEL_ANGLE 0
BALL1_X 1000
BALL1_Y 1000
BALL1_RADIUS 200
BALL1_MASS 0.0
When it has "IS_TESTING 1" the simulation will read the parameters related to balls 0 and 1 (the first two balls). The parameters starting at BALL0_SPEED and ending at BALL1_MASS will control the first two balls (ball 0 and ball 1). They can control their positions, sizes, mass, and initial velocity (speed and angle). This is useful to make tests, but also to simulate the launching of a satellite.
In the case of ball 0, it also can control its "second speed", or "delta speed", which is a speed that will be added at a specified time, to change its trajectory, using BALL0_TIME (the time), BALL0_DELTA_SPEED (the speed added), BALL0_DELTA_ANGLE (the the angle of this speed).
In the case of the "Three balls. (default)" simulation, IS_TESTING is "0", so we can ignore these parameters. But there are other cases when we could use this option. See the details, with an example, in the "Satellite launching" that we are going to explain below.
Back to our explanation, after those three blocks, the next group is:
PISTON_MASS 10
PISTON_GRAVITY 0.0
We have the mass of the piston (PISTON_MASS x), and the gravity that will operate on the piston (PISTON_GRAVITY x.x).
The next group is:
BOTTOM_TEMP_MIN 0.0
BOTTOM_TEMP_MAX 100.0
We have a simulation of an "energy" injection (an approximation) that could operate from the bottom. It will control how much energy can be entered using the keys → and ←.
The final group is:
BACKGROUND 1
SCREEN_WIDTH 480
PERCENT_WIDTH 0.50
SCREEN_HEIGHT 480
PERCENT_HEIGHT 0.80
WALL_WIDTH 20
ZOOM_FACTOR 1.0
It shows the rendering options, like the size of the canvas in points or pixels (SCREEN_WIDTH, SCREEN_HEIGHT) and the color (BACKGROUND), which has '0' and '1' options. The PERCENT_WIDTH is the amount of space used by the cylinder, also the PERCENT_HEIGHT. The ZOOM_FACTOR will create a zoom effect, so we can choose a big canvas, but apply a small zoom factor to fit it on the screen.
II) Elementary "Satellite launching" simulation:
As a challenge, you could find the parameters for an elementary satellite launching. You will need to set NBALLS 2 and IS_TESTING 1 to be able to program the first two balls. One will be the planet and the other the satellite.
You will need to set the sizes of the satellite (BALL0_RADIUS) and the planet (BALL1_RADIUS) and their masses (BALL1_MASS, BALL0_MASS), and their positions (BALL0_X, BALL0_Y) and (BALL1_X, BALL1_Y).
You will need to think about BALL0_SPEED (the launching speed), BALL0_VEL_ANGLE (the angle of launching: set to 90 degrees), BALL0_TIME (the time to orbit, when we must turn on the orbit speed), BALL0_DELTA_SPEED (the orbit speed), BALL0_DELTA_ANGLE (the angle for the orbit initial velocity: set to 0 degrees).
Example of "Satellite launching" (we have omitted three values with xxx):
(Begin of file)
GAS_MODE 0
NBALLS 2
BALL_RADIUS 8
BALL_SPEED 0
BALL_MASS 1.0
BALL_GRAVITY 0
BALL_G 100000.0
PUSH_PULL 1
COEF_RESTITUTION 1.0
IS_TESTING 1
BALL0_SPEED xxx
BALL0_VEL_ANGLE 90
BALL0_X 1000
BALL0_Y 788
BALL0_RADIUS 12
BALL0_MASS 1e-6
BALL0_TIME xxx
BALL0_DELTA_SPEED xxx
BALL0_DELTA_ANGLE 0
BALL1_SPEED 0
BALL1_VEL_ANGLE 0
BALL1_X 1000
BALL1_Y 1000
BALL1_RADIUS 200
BALL1_MASS 50.0
PISTON_MASS 1e10
PISTON_GRAVITY 0.0
BOTTOM_TEMP_MIN 0.0
BOTTOM_TEMP_MAX 100.0
BACKGROUND 1
SCREEN_WIDTH 2000
PERCENT_WIDTH 0.90
SCREEN_HEIGHT 2000
PERCENT_HEIGHT 0.90
WALL_WIDTH 20
ZOOM_FACTOR 0.40
(End of file)
Given the parameters above, you will need to program the BALL0_SPEED (initial speed at the launching of the satellite), BALL0_TIME (when it will turn on the orbit speed), and BALL0_DELTA_SPEED (the second speed, so we have the initial orbit velocity).
See that the initial launching angle is BALL0_VEL_ANGLE 90 and the angle for the second speed (the delta speed) is BALL0_DELTA_ANGLE 0.
Tip: Set the BALL0_DELTA_SPEED to zero, but BALL0_TIME to a time enough for the ball to invert its velocity. Pay attention to the data that the program will print. You will find how much altitude these values could arrive at.
III) Partially inelastic collision of two balls:
The programing of "IS_TESTING 1" is also useful to simulate the collision of two balls, and to study the effect of coefficient of restitution in a partially inelastic collision. Just set NBALLS 2 and adjust the other parameters. Below is an example:
(Begin of file)
GAS_MODE 0
NBALLS 2
BALL_RADIUS 8
BALL_SPEED 60
BALL_MASS 0.1
BALL_GRAVITY 0
BALL_G 0
PUSH_PULL 1
COEF_RESTITUTION 0.8
IS_TESTING 1
BALL0_SPEED 40.0
BALL0_VEL_ANGLE 0
BALL0_X 200
BALL0_Y 200
BALL0_RADIUS 20
BALL0_MASS 10
BALL0_TIME 0
BALL0_DELTA_SPEED 0.0
BALL0_DELTA_ANGLE 0
BALL1_SPEED 0
BALL1_VEL_ANGLE 0
BALL1_X 280
BALL1_Y 200
BALL1_RADIUS 20
BALL1_MASS 10
PISTON_MASS 1e6
PISTON_GRAVITY 0.0
BOTTOM_TEMP_MIN 0.0
BOTTOM_TEMP_MAX 100.0
BACKGROUND 1
SCREEN_WIDTH 480
PERCENT_WIDTH 0.50
SCREEN_HEIGHT 480
PERCENT_HEIGHT 0.80
WALL_WIDTH 20
ZOOM_FACTOR 1.0
(End of file)
Look at the coefficient of restitution and the way the parameters after IS_TESTING 1 were configured. Ball 0 is programmed to collide with ball 1.
Good simulations!