Let's say there's three fluid boxes: L, M, and R. L is on the left, R is on the right, M is in the middle, and they are all connected. Their build order is from right to left, so R was placed before M, and L last. (I understand that build order somehow affects the fluid update step, that fluidboxes do not get calculated simultaneously but rather serially?) They're all empty and in default state. L is size 10, M is size 20, and R is size 30 (base_area 1, 2, and 3 respectively).
Now, 10 units of a fluid with flow_to_energy_ratio=0.59 and pressure_to_speed_ratio=0.4 (the defaults) is put into L in a single tick. Can someone walk me through what actually gets calculated in the following ticks? I tried printing lots of values where I measure fluidboxes in a sort of minimod but all it did was confuse me some more.
I have tried to research this on the forums, but the best I could find was viewtopic.php?p=143780#p143780 who doesn't know, exactly. And viewtopic.php?p=125742#p125742 who says he DID figure out the math but then doesn't actually post it, just some graphs as far as I can see... The wiki's "Pipe Physics" page is woefully short on actual physics.
Storage tanks seem easy, something like this:
Code: Select all
// update flow based on previous flow & pressure difference
// (why is base_area given in 10 liquid units?)
flow = flow*fluid.flow_to_energy_ratio + fluid.pressure_to_speed_ratio*(A.amount/A.base_area - B.amount/B.base_area)
A.amount -= flow
B.amount += flow
But with pipes it's different(?!). There's some extra factor(s) here I can't account for. I can't figure out why their flow is so high and then how it "breaks" in edge cases, with different build orders or around a corner. I can have a line of pipes, "magically pumped full" with 10 units every tick in one end, drained completely in the other, and the liquid will end up "equalizing" on totally different values depending on the order I set it up and it all just hurts my brain trying to "reverse engineer" it.