Skip to content

Commit

Permalink
Thermomachine balance (#57921)
Browse files Browse the repository at this point in the history
Changed how much internal heat_capacity the machine has, from 5000 to 7500, this to try and increase the speed of cooling/heating that was a bit slower than the old version
Added a check that stops the machine from cooling when set to heater and heating when set to cooler
Changed efficiency to be clamped between 0.65 and 1 (lessen the power spikes)
Power usage reduce on lower efficiency if above a certain amount
removed else if when checking to use enviroment heat (allow to use enviroment to cool even with the red port connected and with gas)
  • Loading branch information
Ghilker committed Mar 27, 2021
1 parent 33ced00 commit 98e90a6
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
var/calculated_bin_rating
for(var/obj/item/stock_parts/matter_bin/bin in component_parts)
calculated_bin_rating += bin.rating
heat_capacity = 5000 * ((calculated_bin_rating - 1) ** 2)
heat_capacity = 7500 * ((calculated_bin_rating - 1) ** 2)
min_temperature = T20C
max_temperature = T20C
if(cooling)
Expand Down Expand Up @@ -110,7 +110,7 @@
. = ..()
. += "<span class='notice'>The thermostat is set to [target_temperature]K ([(T0C-target_temperature)*-1]C).</span>"
if(in_range(user, src) || isobserver(user))
. += "<span class='notice'>The status display reads: Efficiency <b>[(heat_capacity/5000)*100]%</b>.</span>"
. += "<span class='notice'>The status display reads: Efficiency <b>[(heat_capacity/7500)*100]%</b>.</span>"
. += "<span class='notice'>Temperature range <b>[min_temperature]K - [max_temperature]K ([(T0C-min_temperature)*-1]C - [(T0C-max_temperature)*-1]C)</b>.</span>"

/obj/machinery/atmospherics/components/binary/thermomachine/AltClick(mob/living/user)
Expand Down Expand Up @@ -143,6 +143,7 @@
var/main_heat_capacity = main_port.heat_capacity()
var/thermal_heat_capacity = thermal_exchange_port.heat_capacity()
var/temperature_delta = main_port.temperature - target_temperature
temperature_delta = cooling ? max(temperature_delta, 0) : min(temperature_delta, 0) //no cheesy strats

var/motor_heat = 2500
if(abs(temperature_delta) < 1.5) //allow the machine to work more finely
Expand All @@ -158,34 +159,34 @@
temperature_difference = thermal_exchange_port.temperature - main_port.temperature
temperature_difference = cooling ? temperature_difference : 0
if(temperature_difference > 0)
efficiency = max(1 - log(10, temperature_difference) * 0.08, 0)
efficiency = max(1 - log(10, temperature_difference) * 0.08, 0.65)
main_port.temperature = max(main_port.temperature - (heat_amount * efficiency)/ main_heat_capacity + motor_heat / main_heat_capacity, TCMB)
skip_tick = FALSE
else if(use_enviroment_heat && main_port.total_moles() > 0.01 && enviroment.total_moles() > 0.01 && (!thermal_exchange_port.total_moles() || !nodes[2]))
if(use_enviroment_heat && main_port.total_moles() > 0.01 && enviroment.total_moles() > 0.01)
var/enviroment_efficiency = 0
if(cooling)
var/enviroment_heat_capacity = enviroment.heat_capacity()
if(enviroment.total_moles())
enviroment_efficiency = clamp(log(1.55, enviroment.total_moles()) * 0.15, 0, 1)
enviroment_efficiency = clamp(log(1.55, enviroment.total_moles()) * 0.15, 0.65, 1)
enviroment.temperature = max(enviroment.temperature + heat_amount / enviroment_heat_capacity, TCMB)
air_update_turf(FALSE, FALSE)
temperature_difference = enviroment.temperature - main_port.temperature
temperature_difference = cooling ? temperature_difference : 0
if(temperature_difference > 0)
efficiency = max(1 - log(10, temperature_difference) * 0.08, 0)
efficiency = max(1 - log(10, temperature_difference) * 0.08, 0.65)
main_port.temperature = max(main_port.temperature - (heat_amount * efficiency * enviroment_efficiency) / main_heat_capacity + motor_heat / main_heat_capacity, TCMB)
skip_tick = FALSE
else if(use_enviroment_heat)
skip_tick = TRUE

skipping_work = skip_tick

heat_amount = abs(heat_amount)
var/power_usage = 0
if(temperature_delta > 1)
power_usage = (heat_amount * 0.35 + idle_power_usage) ** (1.25 - (5e6 * efficiency) / (max(5e6, heat_amount)))
power_usage = (heat_amount * 0.35 + idle_power_usage) ** (1.25 - (5e7 * efficiency) / (max(5e7, heat_amount)))
else
power_usage = idle_power_usage
if(power_usage > 1e6)
power_usage *= efficiency
use_power(power_usage)
update_appearance()
update_parents()
Expand Down

0 comments on commit 98e90a6

Please sign in to comment.