GTNewHorizons / GT-New-Horizons-Modpack

New Modpack with Gregtech, Thaumcraft and Witchery
https://www.gtnewhorizons.com/
Other
992 stars 302 forks source link

Burning cables an machine buffers #6129

Closed meneken17 closed 4 years ago

meneken17 commented 4 years ago

Which modpack version are you using?

2.0.8.8 #

What did you try to do, and what did you expect to happen?

Consider the following setup: 4 LV Macerator, which are supplied by a LV Transformer. The Macerators process ore using 2EU/t each. Simple math: 4*2EU/t = 8EU/t (some loss), 8EU/t / 32EU = 1/4 Amp. Using a 1x Tine cable should do fine. #

What happened instead? (Attach screenshots if needed)

You build the Macerators, put in ores, fire up your generators, the machine buffer use 4 A to fill up all at once and your cable is toast. #

What do you suggest instead/what changes do you propose?

Consider real wires: A wire specified for 2 Amps can hold up to 218 A for 32 ms.

Would it be possible to calculate an averange current for cable burns? For example 1xTin can handle 4 Amps but only for a short time and will burn up if the averange over some time exceeds 1 Amp?

yukieiji commented 4 years ago

EU output from the LV Transformer is always 32V4A. Losses can cause Voltage to drop, but they don't change the Amperage.Therefore, all cables extending from the LV transformer need to be able to withstand 32V4A. Also, Machine runs as overclocked as possible to match Machine Voltage Tier. In this case, the speed per Macerator is four times faster at 32EU/t, so 32V4A is needed to operate four Macerators.

Methes commented 4 years ago

Yukieiji is I think completely wrong. Every machine can accept 2 Amps of Voltage for it's current recipe. (the exception being Arc Furnace with 3 Amps). Packets are not pushed, they are called. So a Macerator will use 2EU/t and deplete its internal energy storage. When the internal storage drops under certain threshold, the Macerator will call for up to 2 Amps energy packet, finding a LV Transformer as a provider. LV Transformer will send these 2 Amps and deplete its internal storage by appropriate amount and again call for replenishing from another energy source.

So in theory, a 2x cable should be enough most of the time. However, a situation can occur when in the same tick two macerators will call for 2Amps each, so the Transformer will send 4Amps down the wire, leading to the cable burning up. Therefor it's good practice to use cables as beefy as the provider is.

EDIT: Also, no basic GT machine overclocks with the amount of energy you provide. Machines overclocked naturaly by their voltage tier. So a LV Macerator will always use LV recipe and not overclock, no matter how much energy you provide (and its useless to provide more as energy is called, not pushed).

yukieiji commented 4 years ago

From what I've read on the Wiki, it was wrong, so I'll correct it. According to the Wiki, Amperage machine receive will vary depending on recipe In this case, since the LV Machine is trying to execute the ULV recipe(2EU/t), the amperage received is 1A, and since it is overclocked one time, the EU consumption is 8EU/t, and it needs 32V4A to run 4 Macerator. Therefore, a 4x Tin Cable is required. wiki:https://gtnh.miraheze.org/wiki/Electricity

meneken17 commented 4 years ago

You are right about the overclocking. 3 Macerators will work fine unless you let them fill their buffer aut the same time.

mitchej123 commented 4 years ago

Yukieiji is I think completely wrong.

He is not.

Every machine can accept 2 Amps of Voltage for it's current recipe. (the exception being Arc Furnace with 3 Amps).

Generally true

Packets are not pushed, they are called.

Incorrect. Please look here: emitEnergyToNetwork https://github.com/GTNewHorizons/GT5-Unofficial/blob/experimental/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java#L61-L123 You'll notice it's looking at each side, and sending energy that way, keeping track of how many amps were used.

Now where is that called from you might ask? You'd want to look here for that! BaseMetaTileEntity::UpdateEntity https://github.com/GTNewHorizons/GT5-Unofficial/blob/experimental/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java#L430-L437 Notice it mentions isEnetOutput() Let's see where that returns true... (Search for boolean isEnetOutput())

True:

False

So a Macerator will use 2EU/t and deplete its internal energy storage. When the internal storage drops under certain threshold, the Macerator will call for up to 2 Amps energy packet, finding a LV Transformer as a provider.

Nope, see above.

LV Transformer will send these 2 Amps and deplete its internal storage by appropriate amount and again call for replenishing from another energy source.

Nope, it's actively trying to push (and if it doesn't find anything, traversing the entire connected cable network every time it tries).

So in theory, a 2x cable should be enough most of the time. However, a situation can occur when in the same tick two macerators will call for 2Amps each, so the Transformer will send 4Amps down the wire, leading to the cable burning up.

Not strictly correct. The emitters are constantly pushing, and they don't pay attention to the size of the cable. It pushes amps through the cable and tracks this, using some math and average amps it decides to set the cable to fire when over amped.

Reading: transferElectricity - https://github.com/GTNewHorizons/GT5-Unofficial/blob/experimental/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java#L175-L213 and onPostTick where it's actually set to fire - https://github.com/GTNewHorizons/GT5-Unofficial/blob/experimental/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java#L297-L363

Therefor it's good practice to use cables as beefy as the provider is.

Good advice

EDIT: Also, no basic GT machine overclocks with the amount of energy you provide. Machines overclocked naturaly by their voltage tier. So a LV Macerator will always use LV recipe and not overclock, no matter how much energy you provide (and its useless to provide more as energy is called, not pushed).

ghost commented 4 years ago

First, lv machines will not overclock ulv recipes. All 1-32 eu/t is considered LV from the pov of a singleblock machine. Additionally, singleblocks will not take 2a unless they are in progress on a recipe taking enough eu/t, in the case of an lv machine that number is 16 eu/t. Also, eu is indeed pushed although I'm not sure whether it really matters here. The ticket as originally written was correct; 8 total eu/t is consumed = .25 average amps, however, up to 4 amps peak are transmitted if the transformer becomes able to send eu to all 4 macerators at once. The simplest solution is just to place a diode (block) or 1x battery buffer after the transformer.

As for the suggestion, I would not be necessarily opposed, however, note it may result in a significant complexity increase for an otherwise simple system (what period are we averaging for etc.). Additionally, gt wires are already not the most performant as far as I aware and a change like this may be costly.

Methes commented 4 years ago

Glad someone with greater knowledge chimed in. Interesting to see it's a push system. I'm no coder so I don't read code unless I really have to. My explanation worked so far and helped me understand the GT electricity. I might run into some exceptions I guess. Sorry for calling yukieji completely wrong.

yukieiji commented 4 years ago

@Methes It’s ok. No harm done.

mitchej123 commented 4 years ago

My explanation worked so far and helped me understand the GT electricity. I might run into some exceptions I guess.

Your inferences as to how to deal with it were great.

meneken17 commented 4 years ago

@mitchej123 Thank you for pointing out the code parts. Apparantly this part https://github.com/GTNewHorizons/GT5-Unofficial/blob/experimental/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java#L316-L333 does exactly what i was suggesting and calculates the transfered amps over the last 16 ticks, heats the cable up, if exceeded and finally burns the cable.

So the main issue is that the initial buffer filling takes too much energy/ keeps up the current for to long.

mitchej123 commented 4 years ago

I'm not convinced this is a bug. Use bigger cables.