Left-to-Right Liquid Flow Heat Transfer Bug


mathmanican
  • Branch: Preview Branch Version: Linux Known Issue

For a long time people have known that left-to-right counter flow heat exchangers are bugged. I think we've found the reason why. The full discussion is on pages 5 and 6 of this thread

@wachunga noticed the following:

image.thumb.png.38005a32fbe6a6fc1f8d4efa

The point to take away is that the computation for heat on the 40kg cell on the bottom right, that says 300.4C, got its temperature by using a weighted average of the 10kg inflowing liquid at 300C, and the FULL 40kg of 300.5C that was in the cell one tick earlier, rather than using the 30kg that remains in the cell. 

The game is using the mass from the prior tick to compute temperatures in the next tick, but ONLY with liquid flowing left-to-right. 

A little later down in that thread you'll find this:

Found something quite fun. Vertical heat conduction is different in these stair case builds, which accounts for the large difference in performance. Note the temps above the last radiant filled pipe. (the masses are a tad off (they fluctate), but those two temps are constant... (I had to vent out the cold liquid near the base as it's hard to see anything near the top of the exchanger because of rapidly fluctuating mass, so I only have liquid in pipes at the very bottom.)

image.png.930f855d9c0c546fd9f3909dbaa25c6c.png  image.png.39c12252d905650f6ad52492af387b49.png

Here is my working theory

  • Staircase going down left (right to left flow).  Conduction is performed and since both cells on top are 80, no change happens. However, the cell below is colder, so there is a change in temp here. However,  then flow occurs and the left cell drops all mass down (vertical min flow isn't surpassed). As such the colder temp liquid drops (an outflow - gets ignored). Then this cell grabs 1/4 of the 80C cell to the right (the colder stuff already fell), and keeps the 80C temp. The temp remains at 80C always, never changing. Since computations are done left to right, top to bottom, this cell's temp is fixed at 80C. There is no inflow from above or to the left of this elbow cell, 
  • Staircase going down to right (left to right flow - bugged one). Conduction is performed, and the cell in the elbow cools down from the cell below. This time the cell above the stair gets to push some mass right. When the cell on the elbow performs it's computation, it actually looses all the current mass by sending it down, however the incoming mass (from the cell above the stair) performs a weighted average with the current cell's mass (before sending fluid down - the bug @wachunga already noticed). This means the new temp on the elbow cell is lower. 

I am not sure exactly what is going on (have some guesses that I may fully build a spreadsheet around), but I hope this is enough to help you guys know exactly what IS going on before I massively exploit it.  It could be as simple as realizing that you grabbed the mass from the wrong array. Update one array call, and fixed. (That would be a sweet simple fix.)

We can use this bug to amplify any change in temperature we want. Here is a save that has an aquatuner contraption designed to amplify the bug. With escher waterfalls, we can crank up the effect of the bug to work in either direction, either generating lots of heat, or destroying heat. I'm sure I'll come up with something to make us all laugh, if this is still around in a few days. :) 

FlowTestExample.sav


Steps to Reproduce

Paint the values in the cells above (or any values) and watch how after conduction has been done, right flowing liquid uses the wrong mass to find new temperatures. 

  • Like 1
  • Thanks 1


User Feedback


....

Just to add a bit of clarification that probably isn't needed, that erroneous 40kg in the bottom right of the screenshot is precisely 300.4C when it really should be precisely 300.375C. There is no conduction between cells due to the low temperature difference. Resulting temperatures are just a result of liquid flowing from the 80kg cell to the 40kg cell. 10kg of 300C should combine with 30kg of 300.5C to produce 40kg of 300.375C. This is indeed what happens on leftwards flow, but not rightwards.

  • Like 1
  • Thanks 1

Share this comment


Link to comment
Share on other sites
....

Thanks for the info, we're looking into this.

Small note: you're using C for 300+ values, when I believe you intend to use K.
(Water at 300C immediately becomes steam :D)

  • Thanks 2

Share this comment


Link to comment
Share on other sites
....
1 hour ago, klei.ruby said:

you're using C for 300+ values, when I believe you intend to use K.

Ouch. You got me. :lol:

it seems to be a simple incorrect mass in the weighted average formula. Thanks for the quick reply. 

Share this comment


Link to comment
Share on other sites
....

Minor update: I've got a tentative fix that we're testing locally.
It makes left/right flow calculations consistent, but it may have other side effects (as you'd imagine).

  • Like 1
  • Thanks 2

Share this comment


Link to comment
Share on other sites
....
16 minutes ago, klei.ruby said:

it may have other side effects (as you'd imagine).

Of course. One tiny change can snowball out of control (and then metal doors start dropping free blobs of metal on each open/close).  

I hope this was enough to isolate and find everything.  Cheers. 

Share this comment


Link to comment
Share on other sites
....

Minor update #2: there were indeed side effects... liquid grew in mass every time it flowed :D A small pocket of liquid would go on to flood an entire base.

While the cause of the temperature discrepancy is now known, the behaviour needs more time to isolate a fix without side effects, given how the logic works.

  • Like 2
  • Thanks 1
  • Haha 1

Share this comment


Link to comment
Share on other sites
....
50 minutes ago, klei.ruby said:

A small pocket of liquid would go on to flood an entire base.

Fun times. :)  A mass duplication device would not be wanted.  The current system allows for amplification of either heat or cold (the greater the delta, the more the magnification), but mass creation that would flood an entire base is definitely worse. 

Share this comment


Link to comment
Share on other sites
.... .... ....


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now