[Genhis] [1.1.42] Incorrect consumption by fluid burning generator

This subforum contains all the issues which we already resolved.
Post Reply
Anachrony
Fast Inserter
Fast Inserter
Posts: 139
Joined: Thu Sep 21, 2017 10:55 pm
Contact:

[Genhis] [1.1.42] Incorrect consumption by fluid burning generator

Post by Anachrony »

What did you do?
Used fluid burning generator in mod with burns_fluid=true, scale_fluid_usage=true, and provided it with a fluid that has no fuel value. In particular it was a turbine in the Nullius overhaul, which burns compressed gases and where steam has a fixed fuel value that it uses instead of temperature.

What happened?
The turbine consumes fluids with no fuel value, and falsely displays the consumption rate at 0/s, even though it is actually destroying the non-fuel fluid at the maximum rate the generator allows. The generator is not animated and from all outward appearances seems to be idle even though it is consuming fluid quite rapidly.
turbine.png
turbine.png (998.67 KiB) Viewed 3809 times
In the first panel you can see the turbine is full of fluid, with consumption 0/s out of 1.2k/s, and power output of 0. It is also not showing an active animation.
In the second panel, you can see that the pump is still continuously filling it at 1.2k/s, even though it's apparently full already. The pump is capable of more throughput, but that rate suspiciously matches the max consumption rate of the turbine.
In the third panel, you can see that as soon as the pump is removed, the turbine's fluid contents rapidly decline to zero, even though it's not connected to anything and says it's not consuming anything.

What did you expect to happen instead?
Either one of 2 possibilities:
A) Ideally generators with burns_fluid=true and scale_fluid_usage=true would simply not burn fluids with no fuel value. One argument I've heard for the current behavior is that people may implement universal fluid void entities as generators, however, if so surely they would set scale_fluid_usage to false. scale_fluid_usage true indicates not to waste any more fuel than necessary to get the most energy production supported by that machine. Well if the fuel value is zero, then it gets as much energy as it's going to get consuming 0 fluid per second and anything more is a waste. If the goal is to waste as much as possible, then surely scale_fluid_usage = false would be the correct setting to accomplish that. I don't think the current behavior makes sense for any realistic use case with these settings. This behavior seems like perhaps more of a design flaw than a clear bug, yet there is a bug here and this would be the simplest and most sensible way to make the bug irrelevant.

B) At very least it should accurately display the amount being consumed. Showing 0/s is wrong when it's clearly consuming the full amount that the throughput of the generator allows. It should also be animated as it would be if consuming fuel. If the current behavior is intended, this display should at least be fixed. But if the behavior were improved then it would not longer be an issue because it would actually be consuming 0 like it shows.

Reproducing:
Key fields in fluid burning generator prototype:

Code: Select all

    type = "generator",
    name = "nullius-priority-turbine-2",
    burns_fluid = true,
    scale_fluid_usage = true,
    fluid_usage_per_tick = 20,
    max_power_output = "6MW",
    effectivity = 1,
Provide a fluid with nil or zero fuel value to this generator. Fill it with a pump, and watch the pump continuously fill it at the rate of whatever fluid_usage_per_tick the generator supports. Observe that the consumption of the generator shows up as 0/s, and the energy output is also 0. There is no clear sign that the generator is doing anything. Remove the pump, and watch the fluid contents of the generator rapidly go down to zero despite saying it's not consuming fluid and not being attached to anything.

The overhaul mod I'm using here is Nullius, and the fluid is nitrogen, but the bug can be demonstrated with any fluid without a fuel value, and any mod that uses fluid burning generators. It happens consistently and doesn't require any special conditions beyond this. Nevertheless, I've attached my save if that helps in reproducing it more easily:
TurbineBug.zip
(32.2 MiB) Downloaded 241 times

Black_Noise
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Dec 16, 2020 3:08 pm
Contact:

Re: [1.1.42] Incorrect consumption by fluid burning generator

Post by Black_Noise »

Some thoughts on this matter:
  • Ideally, a power generator entity that burns fluids for energy should not, as default behavior, destroy fluids with no fluid value. Ideally it wouldn't even be allowed in the fluid box but absent that, it should at least not magically destroy it.
  • This is especially true for the Nullius mod, in which a major challenge of the game is processing non-disposable byproduct fluids into disposable forms, which can then be "properly" disposed of using dedicated item void entities that accept only a specific and tooltip accessible subset of fluids. Currently it is possible to completely bypass that by just directing any byproduct fluid into a very cheap and high throughput generator and have it disappear. I have seen players (probably) unintentionally abusing this behavior, thinking it's intentional design.
  • I vaguely remember early on in factorio that steam engine exhibited similar unintended behavior, which speedrunners at the time abused in order to deal with oil processing byproducts. Since then steam engines got a fluid filter set to steam only, which solved the problem for vanilla, but still leaves limited options for modders.
  • From digging in the forum, it doesn't look like fluid filters can be expanded into an array of allowed fluids due to technical/performance reasons, so that kind of fix is (if my understanding is right) not an option.
  • I am guessing that for similar reasons, it isn't feasible to port fuel_cateogry behavior from burner_energy_source to liquid_energy_source.
  • I have tested the behavior for other entities with a fluid_energy_source, and generators are the only one which destroys non-fuel liquids, so there is clearly something weird going on in the generator prototype code, perhaps a flag which checks for 0 fuel value which then sets the generator into a fluid destruction mode.
Thoughts on possible solutions:
  • Since some mods do, in fact, use this behavior for their general purpose fluid void entities, a solution to this behavior will ideally preserve backwards-compatibility, give or take having mods set the correct flag combination for their generator entities.
  • I suggest either implementing Anachrony's suggestion to only enable this behavior when "burns_fluid=true, scale_fluid_usage=false", or adding a new default-true flag like "destroy_nonfuel_fluids", which would preserve current behavior while giving modders the option to turn it off.
  • In either case, there is definitely an interface bug where generators that are currently destroying non-fuel liquids show "0/max rate" consumption, when in fact the fluid is being destroyed as fast as the generator entity can handle it.

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

Re: [1.1.42] Incorrect consumption by fluid burning generator

Post by mrvn »

Black_Noise wrote:
Mon Oct 25, 2021 10:02 pm
I have tested the behavior for other entities with a fluid_energy_source, and generators are the only one which destroys non-fuel liquids, so there is clearly something weird going on in the generator prototype code, perhaps a flag which checks for 0 fuel value which then sets the generator into a fluid destruction mode.
The code probably has something like this:

Code: Select all

    double energy = fluid.amount * fluid.fuel_value;
    if (energy < generator.max_energy) {
        fluid.amount = 0;
    } else {
        fluid.amount -= generator.max_energy / fluid.fuel_value;
        energy = generator.max_energy;
    }
Note: The source might not have that code exactly but something the compiler optimizes like that.

Genhis
Factorio Staff
Factorio Staff
Posts: 132
Joined: Wed Dec 24, 2014 8:19 am
Contact:

Re: [Genhis] [1.1.42] Incorrect consumption by fluid burning generator

Post by Genhis »

Thank you all for your input.

Firstly, the tooltip issue is fixed for the next release. It will show the actual amount of fluid consumed in cases when the fluid doesn't generate any energy.

Secondly, I added destroy_non_fuel_fluid property as Black_Noise suggested. This will preserve the voiding behavior for mods which want to use it and allow others to disable it.

Anachrony
Fast Inserter
Fast Inserter
Posts: 139
Joined: Thu Sep 21, 2017 10:55 pm
Contact:

Re: [Genhis] [1.1.42] Incorrect consumption by fluid burning generator

Post by Anachrony »

Thank you! I will enable that property for the mod when available.

Post Reply

Return to “Resolved Problems and Bugs”