Jump to content

heat deletion in UpdateLiquid() when liquids "fall"


monrandria
  • Branch: Live Branch Version: Windows Pending

I've isolated the source of the thermodynamics issue reported a couple weeks ago.

The root of the problem is in UpdateLiquid() when liquids "fall" (i.e. SimEvents::SpawnFallingLiquid) is called, it is called with the pre-tick temperature.  In the situation where this cell has already participated in liquid advection from an adjacent cell, this causes net deletion.

Consider:

image.png.4e782221045cd2787bae41ceb8dc36cb.png

 

Each of these have 200kg of petrol at 100C next to 100kg of petrol at 0C.  If you let them settle, they will settle at different temperatures: the situation on the left (where the bug happens) settles ~63.1C.  The one on the right settles at the (correct) 66.6.

 

The reason is processing order.  The situation on the left:

1. First the temperatures are shared, resulting in 200kg @ 87.5C and 100kg @ 25.

2. CopyFrom() is called, pre-tick is reset to post-tick.

3. Mass movement (UpdateLiquid).

2a. The cell on the left pushes 25kg @ 87.5C to the cell in the middle, resulting in 125kg @ 37.5C.

2b. Now the cell in the middle is called, and it wants to push 25kg off the ledge.  The problem is that it does this at the "pre-tick" temperature.  In other words, we're deleting 25kg at 37.5C and Spawning it at a different temperature.

The situation on the right conserves heat because the liquid is pushed off the ledge first (before it has felt the "push" from the right), so pre- and post-tick temperatures are the same, so there is no instantaneous loss of heat.

 


Steps to Reproduce

Create the situations above and let them settle.

  • Sanity 2
  • Spooky 1



User Feedback


I'm having a bit of trouble parsing your setup.  I might just be tired, but maybe a video could help?  Or a save game where it is set up beforehand?  I would love to experiment with it and learn more.

Share this comment


Link to comment
Share on other sites

Sure.  I attached a save file: (maybe it doesn't work?).

 

The setup is:

Cell 1: 200kg of petrol @ 100C.

Cell 2: 100kg of petrol @ 0C.

Cell 3: vacuum (with reservoir below)

We should expect the weighted average temperature once they settle into that little reservoir to be 66.6C (yes?).  But if you try it oriented left- and right (as above -- there's nothing else) you'll get different answers.

Or if you get the same answers, I want your save file!

The point is: when fluids flow off a ledge to the right with a temperature (as well as mass) gradient, they delete heat.

 

 

Share this comment


Link to comment
Share on other sites

2 hours ago, monrandria said:

Sure.  I attached a save file: (maybe it doesn't work?).

 

The setup is:

Cell 1: 200kg of petrol @ 100C.

Cell 2: 100kg of petrol @ 0C.

Cell 3: vacuum (with reservoir below)

We should expect the weighted average temperature once they settle into that little reservoir to be 66.6C (yes?).  But if you try it oriented left- and right (as above -- there's nothing else) you'll get different answers.

Or if you get the same answers, I want your save file!

The point is: when fluids flow off a ledge to the right with a temperature (as well as mass) gradient, they delete heat.

 

 

Oh, it worked, my brain just filtered it out because it was right next to the player log I never look at.  Thanks for the video!

Edited by Zarquan

Share this comment


Link to comment
Share on other sites

I should add: SpawnFallingLiquid is called in three places (in certain circumstances, below; to the left; to the right).  It also does things related to disease count (not my main issue, so I didn't look too closely).  But all three should be looked at, of course.

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

×
  • Create New...