Skip to content

Correctly calculate consumedSystemFlux for consumers - #156

Merged
JonnyOThan merged 1 commit into
KSPModStewards:masterfrom
Phantomical:consumed-flux-v2
May 7, 2026
Merged

JonnyOThan merged 1 commit into
KSPModStewards:masterfrom
Phantomical:consumed-flux-v2

Conversation

@Phantomical

Copy link
Copy Markdown
Contributor

This commit makes two different changes:

  • It rewrites HeatLoop.AllocateFlux to avoid the issue where consumedSystemFlux is set to 0 if a system's totalSystemFlux is equal to totalFlux when it is checked.
  • It changes the total flux available to allocate to also take into account negative flux used to lower the temperature of the loop.

With these two changes consumedSystemFlux should now be accurate when the loop temperature is >= its nominal temperature. It should now be possible to actually use it to drive downstream things based on the amount of heat used (e.g. consuming resources, transferring heat, or powering an engine).

I have taken care to make sure that the behaviour stays consistent when below the nominal temperature: flux will still be allocated to consumers based on the positive flux, even if this has no real effect on the loop itself.

Fixes #138

This commit makes two different changes:
- It rewrites `HeatLoop.AllocateFlux` to avoid the issue where
  `consumedSystemFlux` is set to 0 if a system's `totalSystemFlux` is
  equal to `totalFlux` when it is checked.
- It changes the total flux available to allocate to also take into
  account negative flux used to lower the temperature of the loop.

With these two changes `consumedSystemFlux` should now be accurate when
the loop temperature is >= its nominal temperature. It should now be
possible to actually use it to drive downstream things based on the
amount of heat used (e.g. consuming resources, transferring heat, or
powering an engine).

I have taken care to make sure that the behaviour stays consistent when
below the nominal temperature: flux will still be allocated to consumers
based on the positive flux, even if this has no real effect on the loop
itself.

Fixes KSPModStewards#138
@JonnyOThan
JonnyOThan merged commit 3463791 into KSPModStewards:master May 7, 2026
1 check passed
@Phantomical
Phantomical deleted the consumed-flux-v2 branch May 7, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

consumedSystemFlux gets set to zero incorrectly if the heat consumed by a ModuleSystemHeat exactly matches the remaining total flux

2 participants