Simulation of a forest fire in Unity

This summer I decided to learn more about rockets and found an online course called Differential Equations in Action by Udacity. The first and second lessons in that course teaches you how to bring back the unfortunate Apollo 13 space ship from space to Earth. You will also learn about ABS brakes and how many people that how to be vaccinated to stop an outbreak of an epidemic. 
But sixth lesson is all about forest fires, and you will learn how to simulate a forest fire in Python. The differential equations include change in temperature from:
  • Heat diffusion
  • Heat loss
  • Wind speed
  • Combustion of wood      
I thought the simulation of a forest fire was really interesting, but it was boring to simulate it in Python. Wouldn't it be more interesting to see the forest burn in real time? Yes it would! So I decided to make a forest fire in Unity
It was really easy to translate the code from Python to Unity and make a real time simulation. The code in Python used a method called Euler forward to solve the differential equations, and Euler forward is working really well in Unity. This is the result:

The temperature at the start of the fire is about 700°C and the surrounding temperature is set to 37°C.

After about 2 minutes the fire has spread towards north-west, because the wind speed is north-west. The core temperature is now about 2500°C and the fire covers an area of  50*50 meters.

After 20 minutes the fire covers the entire area it can cover in the simulation. Notice that the forest that's not north-west of the fire has not ignited. The temperature at the edge is still between 100°C and 200°C, so you don't want to be there, but the wood has not ignited.

After 1 hour, 20 percent of the wood has gone up in flames. The trees change shape after a certain amount of wood has burned up. The core temperature is now 4000°C. 

Still smoking after 2 hours, but the core temperature has gone down to 2500°C, so the fire is dying.

After 5 hours, 70 percent of the wood has gone up in flames. The core temperature has gone down to 500°C.

The outer part of the forest fire that's not in the wind-direction has now stopped burning.

After 6 hours and 12 minutes, the last part of the forest has finally stopped burning. 

...or if you are more interested in a video (not the same fire as in the images)

Looks interesting? You can test it here: Fore Fire Simulator


  1. This is a very nice animation and a good example of how scientific computing can be useful. Would you be willing to share the actual PDEs that are solved within your program?

    1. You can find them i you take this (free) course


Post a Comment