From 6cf2e30038feef32da8b6fe27c57d406740cfb56 Mon Sep 17 00:00:00 2001 From: Putnam3145 Date: Thu, 23 Nov 2023 21:54:04 -0800 Subject: [PATCH 1/6] heat pump rebalance --- .../machinery/components/binary_devices/heat_pump.dm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm index 8e01b7cee05b..4062b3d4ef47 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm @@ -141,13 +141,16 @@ //Now we are at the point where we need to actively pump efficiency = get_thermal_efficiency() - var/energy_transfered = 0 CACHE_VSC_PROP(atmos_vsc, /atmos/heatpump/performance_factor, performance_factor) - energy_transfered = clamp(air2.get_thermal_energy_change(target_temp),performance_factor*power_rating,-performance_factor*power_rating) + var/actual_performance_factor = performance_factor*efficiency - var/power_draw = abs(energy_transfered/performance_factor) - air2.adjust_thermal_energy(-air1.adjust_thermal_energy(-energy_transfered*efficiency))//only adds the energy actually removed from air one to air two(- infront of air1 because energy was removed) + var/max_energy_transfer = actual_performance_factor*power_rating + + var/energy_transfered = clamp(network2.get_thermal_energy_change(target_temp),-max_energy_transfer,max_energy_transfer) + + var/power_draw = abs(energy_transfered/actual_performance_factor) + air2.adjust_thermal_energy(-air1.adjust_thermal_energy(-energy_transfered))//only adds the energy actually removed from air one to air two(- infront of air1 because energy was removed) if (power_draw >= 0) last_power_draw_legacy = power_draw use_power(power_draw) From 7b75d1d32f85e6406bc106a2ea8f626f13536666 Mon Sep 17 00:00:00 2001 From: Putnam3145 Date: Thu, 23 Nov 2023 22:21:39 -0800 Subject: [PATCH 2/6] networks don't have airs, silly --- .../machinery/components/binary_devices/heat_pump.dm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm index 4062b3d4ef47..8a1eb830188d 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm @@ -146,11 +146,14 @@ var/actual_performance_factor = performance_factor*efficiency var/max_energy_transfer = actual_performance_factor*power_rating - - var/energy_transfered = clamp(network2.get_thermal_energy_change(target_temp),-max_energy_transfer,max_energy_transfer) - + + var/datum/gas_mixture/sample_air = air2 + if(length(network2.line_members)==1) + sample_air=network2.line_members[0] + //only adds the energy actually removed from air one to air two(- infront of air1 because energy was removed) + var/energy_transfered = -air1.adjust_thermal_energy(-clamp(sample_air.get_thermal_energy_change(target_temp),-max_energy_transfer,max_energy_transfer)) + energy_transfered=abs(air2.adjust_thermal_energy(energy_transfered)) var/power_draw = abs(energy_transfered/actual_performance_factor) - air2.adjust_thermal_energy(-air1.adjust_thermal_energy(-energy_transfered))//only adds the energy actually removed from air one to air two(- infront of air1 because energy was removed) if (power_draw >= 0) last_power_draw_legacy = power_draw use_power(power_draw) From 6d48891cf2e6654773972f885d0f89512e6eeec8 Mon Sep 17 00:00:00 2001 From: Putnam3145 Date: Thu, 23 Nov 2023 22:24:55 -0800 Subject: [PATCH 3/6] forgot a .air --- .../machinery/components/binary_devices/heat_pump.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm index 8a1eb830188d..db337bd29298 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm @@ -149,7 +149,7 @@ var/datum/gas_mixture/sample_air = air2 if(length(network2.line_members)==1) - sample_air=network2.line_members[0] + sample_air=network2.line_members[0].air //only adds the energy actually removed from air one to air two(- infront of air1 because energy was removed) var/energy_transfered = -air1.adjust_thermal_energy(-clamp(sample_air.get_thermal_energy_change(target_temp),-max_energy_transfer,max_energy_transfer)) energy_transfered=abs(air2.adjust_thermal_energy(energy_transfered)) From 387c83dfd87f840f2822fa20b8c18d5aff2b5db0 Mon Sep 17 00:00:00 2001 From: Putnam3145 Date: Wed, 29 Nov 2023 23:48:26 -0800 Subject: [PATCH 4/6] this language is 1-indexed --- .../machinery/components/binary_devices/heat_pump.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm index db337bd29298..525e10897fb9 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm @@ -149,7 +149,7 @@ var/datum/gas_mixture/sample_air = air2 if(length(network2.line_members)==1) - sample_air=network2.line_members[0].air + sample_air=network2.line_members[1].air //only adds the energy actually removed from air one to air two(- infront of air1 because energy was removed) var/energy_transfered = -air1.adjust_thermal_energy(-clamp(sample_air.get_thermal_energy_change(target_temp),-max_energy_transfer,max_energy_transfer)) energy_transfered=abs(air2.adjust_thermal_energy(energy_transfered)) From d003104b4d987661dbfca0340cfc44b09a90e67f Mon Sep 17 00:00:00 2001 From: Putnam3145 Date: Thu, 30 Nov 2023 17:10:57 -0800 Subject: [PATCH 5/6] Reduce temperature swings/wheel spinning --- .../machinery/components/binary_devices/heat_pump.dm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm index 525e10897fb9..e7fb9b92905d 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm @@ -150,6 +150,9 @@ var/datum/gas_mixture/sample_air = air2 if(length(network2.line_members)==1) sample_air=network2.line_members[1].air + + if((sample_air.temperature - target_temp) < 0.001) // don't want wild swings and too much power use + return //only adds the energy actually removed from air one to air two(- infront of air1 because energy was removed) var/energy_transfered = -air1.adjust_thermal_energy(-clamp(sample_air.get_thermal_energy_change(target_temp),-max_energy_transfer,max_energy_transfer)) energy_transfered=abs(air2.adjust_thermal_energy(energy_transfered)) From 0b21df92677e8c9dcdd4f91051654c3b1d292e67 Mon Sep 17 00:00:00 2001 From: LordME <58342752+TheLordME@users.noreply.github.com> Date: Wed, 6 Dec 2023 16:25:08 +0100 Subject: [PATCH 6/6] fixes Heatpumps being monodirectional --- .../machinery/components/binary_devices/heat_pump.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm index e7fb9b92905d..9f7248f61d89 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/heat_pump.dm @@ -146,12 +146,12 @@ var/actual_performance_factor = performance_factor*efficiency var/max_energy_transfer = actual_performance_factor*power_rating - + var/datum/gas_mixture/sample_air = air2 if(length(network2.line_members)==1) sample_air=network2.line_members[1].air - if((sample_air.temperature - target_temp) < 0.001) // don't want wild swings and too much power use + if(abs(sample_air.temperature - target_temp) < 0.001) // don't want wild swings and too much power use return //only adds the energy actually removed from air one to air two(- infront of air1 because energy was removed) var/energy_transfered = -air1.adjust_thermal_energy(-clamp(sample_air.get_thermal_energy_change(target_temp),-max_energy_transfer,max_energy_transfer))