Inspiration:

A paper my friend and coincidentally teammate gave me on why blood is very complex and methods to find more about its behaviors are computationally intense. I also think that health care is a very important industry and with cardiovascular disease on the rise with a 4 percent increase from last year, and potential uses of simulating blood to prevent heart attacks by possibly seeing where it can clot the blood, I think trying to build a quick simulator would be very important for future healthcare and medical research.

What it does

It simulates blood by using an Eulerian fluid simulator in the background, which I learned the algorithm from a paper by Joe Stam "Real-Time Fluid Dynamics for Games" and implemented in python using numpy and linear algebra to lower rendering time so it can run real time. On top of this we add particulate matter, that has it's own physics, which depending on our parameters, clump, move, bump into, turbulently pass around the space.

How we built it

As my teammate had personal circumstances, I coded everything myself from scratch using only basic standard libraries in python. I used linear algebra methods from numpy to use discrete forms of differential operators to turn these operators into algebraic ones that can be solved quickly. Also, I played around with various ways to render velocity fields using density gradients and implemented added complexities to particulate matter like collisions, charge, charge against a wall, the viscosity of the fluid it is submerged in, etc.

Challenges we ran into

Definitely one of them is making sure it renders real time. That took a lot of thinking and research, and I almost gave up. The thing that frustrated me the most is particles being sucked towards one corner. I still don't know the cause but I believe it has something to do with turning a float array into an int array and updating positions and velocities and in the process, it iteratively loses some x and y position until it sinks into a corner. Another problem was matter clumping together, but you can solve that with implementing something that performs a max distance collision operation that pushes something away if it's within that max distance. I also took a lot of time learning the algorithm. I sat with multiple papers from 8pm to 7am and was going to give up, but I decided to try implementing it in python even though I didn't understand it, and while I was halfway through doing that it finally clicked.

Accomplishments that we're proud of

I'm proud I was able to build a fluid simulator, knowing nothing about fluid dynamics, computational fluid dynamics, computer graphics, all from scratch, by myself, with only 3 hours of sleep for 2 days, while also fasting for ramadan. Regardless of what happens in the competition, I joined it only to learn, and I feel like I did that and some more over that.

What we learned

So much, I think I already covered all these things I went over that surprised me. Methods like Gauss-Seidel method for approximating solutions to equations also surprised me, using the Eulerian fluid algorithm to render beautiful vortexes was just absolutely amazing, and I learnt so much physics and math from this.

What's next for Real Time Eulerian Blood Simulator in Python

I want to work on this. It won't just be a one time thing. I think I have a passion for computer graphics growing, and I want to maybe take these methods to model maybe car flow, sewage, definitely increase the model to the 3rd dimension, and add a feature that takes a geometry and produces a vector field fitting of it, which I sadly did not have enough time to implement. I also want to experiment with combining fluid flow with ray tracing to get pretty pictures of fluids, though I do not know much about ray tracers, yet...

Built With

Share this project:

Updates