This library provides two main object classes: 'Particle' and 'Line'. Given a set of particles and line segments the main 'Engine' function creates a real-time simulation and graphic animation of the interaction between particles and lines.
Particles will bounce off other particles, lines or boundaries according to newtonian mechanics, preserving energy thanks to the implementation of a Verlet algorithm used to move the particles.
In order to create a particle 'p' one must procede to inicializate as followsp = Particle(Position, Velocity, Mass, Radius, Color, Dynamic)
In order to create a line segment 'l' one must procede to inicializate as follows
l = Line(Point_A, Point_B)
The environment in which the objects exist must be determined by the user, this includes:
- Window_Size: Size of the window screen in pixels
- Background: Function comprised of pygame code to draw anything on the screen background
- Boundary: Function that changes the position and velocity of particles defining some boundary
- Force: Function that describes the force felt by a particle
The library includes some predefined functions that could be used to describe the environment
- Boundaries:
- Closed_Box_Boundary
- Periodic_Boundary
- Closed_Circle_Boundary
- Circle_Boundary_Background
- Const_Gravity
This python library allows multiple aplications, including physics simulations with real educational value, a great example might be the simulation presented bellow, with two gases separated by a chamber, blue particles have greater average velocity than red particles. This could be used to demonstrate principles in thermodinamics and statistical physics
This work is licensed under a
Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.