Have pumps be able to measure throughput

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Post Reply
foamy
Filter Inserter
Filter Inserter
Posts: 432
Joined: Mon Aug 26, 2019 4:14 am
Contact:

Have pumps be able to measure throughput

Post by foamy »

I've been mucking about trying to get a working flow measurement system for fluids. There's various implementations that can be done with tanks and pumps and the circuit network, but they're all space-consuming, flow-restricting, and imprecise due to things like fluid flow level scaling, circuit delays, and so on.

Measuring flow through a pipe itself directly might have problems because pipes and tanks are bi-directional.

Pumps, however, are not. Further, they are already a circuit network element.

I propose simply adding another mode of operation, analogous to belts, that sends a per-tick pulse signal of the amount of fluid moved. I think it ought to be straightforward, particularly with fluid mechanics changing Soon(tm).
Last edited by foamy on Tue Sep 17, 2019 6:26 pm, edited 1 time in total.

kbk
Long Handed Inserter
Long Handed Inserter
Posts: 58
Joined: Sun Jun 30, 2019 2:21 pm
Contact:

Re: Have pumps be able to measure throughput

Post by kbk »

Looks useful to me.

Vegemeister
Long Handed Inserter
Long Handed Inserter
Posts: 85
Joined: Sun Dec 04, 2016 9:18 pm
Contact:

Re: Have pumps be able to measure throughput

Post by Vegemeister »

Here's a throughput-measuring contraption that works up to 6000 fluid/s and is precise to the number of significant figures provided by the production screen:
meter.jpg
meter.jpg (155.24 KiB) Viewed 1750 times


Leave off the bottom section, and you get pulse output like from a belt.

It's off by a tiny bit compared to the values given on the wiki for pipe throughput. Someone who knows more about the fluid movement algorithm and the fixed-point representation of fluids could probably improve it.

foamy
Filter Inserter
Filter Inserter
Posts: 432
Joined: Mon Aug 26, 2019 4:14 am
Contact:

Re: Have pumps be able to measure throughput

Post by foamy »

Vegemeister wrote:
Wed Sep 18, 2019 3:22 pm
Here's a throughput-measuring contraption that works up to 6000 fluid/s and is precise to the number of significant figures provided by the production screen:

meter.jpg



Leave off the bottom section, and you get pulse output like from a belt.

It's off by a tiny bit compared to the values given on the wiki for pipe throughput. Someone who knows more about the fluid movement algorithm and the fixed-point representation of fluids could probably improve it.
I'll give that a shot. My own test of a similar count-the-pump cycles idea ran into the issue that the pump flow varies with the fluid level in each tank, so to get it to a constant value you need to very tightly limit the amounts, and because you want precision you need enough time for the result of turning the pump on to be fed back to the pump before it runs again. I wound up running it on a clock and triggering the pump only every four ticks for ~200 per tick, which worked but limited flow to ~3000/s.

Even if it works, though, I think it goes to show how ugly setups need to be, v. just running a wire to a pump.

EDIT: It does run, and is *almost* precise; it reads very slightly high, because fluid accumulation in the discharge tank slows the pump down from the 200-80-100 cycle the circuitry assumes.

EDIT2: Restricting the circuitry to run only if the input tank is bone dry achieves significantly better precision; error was reduced by ~2 OOM. However this comes at a flow cost; peak rate is around 50 per tick, i.e 3,000 units/sec. Tuning the limit to 200 in the discharge tank allows full flow and is more precise than the default print by about 1 OOM.

coppercoil
Filter Inserter
Filter Inserter
Posts: 472
Joined: Tue Jun 26, 2018 10:14 am
Contact:

Re: Have pumps be able to measure throughput

Post by coppercoil »

Vegemeister wrote:
Wed Sep 18, 2019 3:22 pm
Pump moves:
200 u on first tick
80 u on 2nd tick
100 u after that
My experiments shows that pump fluid dynamics is slightly more complex. Once pump has stopped, it needs to sleep at least 3-4 ticks to be able to restart by "standard" sequence. If we have 1 tick delay, pump moves:
200
80
100
0 <- delay
160 (not 200)
100 (not 80)
100

2 t delay: 200, 80, 100, 0, 0, 195, 100, ...
3 t delay: 200, 80, 100, 0, 0, 0, 200, 82 (???), 100, ...

There may be even more combinations.

User avatar
MEOWMI
Filter Inserter
Filter Inserter
Posts: 309
Joined: Wed May 22, 2019 12:21 pm
Contact:

Re: Have pumps be able to measure throughput

Post by MEOWMI »

There's definitely some more to it, although I can't tell what.

I made three attempts to measure 3.0k of fluid using Vegemeister's and foamy's setup and measured 2.2k, 2.0k, and 2.2k of fluid, so suffice to say, for measuring exact quantities this setup seems to be insufficient. Pumping through 25k also only measured 18k and setting the output limit to 1.0k instead of the bone-dry 0 just measured 17k.

Edit: the above was using the tick measurement, which seems to be a lot more unreliable than the flow measurement the apparatus provides. I pumped through 150 tons of fluid in 67,14 s and 67,20 s on two separate attempts (1.2k and 1.0k settings on the input and output) and the flow measurement was definitely accurate to within the range reported by Vegemeister, averaging around 2200 (2234) units/s. The flow per tick pulse however was very different, only measuring 108k both times, or 28% less than the actual value. Adjusting the tick value by a factor of 1.389 gives a much better result, both at total volumes transferred of 2.6k, 25k and 150k, however, the error is still nearly 5% at lower values, but down to only 0.1% for the largest. Also worth clarifying that this only applies at maximum transfer rates.

Post Reply

Return to “Ideas and Suggestions”