Skip to content

Experimental foray into OpenGL and Vispy: A bubble simulation

Notifications You must be signed in to change notification settings

VictorGoubet/Bubble

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Forks Stargazers

Logo

Bubble

Exploring OpenGL and Vispy through Bubble Interactions
Explore the docs »

Report BugRequest Feature

About The Project

The "Bubble" project is more than a mere simulation; it's an experimental foray into OpenGL and Vispy, aiming to create a visually appealing interaction of bubbles in a 2D space. The physical concepts in this simulation are largely approximated, serving as a learning and exploration platform rather than a precise physical simulation.

Product Screen Shot

The bubbles interact through a simplified physics model, where collisions can result in bubbles splitting based on an approximated energy transfer model. This approach, while not physically accurate, provides an interesting and aesthetically pleasing visual display of interacting bubbles, offering a foundation upon which further refinements and features can be built.

Built With

Getting Started

Prerequisites

  • Python 3.x
  • pip

Installation

  1. Clone the repository:
    git clone https://github.com/VictorGoubet/Bubble
    cd Bubble
  2. Set up a virtual environment (recommended):
    python3 -m venv venv
    source venv/bin/activate
  3. Install the required dependencies:
    pip install -r requirements.txt
  4. Run the simulation:
    python3 simulation.py

Hyperparameters

Several hyperparameters govern the behavior and visual appearance of the simulation and bubbles:

Simulation Hyperparameters (Located in simulation.py)

  • n: Number of bubbles in the simulation.
  • width & height: Width and height of the simulation window.
  • min_radius & max_radius: Minimum and maximum allowable radii for the bubbles.
  • max_speed: Maximum allowable speed for the bubbles.
  • mode: Interaction mode ("split", "merge", "overlap", or "bounce").

Bubble Hyperparameters (Located in bubble.py)

  • density: Density of the bubbles, affecting their weight.
  • max_speed: Maximum speed of a bubble.

Simulation Details

Bubble Splitting Mechanism

In the context of a collision, kinetic energy is transferred between bubbles. Each bubble has a resistance, and if the energy transferred surpasses this resistance, the bubble "breaks", splitting into two smaller bubbles. New properties (e.g., radius, position, and speed) for the resulting bubbles are calculated, maintaining a semblance of energy conservation in the system.

Future Improvements

  • Bubble Merging: Implement a "merge" mode, where bubbles coalesce like water bubbles, forming larger structures instead of splitting.

Contact

Victor Goubet - LinkedIn - victorgoubet@orange.fr