Does fluid/electricity flickering affect ups?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
User avatar
Qilili
Inserter
Inserter
Posts: 24
Joined: Wed Mar 01, 2023 2:47 pm
Contact:

Does fluid/electricity flickering affect ups?

Post by Qilili »

If you use circuit network conditions to change active volume without buffering, like "if tank > 20K : enable pump" and fluid will go back-and-forth fast around this number, does it have any negative consequences? Besides "not pretty".

Same for electricity with accumulators.
Last edited by Qilili on Sat Mar 25, 2023 6:44 am, edited 2 times in total.

User avatar
jodokus31
Smart Inserter
Smart Inserter
Posts: 1599
Joined: Sun Feb 26, 2017 4:13 pm
Contact:

Re: Does fluid/electricity flickering effect ups

Post by jodokus31 »

Don't know, if UPS is tanked, but probably yes.
Here is a tip for the "not pretty" part
https://wiki.factorio.com/Tutorial:Circ ... er_version

mrvn
Smart Inserter
Smart Inserter
Posts: 5681
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Does fluid/electricity flickering effect ups?

Post by mrvn »

The term you are looking for is called hysteresis.

I'm not sure about the fluid system as I think that never sleeps. As soon as you have more than a pipe the fluid remains in motion at all times but the delta just gets incredible small.

The circuit network though has code that activate only when a signal changes. So a wire connected to a tank will update the signal every tick and that needs processing.

For power it is the worst I think. Every time you change a power switch the whole electrical network changes. The histogram on one side disappears and the entities are merged into a larger network. Solar panels might have to be recounted unless the code is smart enough to see when a panel is in both network and can merge the total number of panels smartly. Entities also slowly drain their internal buffer when they loose power and recharge it when they get power back. Once recharged their power demand changes to what they consume each tick. So there is a ton of extra work happening when your power switch flickers.
hysteresis.png
hysteresis.png (230.51 KiB) Viewed 1198 times
You can build a slow switch with or without hysteresis using 2 inserters, some belts, a wooden chest and any item. You configure one inserter to remove the wood when you have > 20k in the storage tank and the other to put it back with the reverse condition. Just the delay created by the belt will reduce the flickering, which is probably good for fluids. For power I would go for a hysteresis setup: Configure the second inserter to put the wood back when the tank is <10k. Then the factory with only switch back on when 10k has been produced or consumed, which will be far less often.

Note: you use the presence or absence of the item in the wooden chest to turn on/off the pump or switch.

User avatar
Qilili
Inserter
Inserter
Posts: 24
Joined: Wed Mar 01, 2023 2:47 pm
Contact:

Re: Does fluid/electricity flickering affect ups?

Post by Qilili »

So, the answer is "fluid may be not (it is already always moving), electricity most likely yes" (affects ups)


Nice trick with chest, but at this point you can as well just use 2-3 deciders.

User avatar
jodokus31
Smart Inserter
Smart Inserter
Posts: 1599
Joined: Sun Feb 26, 2017 4:13 pm
Contact:

Re: Does fluid/electricity flickering affect ups?

Post by jodokus31 »

The chest trick seems nice, if you haven't researched "circuit network" / "combinators".
You just have to have a blueprint and wires are build just fine.

And I like it visually.

mrvn
Smart Inserter
Smart Inserter
Posts: 5681
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Does fluid/electricity flickering affect ups?

Post by mrvn »

Yes you can use 2 combinators for a hysteresis. It's more useful without it, just as a slow switch.

But I like the visuality of it. Works great with an upgrade planer (green) or deconstruction planer (red) as item.

You can also use just a belt loop and read/hold instead of the chest. That way it doesn't even need power and you can put it on the side of a power switch that gets cut off.

Tertius
Filter Inserter
Filter Inserter
Posts: 650
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: Does fluid/electricity flickering affect ups?

Post by Tertius »

An attempt to answer the OP:
"Fluid flickering" if meant as toggling some pump every tick, isn't relevant to UPS, because fluid behavior is calculated anyway and fluidboxes are not going to sleep internally. The pump state just determines if fluid is transferred from its input to its output or not. One more operation per pump, and as long as you don't have 100000 pumps, it will probably not affect UPS. So just use a simple ">20K" condition without hysteresis.

"Electricity flickering" if meant as connecting/disconnecting electric networks with a power switch will probably affect UPS, because if 2 disconnected networks are being connected if you activate a power switch, the merging will consume some additional CPU the tick the switch is toggled. The same with disconnecting, when 1 electric network is being split into 2. Separating networks and occasionally (less than once a second) switching off inactive parts of a factory might improve UPS, because unpowered entities might go to sleep and not consume any CPU on update, but if you frequently toggle a power switch (every other tick), the overhead of merging/splitting the network is probably bigger than the savings with entities going inactive.

I bet people made benchmarks about this in the past.

I separated electric networks for smelter arrays. If the output chests of a plate smelter train station are full, or if the input chests are empty and no plates are flowing out of the smelters any more, I turn off all the electric furnaces and all their beacons. Looks smart, saves some MW of power if inactive, and I have the illusion that I optimized my factory. Dunno if this is really the case.

User avatar
Qilili
Inserter
Inserter
Posts: 24
Joined: Wed Mar 01, 2023 2:47 pm
Contact:

Re: Does fluid/electricity flickering affect ups?

Post by Qilili »

Tertius wrote:
Sat Mar 25, 2023 3:15 pm
Separating networks and occasionally (less than once a second) switching off inactive parts of a factory might improve UPS, because unpowered entities might go to sleep and not consume any CPU on update
I remember reading recently that it is opposite, unpowered entities are not sleeping because they are checking for power. So that "unpowering is very bad for ups".

User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 310
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: Does fluid/electricity flickering affect ups?

Post by Stringweasel »

Seperate networks are not good for UPS, but if you only have 3 then it's neglible. This has been tested.

All this talk is theorizing though, which is usually quite inaccurate because we don't know the source code, and optimization is hard.
Alt-F4 Author | Factorio Modder
Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby

Post Reply

Return to “Gameplay Help”