Skip to content

Commit

Permalink
TEG efficiency code tweaks. (#3220)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

Code is [from
citadel](https://github.com/Citadel-Station-13/Citadel-Station-13)
[this PR in
particular](Citadel-Station-13/Citadel-Station-13#15362)
Tweaks TEG code to have efficiency dependent on temperature delta,
instead of whatever the hell whitesands was doing.
This also results in there no longer being an upper cap on TEG output.
Go for a highscore.

![image](https://github.com/user-attachments/assets/a26719b5-9a05-4c92-97dc-65188b415709)
desmos graph if you want to play with numbers:
Y\ =\frac{0.45}{1+\left(e^{-0.0009\cdot\left(X\ -\ 10000\right)\
}\right)}
<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## Why It's Good For The Game
more thermodynamically good is better!
makes room for more accurate and balanced TEGs
also tmtmtl said this was a good and easy first step towards better
TEGs.

<!-- Please add a short description of why you think these changes would
benefit the game. If you can't justify it in words, it might not be
worth adding. -->

## Changelog

:cl:
code: TEG efficiency now depends on temperature delta. 
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
Thera-Pissed committed Aug 25, 2024
1 parent 771e1c5 commit c7a887c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions code/modules/power/generator.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
var/lastgen = 0
var/lastgenlev = -1

var/max_efficiency = 0.45

/obj/machinery/power/generator/Initialize(mapload)
. = ..()
Expand Down Expand Up @@ -75,12 +76,13 @@


if(delta_temperature > 0 && cold_air_heat_capacity > 0 && hot_air_heat_capacity > 0)
var/efficiency = 0.45 //WS Edit - Nerfed down to Cit's efficiency
var/efficiency = LOGISTIC_FUNCTION(max_efficiency,0.0009,delta_temperature,10000)
//2nd (0.0009) effects how 'steep' the curve is, and 4th (10000) effects where the 'middle' is.

var/energy_transfer = delta_temperature*hot_air_heat_capacity*cold_air_heat_capacity/(hot_air_heat_capacity+cold_air_heat_capacity)

lastgen += energy_transfer * efficiency
var/heat = energy_transfer*(1-efficiency)
lastgen += LOGISTIC_FUNCTION(500000,0.0009,delta_temperature,10000) //WS Edit - Buries the 3x3 freezer heater TEG into the ground

hot_air.set_temperature(hot_air.return_temperature() - energy_transfer/hot_air_heat_capacity)
cold_air.set_temperature(cold_air.return_temperature() + heat/cold_air_heat_capacity)
Expand Down

0 comments on commit c7a887c

Please sign in to comment.