[1.1.61] Numerical instability for fluidboxes smaller than 100 units

Bugs that are actually features.
Post Reply
swni
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Sat Mar 05, 2016 1:54 am
Contact:

[1.1.61] Numerical instability for fluidboxes smaller than 100 units

Post by swni »

Not sure if this is a "bug", but as far as I searched it doesn't seem to be a known issue.

In the SpaceEx mod, you can configure the "space pipe" to have sizes from 50 to 150 units, which is done by changing the "base area" of the fluidboxes.

I had a completely static network (only tanks and pipes, no machines / pumps / other sources or sinks) and found that rather than the fluids settling down to a common level, if the pipe capacity was 50 units, then fluids would rapidly slosh back and forth between them at several Hz. At higher capacity the sloshing was less severe, until at 100 capacity or higher it disappeared entirely.

The most reliable set up to cause oscillation was a single (vanilla) tank with a chain of three pipes coming out of one port. Having multiple tanks would stabilize the fluid level in the pipes connecting them (but not in pipes attached to only one tank).

Sometimes sloshing occurred in a network with pipes but no tanks at all. Other times the fluids would stop sloshing and stabilize, but with wildly disparate amounts of fluid in adjacent pipes (e.g. a 40 / 50 pipe touching a 15 / 50 pipe, but no flow).

Here is a video with a fluid network having only a tank and six pipes, yet with rapid fluid oscillation. You can see other fluid networks in the shot similarly oscillating.

https://www.youtube.com/watch?v=9ndZsIt8cco

Presumably Factorio's fluid calculations uses an explicit integration method akin to FTCS:

https://en.wikipedia.org/wiki/FTCS_scheme#Stability

Here, delta x is analogous to the fluidbox area; when it is too small, the calculation becomes unstable. This can be solved by decreasing alpha (i.e., fluid velocity), decreasing delta t (i.e., calculating fluids more often), increasing delta x (i.e., not supporting small fluidboxes), or changing to an implicit integration scheme: https://en.wikipedia.org/wiki/Finite_di ... cit_method which is always stable, at the cost of greater computation time.

Of course there are doubtless many other complications in the Factorio fluid simulation.... Or there could be something else entirely going on.

Anyhow, I resolved the issue for myself by setting the capacity to 100 units.
Attachments
factorio-current.log
(58.44 KiB) Downloaded 65 times

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2252
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.1.61] Numerical instability for fluidboxes smaller than 100 units

Post by boskid »

Ref: 101501, (maybe 97338 but not strictly: there was a full fluidbox transfer happening due to decreased area)

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2252
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.1.61] Numerical instability for fluidboxes smaller than 100 units

Post by boskid »

Thanks for the report. Unfortunately i am not considering this to be a bug, this is an inherent limitation of the way we perform fluid flow and the only way to fix this would be to rework entire fluid flow logic which is not going to happen any time soon.

Post Reply

Return to “Not a bug”