Page 1 of 1

Using Heat Equation for pollution dispersion

Posted: Sat Aug 15, 2020 10:34 am
by fordem
TL;DR
Since i have no idea of the dispersion of pollution is done on Factorio i thought in the use o physics a simulation of a model taken from empirical observations called heat equation.
What ?
The main idea of the heat equation in a closed environment is to calculate how a the system reaches balance.
Image
alpha here also recognized as a diffusivity of the environment is a control constant.
the function u is This equation reads that given a pollution equation "u" the partial derivative of o "u" in relation to time is equation to the Laplacian operator in "u". There are some tricks and ticks to implement this when the system is no closed. But everything will go fine once u solve the equation for each new game created, once we calculate the eigenvectors, for that session in specific, the continuity of the dispersion can be easily continued with much less code.
Why ?
WHY do you think it increases the value of Factorio as a game?
Why? Well, i don't to know to what factorio members and devs aims, but i believe is always nice to have something more close to reality in a simulation game. At least Me as a phd student, i would like to give it a try. Sorry if this sugestion seems stupid.

Re: Using Heat Equation for pollution dispersion

Posted: Sat Aug 15, 2020 11:10 am
by Koub
Isn't that kind of calculations costly (in terms of CPU) ?
If this were to degrade performance, it's likely low update time cost >>> realism.

Re: Using Heat Equation for pollution dispersion

Posted: Sat Aug 15, 2020 11:20 am
by fordem
Hi, there are several forms of to solve the equation since the error precision acceptance doesn't need to be so high, this a parameter we control on the method runge kutta, the method becomes slow when the desired error precision is four decimal places but if we put only 2 decimal places the code will run much better.

Re: Using Heat Equation for pollution dispersion

Posted: Sat Aug 15, 2020 9:10 pm
by valneq
In Factorio, the value of pollution is only being tracked on a per chunk basis (32x32 tiles). When you discretize the heat equation with finite volume methods on chunks, you end up with a reasonably accurate and fast simulation.

From my observations of the game's behavior, as well as the fact that you can control the "diffusion ratio" with the map generator, I expect that this is essentially how Factorio is doing it already. So I would consider this as "implemented".

Please keep in mind that the equation given by the OP is for three dimensions and does not take into account sources (machines) nor sinks (tiles, trees, spawners) – which are crucial for a proper simulation in Factorio.

@OP: Why do you believe this is not how Factorio is doing it already?
Increasing the resolution (to have finite volume elements being a tile) could be done, but will most likely increase computational load without giving any gameplay benefits. So that would most likely not be worth it.