I) Instructions to create the "Parameters.txt" file

It is possible to program the simulation parameters through a text file.

There are two options to create the parameter file:

1) Create a "Parameters.txt" file to program the simulation parameters. You can build this file by following the instructions below.

2) Automatically create and save a default "Parameters.txt" file with the simulation “Three balls (default)”, then edit that file and change the variable values to create your custom simulation, saving it as a new “*.txt” file. Use option (3) in the menu.

Use any text editor, but always save as plain text “.txt” (without formatting). You may choose another filename and create different files for each simulation.

After creating the file, load it by selecting option (1) in the menu, and then you can run your specific simulations.

The file must contain all variables (36 in total). Each variable must be on its own line in the format [the variable, one or more spaces, and the value], as in the model:

VARIABLE value

Example:

NBALLS 2

This means we are defining the parameter “NBALLS”, the number of balls in the simulation, with value “2”.

Note: the maximum number of balls depends on the capacity of your computer, but internally it is limited by the size of the integer type (32767). We have not tested or programmed for extreme conditions.

Example:

BALL_MASS 1.0

This sets the “BALL_MASS” parameter, the mass of the balls in the simulation, with value “1.0”.

Below is a full example of all the parameters, with the configuration to initialize the “Three balls (default)” simulation (option 1 in the menu):

(Beginning 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 “(Beginning of file)” and “(End of file)”. Write only the variable names and values of all 36 variables, with optional blank lines between related groups. These blank lines are optional; you may remove or add them to make the blocks clearer.

Suggestion: 1) Select the entire parameter area above. 2) Right‑click and choose “Copy”. 3) Go to your text editor and choose “Paste” (as text). The file will still be read correctly even if spaces appear before each variable. 4) Save the file in “.txt” format.

Next, we 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

This group contains the simulation mode (GAS_MODE x), number of balls (NBALLS x), ball radius (BALL_RADIUS x), initial velocity (BALL_SPEED x), mass of each ball (BALL_MASS x.x), gravity applied to the balls (BALL_GRAVITY x), gravitational constant (BALL_G x), collision mode (PUSH_PULL x), and coefficient of restitution for partially inelastic simulations (COEF_RESTITUTION x.x). PUSH_PULL is an internal configuration (default: “1”).

The next group has three blocks and begins 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 IS_TESTING = “1”, the simulation reads the parameters for balls 0 and 1. They control positions, sizes, masses and initial velocities (magnitude and angle). This is useful for tests and for simulations such as “satellite launching”.

For ball 0, you may define a “second velocity” (delta speed), added at a specific instant, using BALL0_TIME, BALL0_DELTA_SPEED, and BALL0_DELTA_ANGLE.

Note: BALL0_TIME represents time in milliseconds.

In the “Three balls (default)” simulation, IS_TESTING = 0, so these parameters are ignored. In other use cases, however, they are essential.

We will now see the “Satellite launching” example.

After these blocks, the next group is:

PISTON_MASS 10

PISTON_GRAVITY 0.0

This group defines the piston mass (PISTON_MASS x) and the gravity applied to the piston (PISTON_GRAVITY x.x).

The next group is:

BOTTOM_TEMP_MIN 0.0

BOTTOM_TEMP_MAX 100.0

This corresponds to an approximate “energy injection” simulation from the bottom, controlling how much energy can be inserted using the → and ← keys.

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

This shows the rendering options such as the drawing area size in pixels (SCREEN_WIDTH, SCREEN_HEIGHT) and background color (BACKGROUND), with options “0” and “1”. PERCENT_WIDTH and PERCENT_HEIGHT define the fraction of space occupied by the cylinder. ZOOM_FACTOR creates a zoom effect to fit large areas on the screen.

----

II) Elementary simulation: “Satellite launching”

As a challenge, you can determine the parameters for an elementary satellite launch. Set NBALLS 2 and IS_TESTING 1 to program the first two balls: the planet and the satellite.

Define their sizes (BALL0_RADIUS and BALL1_RADIUS), masses (BALL1_MASS, BALL0_MASS) and positions (BALL0_X, BALL0_Y, BALL1_X, BALL1_Y).

It will also be necessary to define BALL0_SPEED (the launch velocity), BALL0_VEL_ANGLE (the launch angle, set to 90 degrees), BALL0_TIME (the moment of orbital insertion, when the orbital velocity should be applied), BALL0_DELTA_SPEED (the orbital velocity, which will be added to the current velocity at that instant), and BALL0_DELTA_ANGLE (the angle of the orbital velocity to be added, set to 0 degrees).

Example of “Satellite launching” (three values omitted with xxx):

(Beginning 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)

Based on the parameters above, you will need to program BALL0_SPEED (the initial velocity at satellite launch), BALL0_TIME (the moment when the orbital velocity will be added, in milliseconds), and BALL0_DELTA_SPEED (the value of the orbital velocity to be added). Note that the suggested initial launch angle is defined as BALL0_VEL_ANGLE 90, and the orbital velocity angle as BALL0_DELTA_ANGLE 0.

Recommendation: Set BALL0_DELTA_SPEED to zero and assign BALL0_TIME a value corresponding to a moment after the inversion of the satellite’s velocity direction, once it has reached a complete stop*. Analyze the data printed by the program to identify the maximum altitude reached.

*Note: the program will display auxiliary information only when the specified BALL0_TIME condition is met.

----

III) Partially inelastic collision

The “IS_TESTING 1” configuration is also useful to simulate the collision of two balls and study the effect of the coefficient of restitution. Simply set NBALLS 2 and adjust the other parameters. Below is an example:

(Beginning 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)

Observe the coefficient of restitution and how the parameters after IS_TESTING 1 were configured. Ball 0 is programmed to collide with ball 1.

Enjoy your simulations!