# Gas Flow Heat Transfer Bug

• Branch: Preview Branch Version: Linux Pending

The bug in this report is almost identical to the bug in the "Left-to-Right Liquid Flow Heat Transfer Bug."  The discussion about this bug can be found here

The average value formula is grabbing the wrong mass when updating gas flows in some configurations  (I haven't tested all configurations under which the bug fires, but I'm going to guess that it has to do with the order in which gas computations occur). Here is a simple example of the bug. The left side is before, and the right side is after one tick of the game.  In particular, pay attention to 150kg cell.

The temperature of 1483.334K is correct, whereas the 1483.872K is not. Heat was created out of thin air. The reason: an incorrect mass was used in the average value formula when combining the transferred mass to the new cell.

After the conduction phase, the three cells would have the following temps:

• m = 100kg, T = 1999.95597
• m = 150kg, T = 1500
• m = 200kg, T = 1000.022015

Then we mix gasses by moving them around. The correct computations are:

• m = 105kg, T = (100*1999.95597+5*1500)/(100+5) = 1976.148543.  Exactly what occurs.
• m = 150kg, T = (145*1500 + 5 * 1000.022015)/(145+5) = 1483.334067. This occurs on the bottom test above. It leaves heat perfectly balanced.
• m = 195kg, T = 1000.022015 (the value shown)

The problem is that in the top test above, the old mass of 150kg is being used in the average value formula, despite the fact that only 145kg remain.  To get the incorrect vale, we just compute

• m=150kg, T = (150*1500 + 5*1000.022015)/(150+5) =  1483.871678 (the overheated tile).   Note that 150, that should have been 145.

So the problem is the exact same problem that occurs in left-to-right liquid flow heat transfer bug. The updated temperatures are using an incorrect mass.

Since this is the second place this bug has occurred, it may be lurking in more places in the code.

This might seem like a really small effect, but I bet it could be magnified greatly.  Along a 10 tile heat exchanger, the liquid flow bug is quite massive. This one will take more tiles to appear as large, as the mass flow is 10% or 12%, instead of 25% with liquid. It is definitely a temperature difference amplification bug, all stemming from an improper average value formula.

Steps to Reproduce

Just paint the cells above, advance one tick, and see the issue. I have observed that sometimes gas flow appears to move right-to-left, and sometimes it moves left-to-right, so you may have to repeat this a couple times to see the issue (as I believe I had one time where no heat was created). The random nature of gas cell movement makes it fun to play with.

## User Feedback

There are no comments to display.