Handling precise fluid amounts... how?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Xtrafresh
Fast Inserter
Fast Inserter
Posts: 103
Joined: Mon Jun 12, 2017 4:57 pm
Contact:

Handling precise fluid amounts... how?

Post by Xtrafresh »

My question:
How do I handle fluids in EXACT amounts reliably?

I'm looking for ways to do precise fluid handling. Hooking up a pump to enable/disable at a certain amount of fluid in a tank doesn't work, it overshoots the mark:

Image

Worse, it seems that the overshoot is wholly unpredictable, so this will not be good enough.

I thought I'd be able to work in units of 50 fluid on a reliable basis by just using barrels, but testing them quickly told me otherwise:

Image

This single unit of offset does not seem like much, but it breaks my builds rather spectacularly.

Me and a friend are on a server building the One Step Per Stop Rocket Train (OSPSRT). Basically, a Pretty big) train takes all the raw materials required, and stays with it all the way to rocket launch, performing one operation at each station.
So, I'll need to be able to pump exact amounts around at the fluid stations, to be able to do exactly ONE rocket, and no more. I've got the problems solved for item handling, but fluids

Does anyone have any methods, tips or mods that might help us?
quyxkh
Smart Inserter
Smart Inserter
Posts: 1031
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: Handling precise fluid amounts... how?

Post by quyxkh »

Use barrels.
Xtrafresh
Fast Inserter
Fast Inserter
Posts: 103
Joined: Mon Jun 12, 2017 4:57 pm
Contact:

Re: Handling precise fluid amounts... how?

Post by Xtrafresh »

Thanks, but I tried that and explain in the OP why that doesn't work.
DaleStan
Filter Inserter
Filter Inserter
Posts: 371
Joined: Mon Jul 09, 2018 2:40 am
Contact:

Re: Handling precise fluid amounts... how?

Post by DaleStan »

None of this is what you want to hear, but I'm not aware of any way to get count-perfect fluid processing. You might try single-tick pump pulses (maybe 1 tick on and then 9 off?) but I expect that will have similar issues to using barrels.
Optera's Inventory Sensor will give you different measurement results, since it rounds up instead of down, but I'm not sure that will be any better. If you're having troubles because your fluid wagons aren't emptying completely, that's what you need.

It sounds like a really neat base, and I'd love to see it when you're done, but, fluid wagons or barrels, I think you're going to have to sully your perfect plan and overload the trains. You can let the extra hang out at the destination stations, and do some cross-station circuit magic, so the oil field station (for example) knows to underload the crude wagon(s) by whatever leftover is hanging out at the refinery station, or you can let the extra hang out on the train, and use that as the signal to load less next time around.

EDIT, because my brain helpfully supplied extra information 5 minutes after I posted: OnmiFluid might be the mod you're looking for. I've never used it, though.
quyxkh
Smart Inserter
Smart Inserter
Posts: 1031
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: Handling precise fluid amounts... how?

Post by quyxkh »

Xtrafresh wrote:Thanks, but I tried that and explain in the OP why that doesn't work.
I see where you showed your attempt not working, but I don't see any attempt to explain (or understand) why. Getting every drop of liquid out of a container is a specialized task IRL too, in Factorio you use assemblers for that. There's going to be a few drops hiding in nooks in pumps and pipes and storage tanks so run a cycle or two to prime them, knowing you won't get a perfect result, and from then on you'll get full value out of the exact BOM quantities you deliver. In barrels.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Handling precise fluid amounts... how?

Post by darkfrei »

DaleStan wrote:because my brain helpfully supplied extra information 5 minutes after I posted: OnmiFluid might be the mod you're looking for. I've never used it, though.
Or Barrels Processing, where is possible do refinery fluids-in-barrels.
Xtrafresh
Fast Inserter
Fast Inserter
Posts: 103
Joined: Mon Jun 12, 2017 4:57 pm
Contact:

Re: Handling precise fluid amounts... how?

Post by Xtrafresh »

quyxkh wrote:
Xtrafresh wrote:Thanks, but I tried that and explain in the OP why that doesn't work.
I see where you showed your attempt not working, but I don't see any attempt to explain (or understand) why. Getting every drop of liquid out of a container is a specialized task IRL too, in Factorio you use assemblers for that. There's going to be a few drops hiding in nooks in pumps and pipes and storage tanks so run a cycle or two to prime them, knowing you won't get a perfect result, and from then on you'll get full value out of the exact BOM quantities you deliver. In barrels.
Oh right! It derps once or twice initially, but then never again? I'll test, if that's the case I'm saved. I'll still have a look at omnifluid though :D
Xtrafresh
Fast Inserter
Fast Inserter
Posts: 103
Joined: Mon Jun 12, 2017 4:57 pm
Contact:

Re: Handling precise fluid amounts... how?

Post by Xtrafresh »

DaleStan wrote:None of this is what you want to hear, but I'm not aware of any way to get count-perfect fluid processing. You might try single-tick pump pulses (maybe 1 tick on and then 9 off?) but I expect that will have similar issues to using barrels.
Optera's Inventory Sensor will give you different measurement results, since it rounds up instead of down, but I'm not sure that will be any better. If you're having troubles because your fluid wagons aren't emptying completely, that's what you need.

It sounds like a really neat base, and I'd love to see it when you're done, but, fluid wagons or barrels, I think you're going to have to sully your perfect plan and overload the trains. You can let the extra hang out at the destination stations, and do some cross-station circuit magic, so the oil field station (for example) knows to underload the crude wagon(s) by whatever leftover is hanging out at the refinery station, or you can let the extra hang out on the train, and use that as the signal to load less next time around.

EDIT, because my brain helpfully supplied extra information 5 minutes after I posted: OnmiFluid might be the mod you're looking for. I've never used it, though.
Thanks for the tips! I was going down the same rabbithole - cross station overflow tracking and loaders adjusting on subsequent runs... Even in concept in my head there were 50 things going wrong, let alone an actual game run.

Also thanks for the interest :)
I have the last 5 stations set up, here's a map view of them:
Image

Because of how the numbers work, every 5th train receives 2 extra RCUs and LDS's. Aside from that, it now produces a rocket and satellite with no byproducts in those last few steps. 5 Stations done, only 24 to go! :o
User avatar
Lav
Filter Inserter
Filter Inserter
Posts: 384
Joined: Mon Mar 27, 2017 10:12 am
Contact:

Re: Handling precise fluid amounts... how?

Post by Lav »

Use barrels. Just don't build a pipe between the unbarreling assembler and the pump. Attach the pump directly to the assembler, otherwise some micro-amounts of liquid will remain in the pipes, perfectly breaking your perfect count. :-)
Zavian
Smart Inserter
Smart Inserter
Posts: 1649
Joined: Thu Mar 02, 2017 2:57 am
Contact:

Re: Handling precise fluid amounts... how?

Post by Zavian »

Lav wrote:Use barrels. Just don't build a pipe between the unbarreling assembler and the pump. Attach the pump directly to the assembler, otherwise some micro-amounts of liquid will remain in the pipes, perfectly breaking your perfect count.
Personally I would expect that even in that case, floating point errors will mean that you still either gain or lose a tiny fraction of fluid, so I wouldn't expect exact amounts. Just settle for having a small surplus somewhere.
Xtrafresh
Fast Inserter
Fast Inserter
Posts: 103
Joined: Mon Jun 12, 2017 4:57 pm
Contact:

Re: Handling precise fluid amounts... how?

Post by Xtrafresh »

Zavian wrote:
Lav wrote:Use barrels. Just don't build a pipe between the unbarreling assembler and the pump. Attach the pump directly to the assembler, otherwise some micro-amounts of liquid will remain in the pipes, perfectly breaking your perfect count.
Personally I would expect that even in that case, floating point errors will mean that you still either gain or lose a tiny fraction of fluid, so I wouldn't expect exact amounts. Just settle for having a small surplus somewhere.
This is true, sadly:

Image

Those 2-ish units got stuck inside the pump due to some calculation or other on the 6th cycle of 10 barrels. How many units will get stuck, and when, is entirely unpredictable, though how that should be possible is beyond me, as Factorio is supposed to be completely deterministic. :?:

As I'm typing this, some :idea: :idea: :idea: :idea: :idea: :idea: are popping into mind:

If I use barrels, I can't control the exact amount of fluid sloshing around between barreling and unbarreling, but I CAN control the exact amount in and out of the train. The 'leakage' described above has an upper bound: once 200 fluid units have gotten stuck in it, the pump is full (god let's hope so!)

That means if I have a pre-filled buffer tank with more buffer than the combined pumps in the setup can hold, I can always insert and extract exact amounts from the setup, and the trains can keep going :D
Jap2.0
Smart Inserter
Smart Inserter
Posts: 2375
Joined: Tue Jun 20, 2017 12:02 am
Contact:

Re: Handling precise fluid amounts... how?

Post by Jap2.0 »

Xtrafresh wrote:If I use barrels, I can't control the exact amount of fluid sloshing around between barreling and unbarreling, but I CAN control the exact amount in and out of the train. The 'leakage' described above has an upper bound: once 200 fluid units have gotten stuck in it, the pump is full (god let's hope so!)

That means if I have a pre-filled buffer tank with more buffer than the combined pumps in the setup can hold, I can always insert and extract exact amounts from the setup, and the trains can keep going :D
Basically - I doubt that much would be lost even if there were floating-point errors, and I doubt that anywhere near 200 units will get stuck in the pump.
There are 10 types of people: those who get this joke and those who don't.
Xtrafresh
Fast Inserter
Fast Inserter
Posts: 103
Joined: Mon Jun 12, 2017 4:57 pm
Contact:

Re: Handling precise fluid amounts... how?

Post by Xtrafresh »

Jap2.0 wrote:Basically - I doubt that much would be lost even if there were floating-point errors, and I doubt that anywhere near 200 units will get stuck in the pump.
Well, I stopped and started the setup above a bunch of times, and it kept going up. I was at 68 units stuck in there when I stopped, after 5 minutes of clicking... I didn't feel like spending the next 10 minutes to push it all the way up to 200, but it kept going up, and the average didn't show any chance of slowing.
Jap2.0
Smart Inserter
Smart Inserter
Posts: 2375
Joined: Tue Jun 20, 2017 12:02 am
Contact:

Re: Handling precise fluid amounts... how?

Post by Jap2.0 »

Xtrafresh wrote:
Jap2.0 wrote:Basically - I doubt that much would be lost even if there were floating-point errors, and I doubt that anywhere near 200 units will get stuck in the pump.
Well, I stopped and started the setup above a bunch of times, and it kept going up. I was at 68 units stuck in there when I stopped, after 5 minutes of clicking... I didn't feel like spending the next 10 minutes to push it all the way up to 200, but it kept going up, and the average didn't show any chance of slowing.
Hm, that's odd. I might look into that sometime.
There are 10 types of people: those who get this joke and those who don't.
thedarkbunny
Inserter
Inserter
Posts: 46
Joined: Mon Oct 23, 2017 10:46 pm
Contact:

Re: Handling precise fluid amounts... how?

Post by thedarkbunny »

Did some experimenting last night and found a couple of weird behaviors re: pump outputs. Some of it looks useful:

- A pump will never hold on to more than 100 units of fluid if given a choice.
- A pump is limited by the fill level at the output. If it's connected to a storage tank (and nothing else) with 10K fluid (40% full), it will keep a maximum of 40 fluid. If the tank has 15K fluid (60% full), it'll keep a maximum of 60 fluid, and so on.
- Fluid momentum and variations in input tend to keep the number lower than the theoretical maximum, with how much lower depending heavily on the rate of flow.

TL;DR: If something is consuming the output from a pump, the amount of 'trapped' fluid goes to almost zero.
adam_bise
Filter Inserter
Filter Inserter
Posts: 441
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Re: Handling precise fluid amounts... how?

Post by adam_bise »

IIRC not all of the fluid math is visible in the GUI, I think there are fractions not represented on screen. If so, I don't know how you will achieve such precision, but your end goal may still be achievable.

What are you wanting to end up with? A completely empty supply train for every rocket? Given that fluids may not be absolutely predictable, you might settle for simply topping off a certain number of tanks on each train visit.
User avatar
Lav
Filter Inserter
Filter Inserter
Posts: 384
Joined: Mon Mar 27, 2017 10:12 am
Contact:

Re: Handling precise fluid amounts... how?

Post by Lav »

Xtrafresh wrote: Mon Sep 10, 2018 8:38 pm
Zavian wrote:
Lav wrote:Use barrels. Just don't build a pipe between the unbarreling assembler and the pump. Attach the pump directly to the assembler, otherwise some micro-amounts of liquid will remain in the pipes, perfectly breaking your perfect count.
Personally I would expect that even in that case, floating point errors will mean that you still either gain or lose a tiny fraction of fluid, so I wouldn't expect exact amounts. Just settle for having a small surplus somewhere.
This is true, sadly:

Image
(sigh)

This is so not true. I've even went and tested this, and everything works perfectly.

You see, when I write "attach the pump directly to the assembler", I usually mean you need to attach the pump directly to the assembler. And not, you know, to several pipe sections. Because it's not the pump that's leaving trace amounts of liquid, it's the pipes and liquid physics.

P. S. Hmm, unless the devs changes the way pump works between 0.15 and 0.16. That's a possibility.
Xtrafresh
Fast Inserter
Fast Inserter
Posts: 103
Joined: Mon Jun 12, 2017 4:57 pm
Contact:

Re: Handling precise fluid amounts... how?

Post by Xtrafresh »

Lav wrote: Wed Sep 12, 2018 8:19 am
Xtrafresh wrote: Mon Sep 10, 2018 8:38 pm
Zavian wrote:
Lav wrote:Use barrels. Just don't build a pipe between the unbarreling assembler and the pump. Attach the pump directly to the assembler, otherwise some micro-amounts of liquid will remain in the pipes, perfectly breaking your perfect count.
Personally I would expect that even in that case, floating point errors will mean that you still either gain or lose a tiny fraction of fluid, so I wouldn't expect exact amounts. Just settle for having a small surplus somewhere.
This is true, sadly:
(sigh)

This is so not true. I've even went and tested this, and everything works perfectly.

You see, when I write "attach the pump directly to the assembler", I usually mean you need to attach the pump directly to the assembler. And not, you know, to several pipe sections. Because it's not the pump that's leaving trace amounts of liquid, it's the pipes and liquid physics.

P. S. Hmm, unless the devs changes the way pump works between 0.15 and 0.16. That's a possibility.
Thedarkbunny's testing seems to disagree with you. Also, factorio seems to disagree, as it's displaying the trapped liquid to be in the pump, not in the pipes.

Still, if i'm wrong I'd love to hear it.

Can you show me your test setup? Can it work "perfectly" when several pumps are placed in sequence?

I suppose I could design a factory to use only pumps for pipes and tanks for corners...

Edit:
Never mind. I followed your instructions, tested for ONE cycle, et voila!
Image
Last edited by Xtrafresh on Wed Sep 12, 2018 10:15 pm, edited 1 time in total.
Xtrafresh
Fast Inserter
Fast Inserter
Posts: 103
Joined: Mon Jun 12, 2017 4:57 pm
Contact:

Re: Handling precise fluid amounts... how?

Post by Xtrafresh »

adam_bise wrote: Tue Sep 11, 2018 9:37 pm IIRC not all of the fluid math is visible in the GUI, I think there are fractions not represented on screen. If so, I don't know how you will achieve such precision, but your end goal may still be achievable.

What are you wanting to end up with? A completely empty supply train for every rocket? Given that fluids may not be absolutely predictable, you might settle for simply topping off a certain number of tanks on each train visit.
That is indeed the goal here, though it's starting to look like a utopia. For example, every 5th train produces two extra RCU's and two extra LDSs because of the production module math. I'm not quite ready to calculate backwards to see how much less of each resource every 35th train should take along as a result :shock:
Xtrafresh
Fast Inserter
Fast Inserter
Posts: 103
Joined: Mon Jun 12, 2017 4:57 pm
Contact:

Re: Handling precise fluid amounts... how?

Post by Xtrafresh »

thedarkbunny wrote: Tue Sep 11, 2018 4:55 pm Did some experimenting last night and found a couple of weird behaviors re: pump outputs. Some of it looks useful:

- A pump will never hold on to more than 100 units of fluid if given a choice.
- A pump is limited by the fill level at the output. If it's connected to a storage tank (and nothing else) with 10K fluid (40% full), it will keep a maximum of 40 fluid. If the tank has 15K fluid (60% full), it'll keep a maximum of 60 fluid, and so on.
- Fluid momentum and variations in input tend to keep the number lower than the theoretical maximum, with how much lower depending heavily on the rate of flow.

TL;DR: If something is consuming the output from a pump, the amount of 'trapped' fluid goes to almost zero.
Impressive work, thanks for this!
Post Reply

Return to “Gameplay Help”