Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thermomachine balance #57921

Merged
merged 4 commits into from
Mar 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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