bobingabout wrote: ↑Thu Dec 06, 2018 9:52 am

doesn't "Hardcoded" simply mean that it's part of the base game mechanics, and can't be edited by a mod?

if so, then all fluid flow is hardcoded.

No i meant that there would be a part of the formula that was hard coded in such a way that increasing fluid flow between two zero level pressure entities wouldn't be possible.

This is clearly not the case now that you guys made me aware of the fact the parameters are hidden inside each fluid.

bobingabout wrote: ↑Thu Dec 06, 2018 9:52 am

I'm not a pipe expert, but I'm fairly sure there is a percentile element to it, as fluids will flow faster from 1 tank to another than they do from 1 pipe to another.

Yes, when i learned of "pressure_to_speed_ratio" here it all fell into place for me and

THIS thread all of a sudden made sense.

Neutral (not pumped, same base level) fluid flow isn't based on amount contained in neighboring entities. It's based on their pressures.

A pipe that has 100 fluid capacity and 50 fluid in it has 50% pressure.

A storage tank that has 25,000 fluid capacity and 5,000 fluid in it has 20% pressure.

For all intents and purposes, storage tanks and pipes are identical in this respect. It's the pressure differences that matter. (as in, how full are they in percent)

It shouldn't matter if the adjoining entities are tanks or pipes. The rate of transfer is the same, the difference is how fast they reach a near equal pressure level.

First, let's look at two pipes next to each other. And ignoring all inertia calculations for now.

Code: Select all

```
Pipe capacity = 100
pressure_to_speed_ratio = 0.4
pipe A = 100 fluid
pipe B = 0 fluid
Tick 1: (100-0)*0.4 = 40 fluid moves from A to B
Tick 2: (60-40)*0.4 = 8 fluid moves from A to B
Tick 3 (52-48)*0.4 = 1.6 fluid moves from A to B
```

Now, let's look at two tanks next to each other. Still ignoring inertia.

Code: Select all

```
Tank capacity = 25,000
pressure_to_speed_ratio = 0.4
tank A = 25,000 fluid
tank B = 0 fluid
Tick 1: (100-0)*0.4 = 40 fluid moves from A to B
Tick 2: (99.84-0.16)*0.4 = 39.872 fluid moves from A to B
Tick 3 (~99-~1)*0.4 = ~39 fluid moves from A to B
Tick 4 (~99-~1)*0.4 = ~39 fluid moves from A to B
Tick 5 (~99-~1)*0.4 = ~39 fluid moves from A to B
...
```

So as you can see, tank to tank will move more fluid per second than pipe to pipe hence why i assumed higher capacity = higher neutral transfer rate.

But what really happens is that the pressure differences just stay high for longer. So more fluid is moved because of that.

Note, without your answers, i would "never" have figured this out. (as in, i would have given up on it until 0.17 hit)

bobingabout wrote: ↑Thu Dec 06, 2018 9:52 am

Just keep in mind that the entire fluid system is currently being re-written for 0.17.

eradicator wrote: ↑Thu Dec 06, 2018 2:03 pm

It's been quite a while since i experimented with this, but i remember i succeeded at making fluids flow really fast (i.e. like 100 times faster). I don't remember the details, but the fluid itself has some related values:

Code: Select all

```
pressure_to_speed_ratio = 0.4,
flow_to_energy_ratio = 0.59,
```

All base game fluids have the exact same values, but you can mod them. That said any modding you do on this now is probably going to be completely worthless when 0.17 comes with the new system ^^.

I am impatient. Also, not sure the fluid mechanics themselves are changing in 0.17, only the optimizations. That's what i take away from the FFF.

Also, modding it is practically a one liner.

mod/data-final-fixes.lua:

Code: Select all

```
for k, v in pairs(data.raw.fluid) do
data.raw.fluid[k].pressure_to_speed_ratio = 0.6
end
```

See above formulas for their effects. Again reminding everyone that inertia plays up to a part in it.

So for the FINAL calculations then... Inertia.

0.59 or 59% of the fluid transfer is down to inertia. As in, in tick 2, 59% of the last fluid movement will be added to the flow of tick 2.

40 + 40*0.59 = 63.6 fluid moves from A to B.

BUT, inertia is limited to 10% of the targets (B) capacity. 10% of 100 is 10 so the actual transfer between two pipes, assuming pipe A is still full and pipe B is empty in tick 2 would be 50.

With my 1000 capacity pipes, the math comes down to...

40 + min(40*0.59, 1000*0.1) = 40 + 23.6 = 63.6 as 63.6 is less than 100.

If one iterates that last calculation, one gets...

Code: Select all

```
63.6
77.524
85.73916
90.5861044
93.445801596
95.13302294164
96.1284835355676
96.7158052859849
97.0623251187311
97.2667718200513
97.3873953738303
97.4585632705599
97.5005523296303
97.5253258744819
97.5399422659443
97.5485659369072
97.5536539027752
97.5566558026374
97.5584269235561
97.5594718848981
97.5600884120899
97.560452163133
97.5606667762485
97.5607933979866
97.5608681048121
97.5609121818391
97.5609381872851
97.5609535304982
97.5609625829939
97.5609679239664
97.5609710751402
97.5609729343327
97.5609740312563
97.5609746784412
97.5609750602803
97.5609752855654
97.5609754184836
97.5609754969053
97.5609755431741
97.5609755704727
97.5609755865789
97.5609755960815
97.5609756016881
97.560975604996
97.5609756069476
97.5609756080991
97.5609756087784
97.5609756091793
97.5609756094158
97.5609756095553
97.5609756096376
97.5609756096862
97.5609756097149
97.5609756097318
97.5609756097417
97.5609756097476
97.5609756097511
97.5609756097531
97.5609756097544
97.5609756097551
97.5609756097555
97.5609756097557
97.5609756097559
97.560975609756
97.560975609756
97.560975609756
97.5609756097561
<LAST VALUE REPEATS FOREVER>
```

C# code for above output

Code: Select all

```
double transfered = 40;
for (var i = 0; i < 1000; i++) {
transfered = 40 + Math.Min(transfered * 0.59d, 100);
Console.WriteLine(transfered);
}
Console.ReadKey();
```

And that's where my 97.5 comes from.

**In summary (AKA TL;DR)**
To simplify EVERYTHING, there's two parts to the simulation.

The main part is "pressure_to_speed_ratio", it defines how much fluid can move per tick between two fluid boxes per liquid.

A value of 0.4 means at MOST 40 units can move between two fluid boxes per tick.

The more equal in level the two fluid boxes are, the less is moved between them.

The second part is "flow_to_energy_ratio", it defines how much MORE fluid is moved if fluid is flowing regularly from one fluid box to another.

A value of 0.59 means that for every tick, another 243% of the main part can move per tick. As long as 10% of the target fluid box capacity is still higher than the resulting value.

For vanilla tank to tank transfers, the maximum flow rate is 97.5 fluid/t

For vanilla pipe to pipe transfers, the maximum flow rate is 50.0 fluid/t, this because the pipes capacity is too small for the maximum inertia bonus.

If one alters "pressure_to_speed_ratio" on a particular fluid they change the base speed of said fluid.

And if one alters "flow_to_energy_ratio" they are changing the max bonus speed gained from moving said fluid continually.

THANK YOU GUYS!