Equerm8 / center_of_mass_visualisation

Visualisation of movement of center of mass using pyplot.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CENTER OF MASS VISUALISATION

I. Info

This project visualizes the motion of particles in one Cartesian axis and the center of mass in both Cartesian axes.

The program includes:

๐Ÿ”น masses of the particles,

๐Ÿ”น constant forces that interact with particles,

๐Ÿ”น initial positions of the particles,

๐Ÿ”น initial velocity,

๐Ÿ”น number of iterations,

๐Ÿ”น time of the process.

Initial data is stored in init_data.txt. Output can be found in output.txt file.

If you want to skip physics stuff and math explanation of the topic than skip to installation.

II. Theoretical explanation and problem

The problem is to find final coordinates of the center of the mass after some seconds.

a) Center of mass equation

If we want to find coordinates of the center of the mass we would use this equation:

Center of mass equation

source: http://hyperphysics.phy-astr.gsu.edu/hbase/cm.html

b) Dynamic equation of motion

In the book I gave as a source, you can find an analytical solution to this problem, but I wanted to do it numerically. So I used Newton's second law of motion.

II Newtons law

The acceleration is the second derivative of the position, so I changed a to the second derivative.

Force is the force that acts on the selected particle in the plane.

The solution is the function x(t).

This is the answer to how my program works. It solves this second derivative, calculates the positions of the particles based on the calculated function, and from this it calculates the position of the center of mass.

III. Installation

The program is a simulation, not a library, so you can download it right away and use it.

IV. Instructions

PRESS 'Q' TO EXIT

If you just want to see the solution to the problem and its visualization:

๐Ÿ”น enable the executable file

๐Ÿ”น view the visualization,

๐Ÿ”น run output.txt. There you can see the final position of the particles and the center of mass.

If you want to play with the simulation:

๐Ÿ”น boot up init_data.txt,

๐Ÿ”น read the rules,

๐Ÿ”น stick to the rules!

๐Ÿ”น add/remove particles,

๐Ÿ”น save init_data.txt,

๐Ÿ”น run executable file and after visualization output.txt.

Screenshot of program