This Python-based project offers a dynamic and interactive simulation of bird-like entities, known as "boids", in a virtual atmospheric environment. The simulation showcases the behavior of individual boids as well as their interactions in a group.
- Introduction
- Demonstrations
- Forces
- Atmosphere
- Constants and Properties
- Assumptions of the Model
- Contributing
- Bug Reporting
- License
NOTE: In the simulation:
- The drag force and the velocity of the boid is represented in red.
- The lift force is represented in green.
- The gravity force is represented in black.
- A change in the boid's color indicates that it has executed a flap.
Single Boid Simulation: Observe the behavior of a single boid navigating through the atmosphere.
singleboid.mp4
Many Boids Simulation: Here each boid has a specific Vx starting velocity. This video shows the one that goes the furthest.
manyboids.mp4
In this project, three fundamental forces are simulated to mimic the realistic movement of boids. Those equations are:
where:
-
$F_{\text{drag}}$ is the drag force, -
$F_{\text{lift}}$ is the lift force, -
$F_{\text{gravity}}$ is the gravitational force, -
$\rho$ is the mass density of the air, -
$v$ is the flow velocity relative to the boid, -
$A_{\text{drag}}$ is the drag area, -
$R_{\text{LTD}}$ is the Lift-to-Drag Ratio, -
$m$ is the mass of the boid, and -
$g$ is the acceleration due to gravity on Earth.
Instead of traditional thrust, the simulation uses a flap mechanism to propel the boids. Each flap provides an energy boost to the boid, increasing its kinetic energy and thus influencing its movement and trajectory in the simulation. The energy dynamics during a flap are described by the following equation:
where:
-
$E_{\text{before}}$ is the kinetic energy of the boid before doing one flap, -
$E_{\text{after}}$ is the kinetic energy of the boid after doing one flap, and -
$E_{\text{flap}}$ represents the additional kinetic energy added to the boid as a result of the flap.
In studying the behavior of the atmosphere at different altitudes, several key equations come into play. These equations help in understanding how temperature, pressure, and density vary with altitude. This ensures that the boids won't fly as high as they can limiting their ability to the limits of the atmosphere.
where:
-
$T(h)$ is the temperature at height$h$ , -
$P(h)$ is the pressure at height$h$ , -
$\rho(h)$ is the mass density at height$h$ , -
$T_0$ is the sea level air temperature, -
$P_0$ is the sea level air pressure, -
$\rho_0$ is the sea level air mass density, -
$h$ is the altitude, -
$h_0$ is the height of the atmosphere, and -
$\gamma$ is the adiabatic index.
-
Boid properties
- LTDRatio [
$R_{\text{LTD}}$ ] = 15 (can be approximated by the glide ratio) - DragArea [
$A_{\text{drag}}$ ] = 50 cm² - Mass [
$m$ ] = 1 kg - FlapEnergy [
$E_{\text{flap}}$ ] = 10 J - MaxFlapsPerSecond = 3
- LTDRatio [
-
Atmosphere properties
- SeaLevelAirDensity [
$\rho_0$ ] = 1.225 kg/m³ - SeaLevelAirPressure [
$P_0$ ] = 101.325 kPa - SeaLevelAirTemperature [
$T_0$ ] = 15 °C - AirAdiabaticIndex [
$\gamma$ ] = 1.4 - AtmosphereHeight [
$h_0$ ] = 30 km - AirMolarMass [
$M_\text{air}$ ] = 28.97 g/mol - GravitationalPull [
$g$ ] = 9.81 m/s²
- SeaLevelAirDensity [
The model assumes a dry atmospheric condition, closely following the dry adiabatic lapse rate for temperature, pressure, and density calculations. This simplification presumes an atmosphere consisting solely of air without water vapor. Although this deviates slightly from real-world data, it maintains a correct order of magnitude for these parameters.
The simulation operates within air speeds of 3 to 50 meters per second. In this range, Lift-Induced drag is significant while parasite drag is minimal. The model focuses on generating lift primarily through adjusting the angle of attack.
The boids in this simulation function independently, without any interactions or influences from other boids.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
If you encounter any bugs or issues, please report them on the Issues page. Include as much detail as possible, such as the steps to reproduce the bug and any error messages.
Distributed under the MIT License. See LICENSE
for more information.