Page 1 of 1

Cable Resistance / Non-lossless Power Transmission

Posted: Sat Sep 05, 2015 7:22 pm
by ssilk
This is about energy loss over distance.

First: The point, why I underline "over distance" is, that it makes no sense to add just some power loss per power pole or add different power networks with different voltage and transformers between the networks (just two examples of many ideas). The game-play won't change. The point of this suggestion is, that you need to think about energy distribution to distant points (maybe more than 500 tiles?) and this will not change, if you add just more energy usage. It's the opposite: The bigger you make your (single) electric network, the better. But it will change, if the energy transport via wires is at some point so expensive that you need to find other methods.

The current state of discussion is, that it is not so easy, cause it needs to calculate the flow of energy in the whole network for (nearly) every tick, which is far above the possibilities of current computers.

This is expressed at it's best in this article: viewtopic.php?f=6&t=24951&p=160688#p160031
Rseding91 wrote: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.
In other words: Wanted (also by the devs), but not possible yet. (and a lot of work has been flown into the ideas till now, so if you have another idea: PLEASE read the threads below, to see, if there are some similarities).

Other ideas are mentioned in the discussion threads:

viewtopic.php?f=6&t=119 Energy Loss Over Distance (Very old! Nearly everything is said here!)
viewtopic.php?f=6&t=3133 New way for electricity
viewtopic.php?f=6&t=3098&hilit=power+resistance A few ideas that could be implemented.
viewtopic.php?f=6&t=15543 Power Conductor Limit
viewtopic.php?f=6&t=21314 Power Leakage and Electrical Substation
viewtopic.php?f=6&t=24951 Another approach to Cable Resistance (with fluid network)
viewtopic.php?f=6&t=54153 Another try of implementing Power Loss

Related:
With v0.13 we will get a power switch, that enables some interesting usages with the power network. See http://www.factorio.com/blog/post/fff-115

viewtopic.php?f=6&t=1261 Handling different electric networks

viewtopic.php?f=80&t=15546 Cable Resistance / Non-looseless Power Transmission

Re: Cable resistance / Non-looseless Power transmission

Posted: Thu Oct 01, 2015 5:31 pm
by EditorRUS
The current state of discussion is, that it is not so easy, cause it needs to calculate the flow of energy in the whole network for (nearly) every tick, which is far above the possibilities of current computers.
https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm

Re: Cable resistance / Non-looseless Power transmission

Posted: Thu Oct 01, 2015 6:35 pm
by ratchetfreak
EditorRUS wrote:
The current state of discussion is, that it is not so easy, cause it needs to calculate the flow of energy in the whole network for (nearly) every tick, which is far above the possibilities of current computers.
https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
That's shortest path from 1 point to a destination

However for non lossless calculation you need a flow network

Re: Cable resistance / Non-looseless Power transmission

Posted: Sat Oct 03, 2015 7:09 am
by ssilk
EditorRUS wrote:
The current state of discussion is, that it is not so easy, cause it needs to calculate the flow of energy in the whole network for (nearly) every tick, which is far above the possibilities of current computers.
https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
As ratchetfreak said, it's not just calculating from one point to all others, it's calculating from all points to all others. :)

Simplifications are possible but don't make sense.

Re: Cable Resistance / Non-looseless Power Transmission

Posted: Wed Apr 06, 2016 6:44 pm
by coolEE
I'm curious, considering I have little experience with coding for games and resource requirements for doing calculations, the feasibility of using a node-voltage equation matrix to find power loss in an electrical network over the wires at least. Now this may require that people need to be careful about setting up a power network, which I think would be cool. In brief, all that would need to be done is determine the voltage at the source of power, and the resistance over a particular length of wire, then the voltage at the final destination. Doing this simply, we could say it's whatever voltage required by the object +zero. Using the equation, you can find the voltage drop across each length of wire, then use P=V^2/R, you can find the power consumption of the wires in the network. This would open up a purpose for the development of transformers in the game to help mitigate losses over long distances. Then, if you wanted to make it really complicated (cool) introduce voltage drop across other things, like inserters, assembly plants, oil refinery etc. This would add a huge extra level of complexity I imagine, but I think it would be very cool! Then, perhaps even add 1,2and 3 phase inputs and outputs for electricity.

Re: Cable Resistance / Non-looseless Power Transmission

Posted: Mon Jun 27, 2016 6:29 pm
by JoonasD6
I also condone this brilliant idea. Worth noticing is that the maths behind it is well-known so there would not be much guessing or empty trials involved!

Specifically, this mechanic would make people train their intuition about inverse (first-order and quadratic) diminishing. Since P=V^2/R and resistance for a wire can be calculated as R=rho•l/A, where rho is material-specific resistivity, l length and A cross-sectional area, we can write power as a function of cable length: P(l)=V^2•A/(rho•l), so the power we get is inversely proportional to cable length. Also, if we're interested in how much the power changes in terms of length (which sounds like a useful quantity if you want to estimate how much the power drops for a given cable), by differentiating the former expression with respect to l, we get dP/dl=-V^2•A/(rho•l^2). So the rate of change of power is inversely proportional to the second power of cable length.

These calculations are quite straightforward ti implement, if the game already tracks cable lengths. For networks of cables (resistors in parallel and series), that takes a little bit more tweaking, but that's pretty much it. The cross-sectional area A can be a fixed constant or it can be incorporated into the calculations for parallel cables (two identical wires next to each other double the area). It would also be pretty amazing to offer the player upgrades; changing the wiring material (changing rho) one can lessen the power loss in a realistic (and easily calculable) way!

Fascinating. And I want this! :D

Re: Cable Resistance / Non-looseless Power Transmission

Posted: Thu Jun 30, 2016 2:30 pm
by m44v
I also condone this brilliant idea
Is basically just the direct application of the Kirchhoff's laws, kind of the first thing you learn when dealing with circuits. I presume the devs did their homework and got familiar with those laws before discarding the method because is not scalable.

Solving that is basically what SPICE does, solving numerically a NxM matrix equation with N as the number of nodes and M the number of branches (get off my back, I'm typing this by heart). Since each pole represents a node and each wire and factory element a branch, is probably not feasible to compute per game tick.

Re: Cable Resistance / Non-looseless Power Transmission

Posted: Thu Jun 30, 2016 10:39 pm
by JoonasD6
m44v wrote:
I also condone this brilliant idea
Is basically just the direct application of the Kirchhoff's laws, kind of the first thing you learn when dealing with circuits. I presume the devs did their homework and got familiar with those laws before discarding the method because is not scalable.

Solving that is basically what SPICE does, solving numerically a NxM matrix equation with N as the number of nodes and M the number of branches (get off my back, I'm typing this by heart). Since each pole represents a node and each wire and factory element a branch, is probably not feasible to compute per game tick.
There are certainly many ways to simplify/approximate the calculations without losing the main idea or make it confusing in-game. A very simple hack would be to ignore parallel cabling and just work with the maximum distance between power source and target machine. This would overestimate the power loss, but with appropriate scaling, it would feel quite realistic and would give the player an incentive to make paths shorter. This way multiple branches can be left alone.

Re: Cable Resistance / Non-looseless Power Transmission

Posted: Sun Oct 29, 2017 10:11 am
by tobin42
Would it be an idea to set a maximum hop count for power delivery and then calculate usage in the covered area the way it's done right now. This way you only need recalculating of the distance/coverage map when power-poles are placed.

Not very realistic but reasonably clear to the players and doesn't need a lot of calculation.. I hope.

Re: Cable Resistance / Non-looseless Power Transmission

Posted: Mon Oct 30, 2017 9:25 pm
by EditorRUS
Minecraft's Industrial Craft implements this in a robust fashion: by sending "packets" of energy through wires. This could be used to implement this system, but it would suffer from the fact that unlike IC, there are many more active energy generators in Factorio per tick and the way they work is incompatible with the packet system. IC's power generators have internal accumulators which are filled by the generator and returning packets (meaning unused packets recharge the accumulator back) and they send discrete amount of energy each tick. Solar panels would wreck the performance unless they were to be grouped and act like a singular power source. However, it would still be a good start.

Power quanta of Factorio seems to be 1 W of energy and we are dealing with millions, even billions of watts in game. This would, obviously, cause major lag and is not suitable as is, so there should a way to discretize energy consumption/production in a power network so that the least amount of packets had to be sent each tick (current?), enough to traverse the entire network (which would look like a directed graph, from sources to sinks) and not too many as you don't want to send packets to null paths. There is also an issue of redundant branches which must be eliminated first. Fortunately, it's quite intuitive that you only need to send exactly the number of sinks of packets at most and if and only if you for some reason decide to create one branch per sink which is exceedingly stupid and won't happen unless you specifically do so.


A similar system was implemented in Factorissimo which has you set the input/output wattage for a building and each building has an internal accumulator the capacity of which depends on the wattage set. It's for a different purpose, sure, but it works similarly.

Re: Cable Resistance / Non-looseless Power Transmission

Posted: Fri Apr 26, 2019 8:24 pm
by AsherMaximum
What if we introduced High Voltage wires and Transformers? I know this is mentioned as a frequently suggested method, but if we also add transformers having an area of effect that influences power consumption, I think it should have the desired effect of forcing you to think about transmission methods, as well as dealing with multiple smaller low voltage networks, instead of one big one like most factories use now.

Power generating entities would only be able to connect to new High Voltage poles, which would have the same recipes as normal poles, except the wire would be a new wire, high voltage wire, made with both iron and copper.
This would introduce a new type of electricity; high voltage electricity, which would be produced be power plants, and consumed by transformers. Transformers would produce low voltage electricity (the current electricity).

Transformers would connect to both wire types, and have an area of effect like Beacons do now, just much larger. Early game could be made with just wood, copper, and iron, later versions would require circuits. More would be needed depending on the size of your power plant, but since they also have an area of effect, choosing where to place them would be a strategic decision.
The area of effect would affect power consumption, and it would not stack with multiple transformers covering the same area. It would need to be calculated separately from the beacon effect, but could use the same efficiency effect. Alternatively, there could be a different efficiency effect for this.

All power consuming entities would start off with a +700% (total 800%) power consumption. Being in range of a transformer would reduce power consumption down to current levels (+0%, total 100%).

Additionally, accumulators should only be able to connect to the high voltage electric network.

End result is that you could skip adding transformers for things outside of the transformer area, but power consumption would be drastically higher, which should simulate the end results of voltage drop across long distances.

To make it easy to tell if your buildings are running under transformers, the transformers area of effect should show when the power coverage shows, but in a different color than blue (yellow would be good I think).

Re: Cable Resistance / Non-looseless Power Transmission

Posted: Thu Dec 29, 2022 1:44 am
by DarkShadow44
After seeing ALTF4 52 - Fluidic Power Benchmarking , does this change anything? It doesn't seem so inperformant after all, although it won't be "zero overhead".
The problem with Fluidic Power is, that there are some limitations that are impossible to overcome with the modding API, like not being able to use copper cables, only being able to make 90° connections and losing the electric network statistics.
I mean, I have ideas how it could be implemented, but not without API changes.
Maybe engine features combined with an official mod could work? That way you only have the performance loss when you opt into it?
I know it's a lot to ask, but it would be cool.

Re: Cable Resistance / Non-looseless Power Transmission

Posted: Thu Dec 29, 2022 9:24 am
by FuryoftheStars
DarkShadow44 wrote: Thu Dec 29, 2022 1:44 am After seeing ALTF4 52 - Fluidic Power Benchmarking , does this change anything? It doesn't seem so inperformant after all, although it won't be "zero overhead".
The problem with Fluidic Power is, that there are some limitations that are impossible to overcome with the modding API, like not being able to use copper cables, only being able to make 90° connections and losing the electric network statistics.
I mean, I have ideas how it could be implemented, but not without API changes.
Maybe engine features combined with an official mod could work? That way you only have the performance loss when you opt into it?
I know it's a lot to ask, but it would be cool.
Hmm, somewhere around here they mentioned having linked fluid boxes for 1.2, now. I wonder if that could be of any use?

Edit: Ah, here it is - viewtopic.php?f=65&t=94556

Re: Cable Resistance / Non-looseless Power Transmission

Posted: Thu Dec 29, 2022 10:33 am
by Stringweasel
FuryoftheStars wrote: Thu Dec 29, 2022 9:24 am
DarkShadow44 wrote: Thu Dec 29, 2022 1:44 am After seeing ALTF4 52 - Fluidic Power Benchmarking , does this change anything? It doesn't seem so inperformant after all, although it won't be "zero overhead".
The problem with Fluidic Power is, that there are some limitations that are impossible to overcome with the modding API, like not being able to use copper cables, only being able to make 90° connections and losing the electric network statistics.
I mean, I have ideas how it could be implemented, but not without API changes.
Maybe engine features combined with an official mod could work? That way you only have the performance loss when you opt into it?
I know it's a lot to ask, but it would be cool.
Hmm, somewhere around here they mentioned having linked fluid boxes for 1.2, now. I wonder if that could be of any use?

Edit: Ah, here it is - viewtopic.php?f=65&t=94556
The linked pipes can't increase the performance of Fluidic Power. The only oppertunity is to maybe allow diagonal poles with some hidden surface shenanigans.

I think it's mentioned in that Alt-F4 article, although a more realistic electricity simulation is feasable for vanilla, it would greatly reduce the sizes of bases you could build. And personally I wouldn't want that compromise, and would rather be able to build big.

A compromise I would be okay with is something like the Power Overload mod, where electric flow is only simulated between sub-networks (and not individual poles) which are seperated by transformers. And you could even limit which poles can transmit which voltages, and what machines can run on which voltages.

Re: Cable Resistance / Non-lossless Power Transmission

Posted: Thu Dec 29, 2022 5:23 pm
by DarkShadow44
Stringweasel wrote: Thu Dec 29, 2022 10:33 am The linked pipes can't increase the performance of Fluidic Power. The only oppertunity is to maybe allow diagonal poles with some hidden surface shenanigans.
I think that's the point.
Stringweasel wrote: Thu Dec 29, 2022 10:33 am I think it's mentioned in that Alt-F4 article, although a more realistic electricity simulation is feasable for vanilla, it would greatly reduce the sizes of bases you could build. And personally I wouldn't want that compromise, and would rather be able to build big.
That's why I proposed it still be a mod. Together with linked pipes, we only need a way to use the copper connection and a way to still have the electric network statistics. But those need engine changes, unless you know a way this can be modded in already?

Re: Cable Resistance / Non-lossless Power Transmission

Posted: Thu Dec 29, 2022 6:30 pm
by FuryoftheStars
DarkShadow44 wrote: Thu Dec 29, 2022 5:23 pm
Stringweasel wrote: Thu Dec 29, 2022 10:33 am The linked pipes can't increase the performance of Fluidic Power. The only oppertunity is to maybe allow diagonal poles with some hidden surface shenanigans.
I think that's the point.
Yep. :)

Re: Cable Resistance / Non-lossless Power Transmission

Posted: Fri Dec 30, 2022 8:15 am
by Stringweasel
Oof, seems I missed a few integral parts of the conversation. :?
FuryoftheStars wrote: Thu Dec 29, 2022 6:30 pm
DarkShadow44 wrote: Thu Dec 29, 2022 5:23 pm
Stringweasel wrote: Thu Dec 29, 2022 10:33 am The linked pipes can't increase the performance of Fluidic Power. The only oppertunity is to maybe allow diagonal poles with some hidden surface shenanigans.
I think that's the point.
Yep. :)
In that case yeah, it would help. But there's another API limitation that would have to be worked around before I'll add diagonal poles. When holding the pole in your cursor you need to see which poles it will connect to, which is currently done with the vanilla underground fluidbox behaviour. This will not work for diagonal connections, so the player won't know if it connects or not.

Ideally we would have access to the player's cursor position, then I can draw my own connections. But this is not possible because the cursor position isn't part of the game state, and I doubt it would be added in 1.2. Would be really cool and powerful though.

There's also a potential option currently where I could add a 4th entity to my composite power-poles to bring back actual copper cable connections, but I haven't had time to look into that either.
DarkShadow44 wrote: Thu Dec 29, 2022 5:23 pm
Stringweasel wrote: Thu Dec 29, 2022 10:33 am The linked pipes can't increase the performance of Fluidic Power. The only oppertunity is to maybe allow diagonal poles with some hidden surface shenanigans.
I think that's the point.
Stringweasel wrote: Thu Dec 29, 2022 10:33 am I think it's mentioned in that Alt-F4 article, although a more realistic electricity simulation is feasable for vanilla, it would greatly reduce the sizes of bases you could build. And personally I wouldn't want that compromise, and would rather be able to build big.
That's why I proposed it still be a mod. Together with linked pipes, we only need a way to use the copper connection and a way to still have the electric network statistics. But those need engine changes, unless you know a way this can be modded in already?
The visual copper connections could currently be drawn manually with LuaRendering. I've not done much research on this, but the problem is the connection points. The poles rotate randomly to face different directions, and IIRC these do not raise on_entity_rotated events, so I would have no idea where the entity is facing. But this might be easy to create a interface request for.

The network statistics is the hard part I've thought a lot about and haven't thought of a way it might work. I would have to combine the network statistics of multiple networks and show them together without actually connecting them.