Dominik wrote: Sat Sep 15, 2018 2:23 pm
I try to follow realism (which automatically makes stuff intuitive)
Well, the problem that it sometimes doesn't. Case in point : Liquids slowing down over long pipe distances is realistic, but not that intuitive.
Vxsote wrote: Sat Sep 15, 2018 4:02 pm
However, if you are only simulating flow at each tick by moving some of the volume of the fluid in each segment to its neighbors, and limiting the calculations to (0 - max volume) per segment, then you have effectively put a cap on throughput as a function of the simulation tick rate. That is undesirable, and in general you don't want there to be a relationship like that.
It doesn't seem to be a big issue though? AFAIK, this is exactly how electric pump's maximum throughput is currently determined : it's 200 L (the pump's capacity) x 60 ticks/s = 12kL/s !
(electric pumps ignore fluid mechanics on their input - meanwhile offshore pumps don't even have a fluidbox!)
Some people here seemed to wish for pressure, height, viscosity to be simulated by the game's fluid mechanics... but they
already are !
As a reminder, here's what a Factorio fluid system currently looks like :

(pump disabled)
And the formula is :
Flow = (Pressure_A - Pressure_B) * 0.4 + Limited[Previous_Flow * 0.59, Target_Capacity * 0.1]
Where 0.4 is the
pressure_to_speed_ratio and 0.59 is the
flow_to_energy_ratio, which seem to account for things like the fluid's viscosity, and which, while are the same for all the fluids in vanilla, have had mods experiment with changing these values (at least Bob's mods).
Anyway, IMHO, fluids just suffer from a very bad image problem.
(People have an issue, ask about it, get answered "Oh yeah, fluids are too complicated to understand anyway!")
But might completely redoing their mechanics be perhaps an overkill ?
What are the current issues that people seem to have with fluids ?
From most common to least common (IMHO) :
1.) Production stopping because of one of the fluids backing up in the refinery/output fluid network.
Not even a fluid problem, but an assembler-with-multiple-outputs problem!
(see Angel's ore crushing/sorting for a similar issue with items)
Solution : Not sure, but probably not relevant to the discussion at hand anyway.
2.) Fluids not flowing because 0.001 L of a different fluid is blocking the flow somewhere.
Solution : Seems like moving fluids from floats to integers might help ? (As well with UPS?)
(Would also solve a plethora of, less common but still annoying, signal-related problems !)
As well as making sure that the Alt-view clearly shows where the offending "intruder" is ?
I don't understand why fluids have to be so granular? Especially after their unit having been divided by 10 ?
(BTW, is the Offshore Pump producing 1/10 of Electric Pump's max flow by design, or an oversight after that change?)
If they do need a lot of granularity, maybe dividing the units by 10 again would be enough ?
3.) Machines not working well because of limited fluid throughput due to overlong pipes.
Honestly, I have a bit of a hard time in believing this one*
- considering that you need to reach more than 18 pipes between pumps for the throughput to drop under offshore pump's 1.2kL/s one,
- that the first thing that you get told when asking for help is to use underground pipes instead (which increase that distance to a pretty comfortable 99 tiles (> 3 chunks),
-
and that you need to reach a good 350-400 pipes (~1900-2200 tiles ~60-69 chunks!) for the flow rate to drop to half that (and that's after the capacitive/flow breakpoint!),
So I'd very much like to see a pre-rocket-launch base that has run into these issues !
(No really, I insist! Otherwise I will just consider this as a perception problem. Blueprints / Save files please ! (and of course only QoL mods!))
Solution :

Why is debug's mode
show-fluid-box-fluid-info doing a so much better job of showing what happens than the normal game view ?!?
- First, it seems that there's some bug where you have sprites that still show quite a bit of fluid, while there's no (or almost none) actual fluid in the pipe left. Maybe fix that first?
(Or is that a fancy non-linear display? Integer fluids might solve that issue then?)
- Second, I see that you used the great idea to represent the flow speed by bubbles. Maybe make them even more apparent? (Would a good non-linear scaler for fluid speed / bubble speed do the job ?)
Maybe try adding more fluid viewpoints?
(One issue is that on a high-throughput-optimized fluid network, you'll hardly have any viewpoints left, as you're only going to have straight pipe segments if there's only 1-2 tiles left to connect, and the undergrounds are not long enough.
How to display fluid/flow on them?
Then maybe it's less of an issue, as by that point the player will
hopefully be experienced enough with fluids to debug the problem ?
BTW, what are the current ways to measure fluid flow speeds by the circuit network? There needs to be one !)
*
One exception : Fluid Tanks - If I understand the issue correctly, their very high capacity (250 pipes!) for the same pressure means that, once their level has equalized, it becomes very hard to make them vary their pressure, which also severely limits their flow!
Solution : it might look weird, but maybe they should show the flow in the same way as pipes? (via bubbles)
4.) Fluid not being equally distributed at junctions (and not "randomly", but in a specific cardinal-directional order) :
Again, concrete examples of the issue In Real Factorio Spaghetti please !
Sure, you might have some assemblers working faster than others, but that will only happen if your flow is insufficient to start with, otherwise, the fluid will just back up and the problem will be solved in a short order.
I mean, IIRC inserters have similar issues, but
only when placed in separate chunks, which is an issue even worse to debug, because good luck finding the difference if you don't play with debug's
show-tile-grid ON !
5.) Megabase UPS issues.
First, this is only a concern for a tiny minority of players that get to that point.
Second, the FFF mentions nuclear reactors (and by extension, boilers using itemized fuel), but I don't see how
any solution could have
any chance to compete with the O(2) complexity of solar+accumulator !
(Unless of course Solar is reworked for have
so high of a tile footprint impact, that megabases start running into RAM issues... which would probably just turn into a who-can-afford-the-most-RAM race!)
That leaves petrochem... which AFAIK has much lower flows... so what's the issue with using barrels as much as possible? ("Cold" Steam barelling for Coal Liquifaction and/or barrel temperature support, please?)
-.) If I forgot any other problems with fluids, please add them?
Now, about possible optimizations :
As been pointed out in the FFF (and
on Reddit), moving from an "every pipe is simulated in that pipe network" to "only simulate inputs/outputs of that network" idea runs into the snag that fluid producers/consumers do not work in flows, but in pulses.
Well, might we be so bold as to propose that the fluid producers/consumers should work in flows instead ?
For instance :
- The input items are consumed all at the start of the production cycle.
- The input fluids are consumed during the whole cycle.
- The output items are generated all at the end of the cycle.
- The output fluids are generated during the whole cycle.
EDIT : Damn, ninjaed by Quarnozian ! That will teach me to proofread for an hour !
What would be great, would be to have
two different Fluid Systems accounting for the different states :
During the
Transient State, the
Fluid Network would work roughly as now, with
every pipe being simulated at each tick, with the fancy fluid level waves seen above, etc.
After a while, the
Fluid Network would settle into a
Steady State, with
only the input/output flows from producers/consumers being calculated. This would be probably even more efficient than the FFF's newly proposed system (no need to calculate the junctions every tick!).
Of course, any
change in that network's inputs/outputs would make it
switch to the Transient State again, until it stabilizes again into a
new Steady state.
And the Megabase owners will make their damned sure that this happens as rarely as possible !
If I'm not mistaken, this would be similar to how belts work after their recent(?) rework ? (Though the fluids would not even necessarily need to be "compressed"(=pipes full) in this case!)
I would like to point out that what seems to be the difference between my proposition, and the other similar ones
(though there are so many of them that I might have missed it),
is that
it's the Transient State "settling down" that "calculates" what the Steady State is going to be.
(Determining when to "freeze" it might be the tricky part...)
(As a reminder, producers/consumers working with flows rather than in pulses, should solve the commonly raised "but the network would never be steady!" complaint.)
A final note/question about multithreading/GPU : if I'm not mistaken, multithreading the different fluid networks is currently very hard because they have to "check back" with the global simulation each tick?