This repository contains the MATLAB code for a fluid simulation, originally coded in 2017 and featured in this YouTube video.
The code simulates fluid flow using a combination of the finite difference method and the Runge-Kutta method for particle advection. The main functionalities include:
- Initialization of velocity, pressure fields, and particle positions.
- Application of a divergence-free condition to the velocity field using the Jacobi method.
- Self-advection of the velocity fields using the Lagrangian-Eulerian approach.
- Particle advection using the Runge-Kutta 4th order method.
- Visualization of particle positions over time to show the fluid flow.
This project is licensed under the MIT License - see the MATLAB_2D_Fluid_Simulation.m
file for details.
- Clone the repository.
- Open
MATLAB_2D_Fluid_Simulation.m
in MATLAB. - Run the script to see the fluid simulation.
- Close the figure window to stop the simulation.
This code was put together using knowledge I accumulated from the internet and my studies. If you use this code for your own animations, please give credit to the original author.