## Visual Basic program VB VirialTh - Description and operation

### Introduction and Purpose

The purpose of the Visual Basic program VBvirialTh is to demonstrate the Virial Theorem by performing a simulation of a cluster consisting of n objects.
To see the listing of the program in QB select: VIRIALTH.HTM

### Description

The program is based around Newton's Law.
Input to the program are four parameters: N, "Reff at t0", Random and merge
• The parameter N defines the number of objects in the simulation. Initial value = 10
• The parameter "Reff at t0" defines the initial size of the "cluster". Initial value = 4
• The purpose of the parameter Random is to perform the same simulation twice (if required). The parameter Random defines the initial value of the Random Number generator. The Random Number Generator is used to calculate the initial position and velocity of each of the N objects of the simulation.
There are two ways to use the parameter Random:
1. When the initial value is 0 or negative the parameter is not used and the program starts immediately.
2. When the initial value is positive the random number generator is initialised with the selected value. This takes some time.
1. The parameter merge is used to allow that objects merge. The mass of the simulation does not change.
When Merge = 0 no merging takes place.
When Merge = 1 objects can merge if they are close. In the Matrix display the merged object is identified with zero values.
Accordingly to Newton's Law when the distance is zero the Force increases to infity. In order to prevent this to happen and to keep the speed reasonable the acceleration is set to set to zero, when the distance between two objects becomes small (<0.3),
When the distance of an object is further away than Reff and when the speed of the object is larger than the escape velocity the object is not used any more in the calculation of Reff and the value n (number of objects) is decreased with 1.

The simulation consists of two parts: Initialisation and Actual.

• In the Initialisation section the three parameters N, "Reff at t0" and Random are entered.
• Next the position and velocity of each of the objects is calculated. The values are displayed.
During this part also an average distance and average speed are calculated.
At the end mtot and m are calculated. This value will be equal to 1.
• At the end of the Initialisation section the program "temporary stops". The user can enter any key for the Actual simulation to start.
• In order to Stop and Restart the simulation the user can enter the S key. The program wil restart with the Initialisation Section.
• In order to terminate the simulation the user can enter E (to End) or the Escape key.
• In order to clear the screen during the simulation the user should enter the C (to Clear) key. When this is done a new origin is used and the scaling factor is recalculated based on Reff. In most simulations this means that the displayed size of the cluster will be smaller.
• During the simulation a counter is updated. When this counter Mod 100 is zero a number of values are calculated:
1. The average distance value of all the objects is calculated. This value is displayed as X0,Y0 and Z0. This defines the origin.
2. For each of the objects the distance r from the origin is calculated. All those values are displayed. The colors can de used to identify the object
3. For each object the distance v and the escape speed is calculated. When v is larger than 1.5 * v-escape the object is "removed".
4. For all the objects the average distance and the average speed are calculated. Reff = 2* average distance
5. The total mass and m are calculated i.e. mtot = 2 * Reff * V^2 / G Reff and m = mtot/n All those values are displayed.

### Operation

Operation of the program is done from the Control Display. See below for more information.
The Control Display contains for push buttons: "Start", "Cancel" and "Clear".
• The "Start" push button is used to start the program. After the "Start" push button is pressed the display shows the 4 input parameters N, rnd, Reff at t0 and Merge.

### Displays

Operation of the program involves 4 displays: 1) Control. 2) Matrix Display 3) Mass Display and 4) Cluster Display.
• The Control Display

### Reflection

• The initial value of the mass of each object m = 1. In the simulation m is calculated as a funtion of Reff, n and v. See above
• The results of almost all simulations shows that the value of m starts with 1 and than slowly increases to 2 or to 3. For longer simulations much higher values are observed. When that is the case also Reff increases a lot but the value of v only slightly
What this means is that based on observed values for v and Reff the predicted value for the total mass of the whole population and the individual mass for each object are not very reliable.
• In almost all simulations objects are ejected from the cluster. When that is the case n decreases with 1.
• Sometimes two objects are ejected as binaries. Those are the most interesting cases.

### Feedback

None

Original 6 December 2005