Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…on-14 into upstream-merge-7
  • Loading branch information
TheArturZh committed Aug 8, 2023
2 parents 9f8ceb2 + 93e48bf commit c84835b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
15 changes: 14 additions & 1 deletion Content.Server/Atmos/EntitySystems/HeatExchangerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,20 @@ private void OnAtmosUpdate(EntityUid uid, HeatExchangerComponent comp, AtmosDevi
// Positive dN flows from inlet to outlet
var dt = (float)(_gameTiming.CurTime - device.LastProcess).TotalSeconds;
var dP = inlet.Air.Pressure - outlet.Air.Pressure;
var dN = comp.G*dP*dt;

// What we want is dN/dt = G*dP (first-order constant-coefficient differential equation w.r.t. P).
// However, by approximating dN = G*dP*dt using Forward Euler dN can be larger than all of the gas
// available for sufficiently large dP. However, we know that dN cannot exceed:
//
// dNMax = (n2T2/V2 - n1T1/V1)/(T2/V1 + T2/V2) = Δp/R/T2/(1/V1 + 1/V2)
//
// Because that is the amount of gas that needs to be transferred to equalize pressures [citation needed].
// So we just limit abs(dN) < abs(dNMax).
//
// Also, by factoring out dP we can avoid taking any abs().
// transferLimit below is equal to dNMax/dP
var transferLimit = 1/Atmospherics.R/outlet.Air.Temperature/(1/inlet.Air.Volume + 1/outlet.Air.Volume);
var dN = dP*Math.Min(comp.G*dt, transferLimit);

GasMixture xfer;
if (dN > 0)
Expand Down
10 changes: 5 additions & 5 deletions Resources/Changelog/Changelog.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
Entries:
- author: liltenhead
changes:
- {message: The economy behind timer electronics has crashed., type: Tweak}
id: 3984
time: '2023-06-13T08:09:18.0000000+00:00'
- author: metalgearsloth
changes:
- {message: Add doorbumpopener to some stuff that should've had it (slimes)., type: Fix}
Expand Down Expand Up @@ -2983,3 +2978,8 @@ Entries:
- {message: Composting produce into trays actually works now., type: Fix}
id: 4483
time: '2023-08-08T00:29:59.0000000+00:00'
- author: Ilya246
changes:
- {message: Fix radiator transfer rate in high-pressure environments., type: Fix}
id: 4484
time: '2023-08-08T08:16:23.0000000+00:00'

0 comments on commit c84835b

Please sign in to comment.