## Program 21: Virial Theorem with n objects

### Introduction and Purpose

The purpose of the program VIRIALTH.BAS is to demonstrate the Virial Theorem .
To see the listing of the program select: VIRIALTH.HTM

### Description and Operation

The program is based around Newton's Law.
Input to the program are three parameters: N, "Reff at t0" and Random.
• 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 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. Initial value = 0
(This function works only the first time the program executes)
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 (Factor 1.5) 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.
In some cases it is still possible that the speed decreases thereafter below the escape velocity and then n is increased.

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.

### 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

Back to my home page: Contents of This Document