Page 1 of 1

Boiler energy is bounded ?!

Posted: Tue Feb 03, 2015 2:32 pm
by Fatmice
So, I was messing around with boiler type. Since energy member variable is [RW] for boiler, I thought I could just put any positive number in. Much to my surprise, that is not the case. For a vanilla boiler (energy_consumption=390kW) , the most one can add is (520000/75) J ~ 6933.333333 J at a time through the console or per tick or per whatever-time-interval if in control.lua. If you add more than this number, the temperature rise is not higher. Why??? What is so special about the ratio 52/75?

Furthermore, for any general boiler with base_area and liquid with liquid-heat-capacity, it seems the maximum of energy is (52/75) * (base_area*10) * (liquid-heat-capacity) J

Re: Boiler energy is quantized ?!

Posted: Tue Feb 03, 2015 8:09 pm
by Koub
Quantum mechanics applied to Factorio boilers :)
/mind blown

Re: Boiler energy is bounded ?!

Posted: Tue Feb 03, 2015 11:23 pm
by Fatmice
I investigated further but still do not know how to derive the funky ratio of 52/75.

In a vanilla boiler with no steam-engine connected and using water, the quanta of 6933.333333 J can be applied to 10 units of fluid to give a temperature rise of exactly 0.6933333333 C. If an energy larger than 6933.333333 is applied, the temperature rise is still 0.6933333333 C with the extra energy above the maximum simply vanished. Energy less than 6933.333333 J can be used giving the corresponding temperature rise. If the vanilla boiler is working, .energy returns 433.3333333333. This number does not change regardless of fuel type. So why that number? 6933.33333333 - 433.33333333 = 6500 J Where did 6500 J come from? energy_consumption of vanilla boiler is 390kW => 390000J/s / (60 ticks/s) = 6500 J / tick.

This leads me to think that .energy in a boiler type is a buffer that holds the excess amount of energy waiting be applied to the fluid, but that .energy is not a boundless buffer. The size of the buffer is proportional to the base_area and heat capacity of the fluid modified by the fudge factor 52/75. But where did 52/75 came from?

Re: Boiler energy is bounded ?!

Posted: Wed Feb 04, 2015 5:16 am
by Fatmice
Well well...seems I figured this out after all.

.energy buffer size is related to energy_consumption of a boiler type. It is not related to the heat-capacity of a fluid or the base_area. Although a bigger base_area will inversely affect rate of temperature rise, but only if you start with a full boiler, which is rarely the case.

The formula is pretty straight forward. .energy buffer size (J) = energy_consumption (J) * 16/15. I don't know why the devs love the number 16/15 which is 6.6%. This same ratio is also used for the maximum energy that can be extracted by generator types which is 544/6 KJ / tick, which came from 85 KJ * 16/15.

So what does this mean? It simply means via script, one can "overclock" any boiler by 6.6%

It so happens that 1/15 is a repeating decimal and in percent form it is 6.666666 => 666. The devs are satanist! :twisted:

Re: Boiler energy is bounded ?!

Posted: Wed Feb 04, 2015 11:18 am
by Nemoricus
15 does happen to be a divisor of the target frame rate for Factorio (60 FPS).

Re: Boiler energy is bounded ?!

Posted: Wed Feb 04, 2015 1:45 pm
by rk84
For some reason they add resting consumption also to buffer size. Normally used with electric energy sources.
resting_consumption = 1 / 30.0
buffer size = energy_consumption * (1 + 2 * resting_consumption)

Side note:
I think that energy consumption should be change to output power or something. Because boiler has effectivity 0.5, it actually consumes 780kW and half of that is used to heat water.

Re: Boiler energy is bounded ?!

Posted: Wed Feb 04, 2015 10:01 pm
by Fatmice
rk84 wrote:For some reason they add resting consumption also to buffer size. Normally used with electric energy sources.
resting_consumption = 1 / 30.0
buffer size = energy_consumption * (1 + 2 * resting_consumption)

Side note:
I think that energy consumption should be change to output power or something. Because boiler has effectivity 0.5, it actually consumes 780kW and half of that is used to heat water.
Where did you find resting_consumption? I never saw it in any prototypes... :roll:

I'm pretty sure Vanilla boiler does consume 780 KW. It's pretty easy to test, just give it a fuel with exactly 780 KJ of energy. It is expected only 390 KJ will be applied to the fluid. It seems clear though that .energy is a buffer to store energy after some fuels have been converted to energy while factoring in the boiler's effectivity. I don't have access to the source code but this algorithm makes logical sense given how boilers behave.
  1. Destroy a fuel and apply fuel_value to staging_buffer
  2. if fluid_temperature < max_temperature and staging_buffer > 0
    staging_buffer = staging_buffer - [(energy_consumption/tick (in J) - .energy) * effectivity]
    .energy = (energy_consumption/tick (in J) - .energy) + .energy
    apply .energy to the fluidbox
  3. if staging_buffer < 0
    go back to 1
staging_buffer is only evident by the consumption bar in the boiler. It's not necessary to access it anyway since .energy is enough. It is likely staging_buffer can be negative during a tick but will be refilled in the next tick.

Re: Boiler energy is bounded ?!

Posted: Thu Feb 05, 2015 7:28 am
by Rahjital
Fatmice wrote:Where did you find resting_consumption? I never saw it in any prototypes... :roll:
It doesn't exist. Idle consumption is controlled by the energy_source.drain property, and it defaults to energy_consumption / 30.

Re: Boiler energy is bounded ?!

Posted: Thu Feb 05, 2015 9:41 am
by Fatmice
Rahjital wrote: It doesn't exist. Idle consumption is controlled by the energy_source.drain property, and it defaults to energy_consumption / 30.
Hm, I see. This is known from reading source code I gathered? I see no mention of how the drain property is defined on either the wiki or searching this forum.