## Another approach to Cable Resistance (with fluid network)

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

ske
Filter Inserter
Posts: 409
Joined: Sat Oct 17, 2015 8:00 am
Contact:

### Another approach to Cable Resistance (with fluid network)

The topic of cable resistance has been discussed before in
"Cable Resistance / Non-looseless Power Transmission"
viewtopic.php?f=80&t=15546&p=145539
and the show-stopper was the time-complexity of calculating a Flow network
https://en.wikipedia.org/wiki/Flow_network
.

I'd like to propose another approach which works like the water flow in pipes: You give every pole a small capacitance and every cable a resistance. Instead of calculating the equilibrium state with the complex algorithm, at each update cycle you only calculate the flow between each pair of connected poles. (Difference in voltage divided by the connecting resistance gives the current. Sum of currents times update time divided by capacitance gives the voltage in the next frame.) I assume this is how the pipe network works.

In order for these differential equations to converge using the incremental solution the RC-constants should be larger than the update time. With a constant consumption the whole network should converge against the real flow network solution. The solar cells and batteries couldn't be treated as one big thing anymore but they could be lumped together into local (neighboring) groups, which wouldn't be too bad.

This would enable great things like:
* having to plan your power distribution on large maps
* separating low-voltage and high-voltage networks for local and distant energy distribution
* having the transformer translate between the two networks

Flight
Burner Inserter
Posts: 9
Joined: Mon May 02, 2016 7:45 pm
Contact:

### Re: Another approach to Cable Resistance

I think it would be fun.

immibis
Filter Inserter
Posts: 301
Joined: Sun Mar 24, 2013 2:25 am
Contact:

### Re: Another approach to Cable Resistance

This is how RedPower 2's blutricity worked.

The problem is that you need lots of capacitance - because e.g. all the power you want to draw from a pole in a tick has to be stored in that pole.

But then it takes a really long time for all the poles to charge up/discharge.

bobucles
Smart Inserter
Posts: 1657
Joined: Wed Jun 10, 2015 10:37 pm
Contact:

### Re: Another approach to Cable Resistance

Fluid dynamics, in my electrical system? I don't think that would fit very well here.

You can do nifty things with fake "hydraulic" power- I.E. a liquid that stores its power using temperature. It is not impossible to have a structure powered by such a material. In such a situation you would need a pipe network to process hydraulic power. But if every single thing depended on it, the complexity of your factory would skyrocket. It'd be way too difficult for a newbie at least.

ske
Filter Inserter
Posts: 409
Joined: Sat Oct 17, 2015 8:00 am
Contact:

### Re: Another approach to Cable Resistance

immibis, yours is a valid concern, I will have to look into that in more detail to explore how big of a problem that is in typical factorio maps.

One thing that could help is not storing all energy "in the pole" but to store some energy in the consumer or direclty creating a slow ramp-up and ramp-down of consumption. The problem is not the power draw as such, it is the fast changes in current and the reaction to fast changes voltage which can cause positive feedback and lead to oscillations.

In the end we don't have to simulate reality directly but we are free to do some adjustments to make it work.

ske
Filter Inserter
Posts: 409
Joined: Sat Oct 17, 2015 8:00 am
Contact:

### Re: Another approach to Cable Resistance

bobucles wrote:Fluid dynamics, in my electrical system? I don't think that would fit very well here.
Fluid networks with vanishingly small storage capacity act like a real electrical network. The problem is that the electrical network is too complex to simulate accurately, so I'm suggesting a trick to get the same effect. For the player both things should look the same.
bobucles wrote: You can do nifty things with fake "hydraulic" power- I.E. a liquid that stores its power using temperature. It is not impossible to have a structure powered by such a material. In such a situation you would need a pipe network to process hydraulic power. But if every single thing depended on it, the complexity of your factory would skyrocket. It'd be way too difficult for a newbie at least.
That is a whole new idea. I don't know if hydraulic or pneumatic power has been suggested before. It would totally make sense... but then again offshore pumps need no fuel

ssilk
Global Moderator
Posts: 12262
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

### Re: Another approach to Cable Resistance (with fluid network)

I have fixed the topic a bit.

Indeed an interesting idea... the problem is: The current fluid simulation is not very accurate. For example if there is low supply the fluid likes to turn left.

Hm.

Let's say there is a fluid simulation like so: Each chunk is connected with four neighbor-chunks other over a piece of pipe.
For every chunk the consumption and production and the in- and outgoing power is counted. Not every tick, more once in 10 secs. The question is here: Does the chunk in sum suck or fill liquid into the pipe?
We calculate also the incoming and outgoing streams from/to the 4 other chunks.

Then we let the fluid simulation run. The measured flow is then the resistance (R = U * I, where I is here the flow and U is constant for simplicity). That effects how much energy will be lost, when flowing from chunk to chunk, until nothing is left anymore.

As already mentioned: That needs to be calculated only every 1-10 seconds or so. (This is realistic! In reality this is the same, there the cable buffers some electrical overload, before there is the danger, that the cable smelts, so the regulation must not be really fast)
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

walljaik
Inserter
Posts: 41
Joined: Fri May 06, 2016 9:24 pm
Contact:

### Electric energy loss due per distance

Joined with this thread, cause basically the same idea -- ßilk

basically the idea is to copy pipes system, pressure decreases per tile, to electric network. would be more realistic and have sense. Like pump take 1 tile straight so you need 2 tiles to turn electric network needed an item without electric range or then you would have minimum energy or none at some kind of limit range. More poles more energy to their range? Range of loss variations depending of energy production but with max distance? Diferent kind of pole for more distance like now but more cable capacity? sry low english level.
hope to see some good response other than no thanks or already said. In the FSI section isnt mention.

Maja153
Inserter
Posts: 41
Joined: Wed May 11, 2016 12:03 pm
Contact:

### Re: Electric energy loss due per distance

This sure makes sense and would add realism, but it is rather hard to pull off in my opinion.
Good idea tho!

Sean Mirrsen
Long Handed Inserter
Posts: 86
Joined: Wed Apr 27, 2016 6:30 pm
Contact:

### Re: Electric energy loss due per distance

On the surface, this wouldn't be that mechanically difficult - just decrease the power supplied by a given power pole by a percentage based on how many "jumps" the power pole is away from the nearest power provider. So, the huge steel power towers make for less power loss over distance because their jumps are longer. The difficulty comes in when determining available power in a grid with multiple sources - like a steam powerplant on one end, and a solar farm on another. Each pole would have to individually sum up the power gained from each source, which, in a large factory with potentially hundreds of solar panels, accumulators, and steam engines, plus thousands upon thousands of power poles, would create a fairly noticeable performance sink unless seriously optimized somehow.

Koub
Global Moderator
Posts: 6542
Joined: Fri May 30, 2014 8:54 am
Contact:

### Re: Electric energy loss due per distance

Koub - Please consider English is not my native language.

ssilk
Global Moderator
Posts: 12262
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

### Re: Another approach to Cable Resistance (with fluid network)

I joined the above thread into this one.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

walljaik
Inserter
Posts: 41
Joined: Fri May 06, 2016 9:24 pm
Contact:

### Re: Another approach to Cable Resistance (with fluid network)

thanks ssilk

Rseding91
Factorio Staff
Posts: 11923
Joined: Wed Jun 11, 2014 5:23 am
Contact:

### Re: Another approach to Cable Resistance (with fluid network)

I was actually looking at converting the fluid system to work more like the electric network for performance reasons.

Making the electric network operate like the fluid system does now is just not going to happen. The performance implications in doing that would be ridiculous and as the electric network got bigger the performance would drop off quickly.
If you want to get ahold of me I'm almost always on Discord.

Skyfront
Burner Inserter
Posts: 5
Joined: Thu May 19, 2016 1:11 pm
Contact:

### Idea for adding complexity in power management

I found a post discussing how it would be nice if it was possible to add more complexity to the power distribution of the game. There were a lot of arguments on how it could be done but none of them were plausible because of computational overhead.

What I am doing in this post is coming with a new suggestion on how power loss during transmission can be handled. Without having too much of an idea on how easy this will be to implement it should not add an insane amount of extra computation to the game.

The basic idea is to keep it simple. Add a multipier to every power pole. Everything connected (which is not a power pole) to that power pole has its power consumption multiplied by the poles multiplier.

The multiplier is thought to be set based on how far the pole is from the nearest connected zero loss power source. A zero loss power source could be things like steam engines, the big steel power lines (transmission lines?) solar cells or accumulators.

By implementing it in a simple way like this you don't add a lot of overhead when it comes to extra processing, and the power draw should only need to be calculated once and otherwise your power network is just at it is in the game right now.

Implementing this will make it beneficial to not just spagetti string your power network together because if you do the part of your factory far away from your power generation will begin to consume inordinate amounts of electricity.

How does this sound for how adding complexity to the game without breaking it?

Koub
Global Moderator
Posts: 6542
Joined: Fri May 30, 2014 8:54 am
Contact:

### Re: Another approach to Cable Resistance (with fluid network)

[Koub] No need to start a new topic, the idea in all these topics is no stop lossless/immediate electric network. Topics merged.
Koub - Please consider English is not my native language.

Skyfront
Burner Inserter
Posts: 5
Joined: Thu May 19, 2016 1:11 pm
Contact:

### Re: Another approach to Cable Resistance (with fluid network)

Thanks for the service.

Blurb
Inserter
Posts: 29
Joined: Sun Dec 27, 2015 12:34 pm
Contact:

### Re: Another approach to Cable Resistance (with fluid network)

A somewhat abstracted way of implementing cable resistance is to give each power pole a constant power drain.
Letting this power drain be proportional to the pole's coverage area, players would also be encouraged to use poles appropriate for the task at hand.
It'd be a very direct way of emulating power loss, and should be computationally cheap - although the distance element would be completely ignored.

Rseding91
Factorio Staff
Posts: 11923
Joined: Wed Jun 11, 2014 5:23 am
Contact:

### Re: Another approach to Cable Resistance (with fluid network)

Blurb wrote:... although the distance element would be completely ignored.
There's always that one piece of any of the "solutions" that make the solution infeasible
If you want to get ahold of me I'm almost always on Discord.

Sean Mirrsen
Long Handed Inserter
Posts: 86
Joined: Wed Apr 27, 2016 6:30 pm
Contact:

### Re: Another approach to Cable Resistance (with fluid network)

I don't know if it's been suggested or thought of already - I can't read through all the different posts on the matter right now - but have you ever considered treating the system as a pathfinding solution, rather than a flow one? Because, really, electricity is not a flow. If you have a power consumer on the end of a very long line that only gets a fraction of the maximum power, then if you plug it in you'll get a reduction of available power across the entire network - the far-away consumer will have a cap on how much it can draw from the grid, but it will draw any available amount it needs up to that cap, even if there are other consumers closer to the powerplants.

With that in mind, something like a good pathfinding algorithm could suit your needs far better than a flow simulation. It might not be perfectly realistic, but then hardly anything in Factorio actually is. You'll end up with a dynamic calculation of paths by nodes, from each source to each destination, with assigned weights for calculating the cheapest path. Nodes are the power poles, the length of each cable can be easily gotten at, and the weight for getting from one node to the next is the cable length, maaaaaybe modified by the type of power pole. Each node will end up with a table of path cost values for each of the power providers in the grid, and the total power available at the pole will be the sum of those modified values. Still probably not a very performance-cheap solution, but since recalculations will only be required when the grid layout changes (i.e. not all that often), it could probably be a better solution than some.